✨ Expand Qiskit RL actions - #794
flowerthrower wants to merge 10 commits into
Conversation
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
Assisted-by: GPT-5.6 via Codex Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com>
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
4247f27 to
36c7835
Compare
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
36c7835 to
8a50c24
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe Qiskit RL action set now includes layout, routing, and optimization passes. Clifford collection and decomposition behavior changed. The registry includes routing actions. The changelog and upgrade guide document the new actions and required model updates. ChangesQiskit RL action expansion
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The PR expands the Qiskit RL action schema and documents the required model retraining; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Registry
participant QiskitActions
participant DeferredDeviceAction
participant QiskitPasses
Registry->>QiskitActions: request routing actions
QiskitActions->>DeferredDeviceAction: create device-deferred actions
DeferredDeviceAction->>QiskitPasses: construct SabreSwap, BasicSwap, or LookaheadSwap
Registry->>DeferredDeviceAction: register routing actions
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (2 skipped: 2 unsupported.) Full details: Description checkExplanation The description summarizes the Qiskit RL action changes, explains motivation and dependency constraints, identifies migration impact and stacked-PR context, and completes the required checklist with AI-use disclosures. 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 |
burgholzer
left a comment
There was a problem hiding this comment.
Some of these additions do not make too much sense to me to be honest. Might be worth double checking.
| def qiskit_routing_actions() -> list[Action]: | ||
| """Return the Qiskit routing actions.""" | ||
| return [ | ||
| DeferredDeviceAction( | ||
| "SabreSwap", | ||
| CompilationOrigin.QISKIT, | ||
| PassType.ROUTING, | ||
| transpile_pass=lambda device: cast( | ||
| "list[Task]", [SabreSwap(coupling_map=CouplingMap(device.build_coupling_map()), heuristic="decay")] | ||
| ), | ||
| ), | ||
| DeferredDeviceAction( | ||
| "BasicSwap", | ||
| CompilationOrigin.QISKIT, | ||
| PassType.ROUTING, | ||
| transpile_pass=lambda device: cast( | ||
| "list[Task]", [BasicSwap(coupling_map=CouplingMap(device.build_coupling_map()))] | ||
| ), | ||
| ), | ||
| DeferredDeviceAction( | ||
| "LookaheadSwap", | ||
| CompilationOrigin.QISKIT, | ||
| PassType.ROUTING, | ||
| transpile_pass=lambda device: cast( | ||
| "list[Task]", | ||
| [ | ||
| LookaheadSwap( | ||
| coupling_map=CouplingMap(device.build_coupling_map()), | ||
| search_depth=1, | ||
| search_width=1, | ||
| ) | ||
| ], | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Everything that is not SABRE here is a bit pointless to add because these outer routing methods aren't really developed or improved anymore and there is hardly ever any reason to choose them.
There was a problem hiding this comment.
oh i see. my naive thought was "cool more passes -> more room for experimantation for the agent", but you are right they seem hardly useful compared to SABRE
There was a problem hiding this comment.
I'd actually argue that more passes can be quite counter-productive if the passes being added do not really add value but just enlarge the search space.
| DeferredDeviceAction( | ||
| "ElidePermutations", | ||
| CompilationOrigin.QISKIT, | ||
| PassType.LAYOUT, | ||
| transpile_pass=lambda device: cast( | ||
| "list[Task]", | ||
| [ | ||
| ElidePermutations(), | ||
| TrivialLayout(coupling_map=CouplingMap(device.build_coupling_map())), | ||
| FullAncillaAllocation(coupling_map=CouplingMap(device.build_coupling_map())), | ||
| EnlargeWithAncilla(), | ||
| ApplyLayout(), | ||
| ], | ||
| ), | ||
| ), | ||
| ] |
There was a problem hiding this comment.
This is a bit of a strange addition. The Elision pass is a regular pass, not a Layout per-se. I see no reason why it should be coupled to a trivial layout.
There was a problem hiding this comment.
Yeah, the thing I was trying to workaround here is that elidepermuations alone do produce a virtual_permutation_layout, which would be lost after the pass if not directly followed by a layout. The cleaner solution would probably be to track that along in our layout bookkeeping, but i have to investigate first what that would do in a cross-compiler scenario (i.e., when interleaving with TKET for example).
There was a problem hiding this comment.
I see. Then I'd rather defer the addition of this to a later PR. I do not believe the current elide+trivial-layout pass provides any meaningful value.
| CompilationOrigin.QISKIT, | ||
| PassType.OPT, | ||
| [OptimizeCliffords()], | ||
| [CollectCliffords(), OptimizeCliffords()], |
There was a problem hiding this comment.
OptimizeCliffords already works for subsequent Cliffords. So I am fairly sure this is pointless and only adds runtime.
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
Signed-off-by: flowerthrower <flowerthrower@users.noreply.github.com> Assisted-by: GPT 5.6 via Codex
🤖 AI text below 🤖
Description
Expands the RL action space with focused Qiskit layout, routing, and optimization passes:
TrivialLayout,SabreSwap,BasicSwap,LookaheadSwap,RemoveIdentityEquivalent, andOptimize1qGatesSimpleCommutation.It also registers
AIRoutingfor routing an existing layout andAIRouting_optfor combined layout and routing. Both use IBM's local AI routing pass at optimization level 3. The IBM pass is loaded lazily, and both actions are masked whenqiskit-ibm-transpilercannot be imported.The IBM package is not added as a dependency because its current release pins NetworkX 2.8.5 while MQT Bench requires NetworkX 2.8.8 or newer, excludes Python 3.14, and imports Qiskit internals removed in Qiskit 2.5. This keeps the action schema ready for a future compatible release without reintroducing the prototype's global dependency override.
Existing RL models must be retrained because the action schema changes.
This is position 3 of the stack. It depends on #758 and is followed by #795. No new package dependencies are introduced.
Part of #675
Part of #664
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).