Complete legacy tracing for dynamic magic wires - #3027
Open
Qottmann wants to merge 10 commits into
Open
Conversation
This was referenced Jul 15, 2026
3 tasks
joshuasteier
pushed a commit
to joshuasteier/pennylane
that referenced
this pull request
Jul 21, 2026
## Summary - Extend `AllocateState` and `qp.allocate()` with `state="magic"` and `state="magic_conj"` for PBC-aligned magic state allocation. - Reject `restored=True` for magic state allocations since those states cannot be restored before deallocation. - Raise `AllocationError` in `resolve_dynamic_wires` for magic states until device simulator support is added. ## Test plan - [x] `tests/test_allocation.py` — enum values, capture jaxpr params, `restored=True` error, `resolve_dynamic_wires` error - [x] CI Merge this PR before the companion [Catalyst PR](PennyLaneAI/catalyst#3027) Made with [Cursor](https://cursor.com) Expose the PBC magic state preparation routine [sc-124605] --------- Co-authored-by: Cursor <cursoragent@cursor.com>
Qottmann
force-pushed
the
qottmann/allocate-magic
branch
from
July 22, 2026 10:02
56de60b to
57f2855
Compare
Qottmann
force-pushed
the
qottmann/allocate-magic
branch
from
July 22, 2026 10:17
57f2855 to
c1e71d2
Compare
Qottmann
force-pushed
the
qottmann/allocate-magic-core
branch
from
July 22, 2026 10:49
efcea1a to
541804b
Compare
Qottmann
force-pushed
the
qottmann/allocate-magic
branch
from
July 22, 2026 10:49
c1e71d2 to
265e202
Compare
Qottmann
added a commit
that referenced
this pull request
Jul 22, 2026
Restore capture=False allocate error coverage, add negative deallocate tests, consolidate deallocate guard logic, document staged fabricate primitives for Co-authored-by: Cursor <cursoragent@cursor.com> #3027, and fix the sharp_bits.rst cross-reference syntax.
Qottmann
force-pushed
the
qottmann/allocate-magic
branch
2 times, most recently
from
July 23, 2026 10:13
b51910e to
ebfaee5
Compare
Qottmann
added a commit
that referenced
this pull request
Jul 23, 2026
Restore capture=False allocate error coverage, add negative deallocate tests, consolidate deallocate guard logic, document staged fabricate primitives for Co-authored-by: Cursor <cursoragent@cursor.com> #3027, and fix the sharp_bits.rst cross-reference syntax.
Qottmann
force-pushed
the
qottmann/allocate-magic-core
branch
from
July 23, 2026 10:34
bb4d012 to
391268d
Compare
Qottmann
force-pushed
the
qottmann/allocate-magic
branch
from
July 23, 2026 10:34
ebfaee5 to
01ee275
Compare
Own all jax_tracer legacy support on top of #3029: qref-mode dynamic wires, allocate/deallocate tracing, MCM/PPM routing, control-flow wire propagation, qref register lifetime, and ppr-to-ppm deallocation ordering. Includes legacy and dual-mode pytest coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
Combine capture and legacy tracing into a single release-note entry for the full allocate feature, following changelog grouping guidelines. Co-authored-by: Cursor <cursoragent@cursor.com>
Replace removed qref_dealloc_qb_p with PennyLane deallocate_prim after the primitive cleanup in the stacked core PR. Co-authored-by: Cursor <cursoragent@cursor.com>
Qottmann
force-pushed
the
qottmann/allocate-magic
branch
from
July 23, 2026 11:00
01ee275 to
3fe4bd1
Compare
…nyLaneAI/catalyst into qottmann/allocate-magic
…nyLaneAI/catalyst into qottmann/allocate-magic
JerryChen97
pushed a commit
that referenced
this pull request
Jul 23, 2026
## Summary PennyLane **dev62** is the minimum pin that includes both [PennyLaneAI/pennylane#9846](PennyLaneAI/pennylane#9846) (`magic-T`) and [PennyLaneAI/pennylane#9841](PennyLaneAI/pennylane#9841) (resource API). This PR bumps Catalyst to that pin and fixes the resulting fallout. **Resource API migration (#9841)** - Bump PennyLane to `0.46.0.dev62` in `.dep-versions` and `doc/requirements.txt` - Replace `SymbolicSpecsResources` checks with `SpecsResources.is_symbolic` - Rename resource fields in tests: `gate_types`/`gate_counts` → `quantum_operations`, `measurements` → `measurement_processes`, `num_gates` → `total_quantum_operations` - Drop `gate_sizes` assertions (no longer tracked) - Handle `PBCSpecsResources` in PPR specs tests (depth fields) **dev62 fallout (Operator2 / magic-T)** - `decompose.py`: safe `.params` access for Operator2 ops; skip abstract `Adjoint(...)` / `Controlled(...)` decomposition-graph nodes that lack `op_type` - PLXPR tests: single-qubit ops like `S`/`T` now lower to `qref_operator` instead of `qref_qinst` - `test_adjoint.py`: replace removed `qp.Rotation` with `qp.Rot` - `test_quantum_control.py`: compare `ControlledOp2` decompositions with `qp.equal` - `test_specs.py`: normalize doubly-controlled `C(S)` counts in `test_complex` This is the base branch for the magic-state allocation stack (`#3029` → `#3027`). --------- Co-authored-by: Cursor <cursoragent@cursor.com>
…gic. Resolve test file conflicts: keep legacy MCM/PPM tests from #3027, drop redundant MLIR pytest removed on core, and remove obsolete capture-only error test. Co-authored-by: Cursor <cursoragent@cursor.com>
…nyLaneAI/catalyst into qottmann/allocate-magic
…to qottmann/allocate-magic
Use quantum.custom result wires in reference-semantics conversion tests and tie ref-side CHECKs to the fabricated qubit in QRef fabricate lit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds all legacy (
capture=False) Catalyst support for magic-T dynamic wires. Stacks on #3029, which lands MLIR lowering and the capture path only.Diff: 6 files, +429 / −42 (single commit on top of #3029).
This PR owns every
jax_tracer.pychange (+218 lines): qref-mode tracing, allocate/deallocate, MCM/PPM routing, control-flow wire propagation, register lifetime, and a compiler fix.Enables TemporaryAND-style workflows: allocate magic-T ancillas → PPM → reactive
qp.cond.Legacy jax_tracer foundation
QRegPromiseqref mode + dynamic-wire → qubit mapping_trace_allocate/_trace_deallocatevia unifiedallocate_prim/deallocate_primMid-circuit measurement routing
MidCircuitPauliMeasure→qref_pauli_measure_pwhen dynamic wires presentMidCircuitMeasure→qref_measure_pwhen dynamic wires presentControl-flow dynamic-wire propagation
cond/for/while/ adjoint regionsdeallocateRegister lifetime & ordering
sort_eqns)ppr-to-ppm fix
quantum.dealloc_qbpast late PPM ops to avoid magic-qubit use-after-deallocTests (+114 pytest lines)
capture=True/False), pauli_measure, mid-circuit measureqp.condwith pre-allocated dynamic wiresReview guide
frontend/catalyst/jax_tracer.pyfrontend/catalyst/api_extensions/quantum_operators.pyfrontend/catalyst/api_extensions/control_flow.pyfrontend/catalyst/jax_extras/tracing.pymlir/lib/PBC/Transforms/ppr_to_ppm.cppTest plan
frontend/test/pytest/test_dynamic_qubit_allocation.py(legacy + dual-mode tests)make format check=1(clang-format, black, isort)Related
jax_tracer)