Skip to content

✨ Add native gate profile parsing and Euler R-basis synthesis#1832

Open
simon1hofmann wants to merge 15 commits into
mainfrom
native-profile-euler
Open

✨ Add native gate profile parsing and Euler R-basis synthesis#1832
simon1hofmann wants to merge 15 commits into
mainfrom
native-profile-euler

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

Adds NativeProfileSpec for 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

  • parseNativeSpec validates single-qubit strategy + cx/cz entangler (cx preferred when both present)
  • synthesizeUnitary2QWeyl emits Weyl decompositions via cached CX/CZ basis decomposers

Euler R basis

  • EulerBasis::R synthesis and parseEulerBasis("r")
  • fuse-single-qubit-unitary-runs recognizes ROp as an R-basis gate

AI Assistance

Used Composer 2.5 via Cursor for parts of this change. I reviewed the full
diff and take responsibility for everything in this PR.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • I have disclosed the use of AI tools in the PR description as per our AI Usage Guidelines.
  • AI-assisted commits include an Assisted-by: [Model Name] via [Tool Name] footer.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

simon1hofmann and others added 6 commits July 1, 2026 09:35
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

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ect/QCO/Transforms/Decomposition/NativeProfile.cpp 96.4% 5 Missing ⚠️
...lib/Dialect/QCO/Transforms/Decomposition/Euler.cpp 94.4% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@simon1hofmann

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 48ba83ff-3ce2-4a49-ab57-6beaa6ba5281

📥 Commits

Reviewing files that changed from the base of the PR and between 3bf1324 and c751462.

📒 Files selected for processing (2)
  • mlir/lib/Dialect/QCO/Transforms/Decomposition/NativeProfile.cpp
  • mlir/unittests/Dialect/QCO/Transforms/Decomposition/test_weyl_decomposition.cpp
👮 Files not reviewed due to content moderation or server errors (2)
  • mlir/lib/Dialect/QCO/Transforms/Decomposition/NativeProfile.cpp
  • mlir/unittests/Dialect/QCO/Transforms/Decomposition/test_weyl_decomposition.cpp

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for an additional Euler basis option, expanding the available synthesis choices.
    • Introduced native gate profile handling so supported gate sets can be parsed, checked, and used during synthesis.
    • Added two-qubit synthesis support that can adapt to the selected native gate menu.
  • Bug Fixes

    • Improved single-qubit gate recognition and error messaging for the new basis option.
    • Updated global phase handling to avoid unnecessary phase operations when not needed.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: native gate profile parsing and the new Euler R-basis synthesis.
Description check ✅ Passed The description follows the template with a clear summary and checklist, though it omits an issue reference and explicit dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch native-profile-euler

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 58e44bb and 3bf1324.

📒 Files selected for processing (8)
  • mlir/include/mlir/Dialect/QCO/Transforms/Decomposition/Euler.h
  • mlir/include/mlir/Dialect/QCO/Transforms/Decomposition/NativeProfile.h
  • mlir/include/mlir/Dialect/QCO/Transforms/Passes.td
  • mlir/lib/Dialect/QCO/Transforms/Decomposition/Euler.cpp
  • mlir/lib/Dialect/QCO/Transforms/Decomposition/NativeProfile.cpp
  • mlir/lib/Dialect/QCO/Transforms/NativeSynthesis/FuseSingleQubitUnitaryRuns.cpp
  • mlir/unittests/Dialect/QCO/Transforms/Decomposition/test_euler_decomposition.cpp
  • mlir/unittests/Dialect/QCO/Transforms/Decomposition/test_weyl_decomposition.cpp

Comment thread mlir/lib/Dialect/QCO/Transforms/Decomposition/NativeProfile.cpp Outdated
Comment thread mlir/unittests/Dialect/QCO/Transforms/Decomposition/test_weyl_decomposition.cpp Outdated
@simon1hofmann

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@simon1hofmann simon1hofmann marked this pull request as ready for review July 2, 2026 12:22
@simon1hofmann simon1hofmann requested a review from burgholzer July 2, 2026 12:24
@mergify mergify Bot added the conflict label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant