✨ Convert pow modifier to jeff - #2000
Conversation
Assisted-by: Claude Opus 5 via Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Assisted-by: Claude Opus 5 via Claude Code
|
@coderabbitai full review |
✅ Action performedFull review finished. |
📝 WalkthroughSummary by CodeRabbit
WalkthroughJeff↔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. ChangesPower modifier conversion
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
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 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
📒 Files selected for processing (4)
mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.tdmlir/lib/Conversion/JeffToQCO/JeffToQCO.cppmlir/lib/Conversion/QCOToJeff/QCOToJeff.cppmlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp
💤 Files with no reviewable changes (1)
- mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td
| 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)})); |
There was a problem hiding this comment.
📐 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
Cpp-Linter Report
|
Description
Fixes #1666
Checklist
I have added migration instructions to the upgrade guide (if needed).