Skip to content

Conversation

p51lee
Copy link
Contributor

@p51lee p51lee commented Sep 5, 2025

Extends Cirq’s QASM 3.0 support to handle multiple conditions (e.g. if (a==1 && b==3)) in both parsing and exporting. This enables semantics-preserving round-trip conversion of QASM programs that use register-wise comparisons as conditions.

Still, circuits with multiple conditions cannot be exported back to QASM 2.0.

Changes:

  • Import
    • updated parser's grammar to allow a condition_list separated by &&.
  • Export
    • added support for emitting multiple conditions with explicit && in QASM 3.0.
    • QASM 2.0 export still raises ValueError

Fixes: #7624

@p51lee p51lee requested review from a team and vtomole as code owners September 5, 2025 07:13
@p51lee p51lee requested a review from viathor September 5, 2025 07:13
@github-actions github-actions bot added the size: M 50< lines changed <250 label Sep 5, 2025
Extends Cirq’s QASM support to handle multiple conditions (e.g. `if
(a==1 && b==3)`) in both parsing and exporting.  This enables
semantics-preserving round-trip conversion of QASM programs that use
register-wise comparisons as conditions.

Still, circuits with multiple conditions cannot be exported back to QASM 2.0.

Changes:
- Import
  - updated parser's grammar to allow a condition_list separated by `&&`.
- Export
  - added support for emitting multiple conditions with explicit && in QASM 3.0.
  - QASM 2.0 export still raises ValueError

Fixes: quantumlib#7624
@p51lee p51lee force-pushed the feat/qasm3-multi-conditions branch from ce8206f to 709db2f Compare September 5, 2025 07:14
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.56%. Comparing base (c35ed72) to head (cfa7962).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7638   +/-   ##
=======================================
  Coverage   99.56%   99.56%           
=======================================
  Files        1088     1088           
  Lines       96048    96069   +21     
=======================================
+ Hits        95632    95653   +21     
  Misses        416      416           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@daxfohl daxfohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

daxfohl

This comment was marked as duplicate.

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for contributing this!

@pavoljuhas pavoljuhas added this pull request to the merge queue Sep 8, 2025
Merged via the queue into quantumlib:main with commit 9f3b2c5 Sep 8, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M 50< lines changed <250

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support roundtrip conversion of register-wise classical conditional qasm

3 participants