Skip to content

Adjoint lowering pass can handle control flow with arbitrary quantum operands#2868

Merged
paul0403 merged 11 commits into
mainfrom
paul0403/adjoint_lowering_arbitrary_qargs
May 25, 2026
Merged

Adjoint lowering pass can handle control flow with arbitrary quantum operands#2868
paul0403 merged 11 commits into
mainfrom
paul0403/adjoint_lowering_arbitrary_qargs

Conversation

@paul0403
Copy link
Copy Markdown
Member

@paul0403 paul0403 commented May 22, 2026

Context:
Recently we extended the quantum.adjoint operation to handle arbitrary quantum operand structures (as opposed to being restricted to have a single qreg arg) #2590

In adjoint lowering pass, when the adjoint region contains other control flow regions, the code is still assuming the control flow regions have a single qreg argument (at index 0).

Description of the Change:
Update adjoint lowering pass's control flow part to deal with arbitrary quantum operand structure.

Benefits:
Adjoint lowering pass works with more general programs.
In particular, those generated by the ref-to-value semantics conversion will in general have unconstrained quantum operand structures on control flow ops.

@paul0403 paul0403 marked this pull request as ready for review May 22, 2026 20:00
@paul0403 paul0403 requested a review from a team May 22, 2026 20:00
Copy link
Copy Markdown
Member

@rniczh rniczh left a comment

Choose a reason for hiding this comment

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

Nice work 💯 ! Would you have a chance to add a test for this improvement?

Comment thread mlir/lib/Quantum/Transforms/AdjointPatterns.cpp Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (f1054e9) to head (8557212).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2868   +/-   ##
=======================================
  Coverage   97.01%   97.01%           
=======================================
  Files         167      167           
  Lines       18807    18807           
  Branches     1768     1768           
=======================================
  Hits        18245    18245           
  Misses        417      417           
  Partials      145      145           

☔ 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.

@paul0403 paul0403 requested a review from mehrdad2m May 25, 2026 14:03
Copy link
Copy Markdown
Member

@rniczh rniczh left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Copy Markdown
Contributor

@mehrdad2m mehrdad2m left a comment

Choose a reason for hiding this comment

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

Looks good! just a minor comment.

Comment thread mlir/lib/Quantum/Transforms/AdjointPatterns.cpp
Comment thread mlir/lib/Quantum/Transforms/AdjointPatterns.cpp Outdated
Comment thread mlir/lib/Quantum/Transforms/AdjointPatterns.cpp Outdated
@paul0403 paul0403 merged commit e56a8d4 into main May 25, 2026
39 checks passed
@paul0403 paul0403 deleted the paul0403/adjoint_lowering_arbitrary_qargs branch May 25, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants