✨ Inject Coupling Map Into Mapping Pass#1709
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
burgholzer
left a comment
There was a problem hiding this comment.
LGTM besides two small details.
Before merging, I'd also prompt at least one full review from CodeRabbit. Probably worth waiting until you addressed the two points.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis PR refactors the mapping pass from an Architecture-based design to an AugmentedDevice model. It introduces new public graph-algorithm utilities, removes the Architecture class, updates the pass factory signature, and migrates tests to use direct QCO construction with device coupling constraints. ChangesMapping Pass Refactoring from Architecture to AugmentedDevice
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp (1)
381-384: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winConsider adding a precondition check for device configuration.
If the pass is constructed via the default or options-only constructor (which may be required by MLIR pass infrastructure),
device.nqubits()will be 0, causing empty trial layouts and likely silent failures or undefined behavior.🛡️ Proposed fix to add an assertion
void runOnOperation() override { + assert(device.nqubits() > 0 && + "runOnOperation: device not configured; use createMappingPass()"); assert(alpha > 0 && "runOnOperation: expected alpha > 0"); assert(niterations > 0 && "runOnOperation: expected niterations > 0"); assert(ntrials > 0 && "runOnOperation: expected ntrials > 0");🤖 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/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp` around lines 381 - 384, The runOnOperation method currently assumes device configuration is set; add a precondition that device.nqubits() > 0 (or otherwise validate the device) before using it to avoid empty trial layouts—e.g., in runOnOperation assert or early-return when device.nqubits() == 0 and emit a clear diagnostic; reference the runOnOperation function and the device.nqubits() call to locate where to add this check.
🤖 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/Transforms/Mapping/test_mapping.cpp`:
- Around line 54-63: The guard currently uses op.getNumQubits() > 1 but only
validates operands 0 and 1; change the condition to require exactly two qubits
so multi-qubit (3+) unitaries don't bypass the check. Update the branch that
calls getInputQubit(0)/getInputQubit(1), TypedValue<QubitType> casts,
qubits.getIndex(...) and coupling.contains(...) to run only when
op.getNumQubits() == 2, leaving the WalkResult::interrupt() logic intact.
---
Outside diff comments:
In `@mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp`:
- Around line 381-384: The runOnOperation method currently assumes device
configuration is set; add a precondition that device.nqubits() > 0 (or otherwise
validate the device) before using it to avoid empty trial layouts—e.g., in
runOnOperation assert or early-return when device.nqubits() == 0 and emit a
clear diagnostic; reference the runOnOperation function and the device.nqubits()
call to locate where to add this check.
🪄 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: a24c177c-9233-4649-a32c-d7b471bfa185
📒 Files selected for processing (9)
CHANGELOG.mdmlir/include/mlir/Dialect/QCO/Transforms/Mapping/Architecture.hmlir/include/mlir/Dialect/QCO/Transforms/Mapping/Mapping.hmlir/include/mlir/Dialect/QCO/Utils/Algorithms.hmlir/lib/Dialect/QCO/Transforms/Mapping/Architecture.cppmlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cppmlir/lib/Dialect/QCO/Utils/Algorithms.cppmlir/unittests/Dialect/QCO/Transforms/Mapping/CMakeLists.txtmlir/unittests/Dialect/QCO/Transforms/Mapping/test_mapping.cpp
💤 Files with no reviewable changes (2)
- mlir/include/mlir/Dialect/QCO/Transforms/Mapping/Architecture.h
- mlir/lib/Dialect/QCO/Transforms/Mapping/Architecture.cpp
Description
This pull request addresses the open issue of injecting a coupling map into the mapping pass. Contrary to #1687 a
AugmentedDeviceclass is constructed from the coupling map instead of a QDMI device handle.Changes
Architecture.handArchitecture.cppChecklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.