Skip to content

✨ Convert pow modifier to jeff - #2000

Draft
denialhaag wants to merge 3 commits into
mainfrom
jeff-pow
Draft

✨ Convert pow modifier to jeff#2000
denialhaag wants to merge 3 commits into
mainfrom
jeff-pow

Conversation

@denialhaag

@denialhaag denialhaag commented Aug 4, 2026

Copy link
Copy Markdown
Member

Description

Fixes #1666

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.

Assisted-by: Claude Opus 5 via Claude Code
@denialhaag denialhaag self-assigned this Aug 4, 2026
@denialhaag denialhaag added enhancement Improvement of existing feature MLIR Anything related to MLIR labels Aug 4, 2026
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@denialhaag

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for converting gates with power modifiers, including combinations with controls and adjoints.
    • Added validation for power exponents and support across standard, custom, phase, and PPR operations.
    • Improved handling of nested gate modifiers during conversion.
  • Bug Fixes

    • Removed the previous limitation that rejected gates with non-trivial powers.
  • Tests

    • Added round-trip coverage for powered, inverted, and controlled gates.

Walkthrough

Jeff↔QCO conversion now supports gate power modifiers. The changes add canonical modifier handling, exponent validation, nested target tracking, power propagation across converted operations, and round-trip tests for powered gates.

Changes

Power modifier conversion

Layer / File(s) Summary
Jeff-to-QCO modifier handling
mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td, mlir/lib/Conversion/JeffToQCO/JeffToQCO.cpp
Power modifiers now use shared canonical wrapping with controls and inversions across supported gate conversions.
QCO-to-Jeff power lowering
mlir/lib/Conversion/QCOToJeff/QCOToJeff.cpp
The lowering tracks power state, validates exponents and nesting, maps targets, and forwards powers to converted operations.
Power modifier round-trip coverage
mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp
Parameterized tests cover powered DCX, inverse and controlled DCX, U, H, and scaled RX programs.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QCOModule
  participant QCOToJeff
  participant LoweringState
  participant JeffModule
  QCOModule->>QCOToJeff: qco.pow operation
  QCOToJeff->>LoweringState: validate and record exponent
  LoweringState->>QCOToJeff: provide power and target mapping
  QCOToJeff->>JeffModule: emit power-modified Jeff operation
Loading

Possibly related PRs

Suggested labels: feature

Suggested reviewers: burgholzer, simon1hofmann

Poem

A rabbit hops through qco.pow,
With gates that turn and neatly flow.
Controls wrap, inverses gleam,
Round trips test each powered beam.
Hop, hop—conversion runs just so!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the issue and checklist but omits the required summary, motivation, dependencies, and AI-assistance disclosures. Add a change summary, motivation and context, dependency details, and the required AI-assisted content checklist and disclosure.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: converting the pow modifier to Jeff.
Linked Issues check ✅ Passed The changes implement pow conversion in both directions and add round-trip tests, matching issue #1666.
Out of Scope Changes check ✅ Passed The code, documentation, and tests are directly related to pow modifier conversion and the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch jeff-pow

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: 1

🤖 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/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp`:
- Around line 489-507: Expand QCOPowOpTest to cover powered qco.gphase,
qco.barrier, and PPR lowering, plus a ctrl(pow(inv(...))) canonical
three-modifier case using the appropriate named builders. Add targeted tests
asserting rejection of negative, fractional, and exponents greater than 255,
covering each exponent-validation path and preserving existing successful cases.
🪄 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 Plus

Run ID: 2090b4be-66a1-4dd3-aa1c-914bb3481418

📥 Commits

Reviewing files that changed from the base of the PR and between 108454d and 1e1c887.

📒 Files selected for processing (4)
  • mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td
  • mlir/lib/Conversion/JeffToQCO/JeffToQCO.cpp
  • mlir/lib/Conversion/QCOToJeff/QCOToJeff.cpp
  • mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp
💤 Files with no reviewable changes (1)
  • mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td

Comment on lines +489 to +507
INSTANTIATE_TEST_SUITE_P(
QCOPowOpTest, JeffRoundTripTest,
testing::Values(
JeffRoundTripTestCase{"PowDCX", MQT_NAMED_BUILDER(powDcx),
MQT_NAMED_BUILDER(powDcx)},
JeffRoundTripTestCase{"PowInverseDCX", MQT_NAMED_BUILDER(powInverseDcx),
MQT_NAMED_BUILDER(powInverseDcx)},
JeffRoundTripTestCase{"PowMultipleControlledDCX",
MQT_NAMED_BUILDER(powMultipleControlledDcx),
MQT_NAMED_BUILDER(powMultipleControlledDcx)},
JeffRoundTripTestCase{"PowU", MQT_NAMED_BUILDER(powU),
MQT_NAMED_BUILDER(powU)},
JeffRoundTripTestCase{"PowEvenH", MQT_NAMED_BUILDER(qco::powEvenH),
MQT_NAMED_BUILDER(qco::alloc1QubitRegister)},
JeffRoundTripTestCase{"PowOddH", MQT_NAMED_BUILDER(qco::powOddH),
MQT_NAMED_BUILDER(qco::h)},
JeffRoundTripTestCase{"PowRxScaled",
MQT_NAMED_BUILDER(qco::powRxScaled),
MQT_NAMED_BUILDER(qco::rxScaled)}));

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Cover all new power conversion behavior.

The suite does not test powered qco.gphase, qco.barrier, or PPR lowering. It also does not test rejection of negative, fractional, or greater-than-255 exponents.

Add success cases for those supported operation categories. Add targeted failure tests for the exponent validation paths. Add a ctrl(pow(inv(...))) case to test the canonical three-modifier composition.

As per coding guidelines, “Add or update automated tests for every behavioral code change.”

🤖 Prompt for 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.

In `@mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp` around
lines 489 - 507, Expand QCOPowOpTest to cover powered qco.gphase, qco.barrier,
and PPR lowering, plus a ctrl(pow(inv(...))) canonical three-modifier case using
the appropriate named builders. Add targeted tests asserting rejection of
negative, fractional, and exponents greater than 255, covering each
exponent-validation path and preserving existing successful cases.

Source: Coding guidelines

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v22.1.8) reports: 3 concern(s)
  • mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp:226:52: warning: [misc-include-cleaner]

    no header providing "int64_t" is directly included

       43 |   auto c = b.allocClassicalBitRegister(static_cast<int64_t>(qubits.size()));
          |                                                    ^
  • mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp:227:28: warning: [misc-include-cleaner]

    no header providing "llvm::enumerate" is directly included

       24 |   for (auto [i, q] : llvm::enumerate(qubits)) {
          |                            ^
  • mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp:253:18: warning: [misc-include-cleaner]

    no header providing "llvm::to_vector" is directly included

       24 |     return llvm::to_vector(inner);
          |                  ^

Have any feedback or feature suggestions? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement of existing feature MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Convert pow modifier to jeff

1 participant