✨ Add native gate profile parsing and Euler R-basis synthesis#1832
✨ Add native gate profile parsing and Euler R-basis synthesis#1832simon1hofmann wants to merge 15 commits into
Conversation
Introduce NativeProfileSpec for parsing native gate menus and driving two-qubit Weyl synthesis, extend Euler decomposition with an R-basis for IQM-style menus, and add isEquivalentUpToGlobalPhase for unitary checks. Assisted-by: Claude Sonnet 4.6 via Cursor Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
👮 Files not reviewed due to content moderation or server errors (2)
📝 WalkthroughSummary by CodeRabbit
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@mlir/lib/Dialect/QCO/Transforms/Decomposition/NativeProfile.cpp`:
- Around line 196-211: The decomposition path in NativeProfile::decomposeTarget
should not call spec.eulerBasis() unless a single-qubit strategy has been
resolved. After the entangler/native gate checks in NativeProfile.cpp, add a
guard for the missing Euler basis and return failure() when NativeProfileSpec
has no resolved basis. Use the existing flow around selectEntangler,
cachedBasisDecomposer(...).decomposeTarget(...), and the later basis-dependent
code so the optional is validated before dereferencing.
In
`@mlir/unittests/Dialect/QCO/Transforms/Decomposition/test_weyl_decomposition.cpp`:
- Around line 465-478: The reconstruction helper currently skips func::ReturnOp
and silently ignores unknown non-unitary ops, which lets invalid qubit returns
or stale inputs pass. Update the loop in the reconstruction logic around the
unitary scan to validate the returned qubits explicitly against the expected
reconstructed qubits, and make any non-unitary/non-GPhase op that is not handled
cause reconstruction to fail rather than continuing. Use the existing helper in
test_weyl_decomposition.cpp that iterates over funcOp.getBody().front() so the
check is enforced wherever the reconstruction result is verified.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 26e05bb4-59f5-4f6c-9f15-f1ee0e8fc6fa
📒 Files selected for processing (8)
mlir/include/mlir/Dialect/QCO/Transforms/Decomposition/Euler.hmlir/include/mlir/Dialect/QCO/Transforms/Decomposition/NativeProfile.hmlir/include/mlir/Dialect/QCO/Transforms/Passes.tdmlir/lib/Dialect/QCO/Transforms/Decomposition/Euler.cppmlir/lib/Dialect/QCO/Transforms/Decomposition/NativeProfile.cppmlir/lib/Dialect/QCO/Transforms/NativeSynthesis/FuseSingleQubitUnitaryRuns.cppmlir/unittests/Dialect/QCO/Transforms/Decomposition/test_euler_decomposition.cppmlir/unittests/Dialect/QCO/Transforms/Decomposition/test_weyl_decomposition.cpp
|
@coderabbitai review |
✅ Action performedReview finished.
|
Description
Adds
NativeProfileSpecfor parsing comma-separated native gate menus (e.g."u,cx","x,sx,rz,cx","r,cz") and driving two-qubit Weyl synthesis from the resolved menu. Extends Euler decomposition with an R basis (R(θ,0) · R(θ,π/2) · R(θ,0)) for IQM-style native sets.Native profile
parseNativeSpecvalidates single-qubit strategy +cx/czentangler (cxpreferred when both present)synthesizeUnitary2QWeylemits Weyl decompositions via cached CX/CZ basis decomposersEuler R basis
EulerBasis::Rsynthesis andparseEulerBasis("r")fuse-single-qubit-unitary-runsrecognizesROpas an R-basis gateAI Assistance
Used
Composer 2.5via Cursor for parts of this change. I reviewed the fulldiff and take responsibility for everything in this PR.
Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.