✨ Add SCF Support to walkProgramGraph#1808
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesQCO SCF region traversal and Drivers Operation* refactor
Sequence Diagram(s)sequenceDiagram
rect rgba(100, 149, 237, 0.5)
Note over Caller,WireIterator: Forward traversal through scf.for / qco.if
end
participant Caller
participant WireIterator
participant TypeSwitch
Caller->>WireIterator: ++it
WireIterator->>WireIterator: isFinal_ set? → transition to sentinel
WireIterator->>WireIterator: isSinkLikeOperation(op_)? → set isFinal_
WireIterator->>WireIterator: isSourceLikeOperation(op_)? → early exit
WireIterator->>TypeSwitch: dispatch current op_
TypeSwitch-->>WireIterator: scf::ForOp/WhileOp → tied loop result value
TypeSwitch-->>WireIterator: qco::IfOp → result at qubit index
TypeSwitch-->>WireIterator: default gate op → next SSA user
WireIterator-->>Caller: updated qubit_ / op_
rect rgba(255, 140, 0, 0.5)
Note over Caller,WireIterator: Backward traversal through qco.if / scf.for
end
Caller->>WireIterator: --it
WireIterator->>WireIterator: isSentinel_? → isFinal_ = true, reactivate
WireIterator->>WireIterator: op_ == nullptr? → block arg, early return
WireIterator->>WireIterator: isSinkLikeOperation(op_)? → stop at boundary
WireIterator->>TypeSwitch: dispatch current op_
TypeSwitch-->>WireIterator: scf::ForOp/WhileOp → getTiedLoopInit operand
TypeSwitch-->>WireIterator: qco::IfOp → find result index → input qubit
TypeSwitch-->>WireIterator: default → defining op qubit
WireIterator->>WireIterator: isFinal_ = false
WireIterator-->>Caller: updated qubit_ / op_
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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/Dialect/QCO/Utils/test_wireiterator.cpp`:
- Line 122: The WireIterator tests are dereferencing the first user directly and
assuming `getUsers().begin()` is stable, which is fragile if more uses appear.
In `test_wireiterator.cpp`, update the affected assertions around
`it.operation()`, `q06.getUsers()`, and the other similar sites to first check
`hasOneUse()` and then capture the user operation into a local variable before
comparing against it. Keep the assertions focused on the expected single-use
case rather than relying on iterator ordering.
🪄 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: dabf446b-0def-4596-ad4f-cf01374adc75
📒 Files selected for processing (6)
CHANGELOG.mdmlir/include/mlir/Dialect/QCO/Utils/Drivers.hmlir/include/mlir/Dialect/QCO/Utils/WireIterator.hmlir/lib/Dialect/QCO/Utils/WireIterator.cppmlir/unittests/Dialect/QCO/Utils/test_drivers.cppmlir/unittests/Dialect/QCO/Utils/test_wireiterator.cpp
burgholzer
left a comment
There was a problem hiding this comment.
Likely just me being too dense, but there are two things that do not quite make sense to me here.
…antum-toolkit/core into enh/scf-support-driver
burgholzer
left a comment
There was a problem hiding this comment.
This looks much more reasonable now 👍🏻
Changes
Drivers.hand update unit tests(Extracted from #1805 to decrease that PR size and ease reviewing)
(Depends on #1806)
Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.