✨ Add replaceWithAdditionalQubits utility function to qco.if - #1872
Conversation
|
@coderabbitai full review |
✅ Action performedFull review finished. |
📝 WalkthroughWalkthroughAdds a new ChangesIfOp qubit expansion
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 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/IR/SCF/IfOp.cpp`:
- Around line 360-361: The insertion point set on the YieldOp is redundant
because replaceOpWithNewOp<YieldOp>(yield, newResults) already inserts the new
op at the erased op’s location. Remove the unnecessary
rewriter.setInsertionPoint(yield) call in the IfOp lowering path and leave the
replacement call as the only insertion-site logic.
- Around line 340-343: The new region block in IfOp::create/rewriting currently
hardcodes every block argument to QubitType, which breaks qtensor operands and
causes a type mismatch with qco.if’s Variadic<LinearType> signature. Update the
block creation to preserve the original operand types by using inits.getTypes()
when building the argument type list, so the region arguments match the
operand/result types for both qubits and qtensors.
🪄 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: 47b3d03e-7dd0-4086-926c-8e136383c065
📒 Files selected for processing (3)
CHANGELOG.mdmlir/include/mlir/Dialect/QCO/IR/QCOOps.tdmlir/lib/Dialect/QCO/IR/SCF/IfOp.cpp
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Should we add an additional test-suite for this function or rely on the usage of the function in #1870 for coverage? |
burgholzer
left a comment
There was a problem hiding this comment.
Just a couple of smaller comments. Generally LGTM
|
@coderabbitai full review |
✅ Action performedFull review finished. |
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/lib/Dialect/QCO/IR/SCF/IfOp.cpp`:
- Around line 345-373: Replace the original IfOp before returning the new one in
the IfOp::replace/clone flow: processRegion correctly migrates the then/else
bodies into newIfOp, but the old op is never rewritten, so existing uses still
reference its results. Update the logic around processRegion and the final
return to call rewriter.replaceOp on the current IfOp with the corresponding
results from newIfOp, or otherwise ensure the caller performs that replacement
consistently.
🪄 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: b1a67669-b1e7-4162-8028-772f9bf73d1a
📒 Files selected for processing (3)
CHANGELOG.mdmlir/include/mlir/Dialect/QCO/IR/QCOOps.tdmlir/lib/Dialect/QCO/IR/SCF/IfOp.cpp
…nich-quantum-toolkit/core into enh/qco-if-extend-qubits-func
burgholzer
left a comment
There was a problem hiding this comment.
Pushed one commit that simplifies part of the implementation a bit.
Feel free to merge if you agree with the implementation and the CI is green.
|
@burgholzer Thanks for the cleanup! Looks good 🚀 |
Description
Adds the analog of MLIR's
replaceWithreplaceWithAdditionalIterOperandsto theqco::IfOp.Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.