Feat/memory locks - #5
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks quantum memory ownership so gadgets allocate data qubits and reserve ancilla qubits, while primitives consume explicit physical-qubit mappings instead of mutating memory directly.
Changes:
- Introduces
PhysicalQubitand updatesQuantumMemoryto manage data allocations and ancilla locks. - Extends gadget compile APIs to receive quantum memory and passes physical-qubit mappings into primitives.
- Updates primitive implementations, tests, and docs for the new memory model.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/epic/core/compilation/quantum_memory.py |
Adds physical-qubit objects, data allocation snapshots, and ancilla/data locking APIs. |
src/epic/core/compilation/qec_compiler.py |
Passes quantum memory to gadgets and removes primitive-level memory passing. |
src/epic/core/compilation/compilation_context.py |
Initializes memory with an optional size limit and allocates/frees data qubits with code registration. |
src/epic/core/qec_primitives/interfaces/qec_primitive.py |
Adds physical-qubit mappings to primitive payloads and updates primitive implementation protocol. |
src/epic/core/qec_primitives/interfaces/extract_syndrome.py |
Defaults missing detector-port checks to unknown state. |
src/epic/core/data_structure/physical_qubit.py |
Adds the PhysicalQubit value object. |
src/epic/core/data_structure/__init__.py |
Exports PhysicalQubit. |
src/epic/core/data_structure/tanner_graph.py |
Formatting-only import spacing update. |
src/epic/core/qec_object/__init__.py |
Re-exports detector graph port related types. |
src/epic/core/language/qec_gadget.py |
Updates gadget compile interfaces to receive quantum memory. |
src/epic/modules/qec_primitives/apply_gates/simple_gate_application.py |
Uses primitive-provided physical-qubit mappings for gate emission. |
src/epic/modules/qec_primitives/readouts/naive_readout.py |
Uses primitive-provided data qubits and stops freeing memory from the primitive. |
src/epic/modules/qec_primitives/qec_procedures/empty_procedure.py |
Updates compile signature and returns a detector graph port object. |
src/epic/modules/qec_primitives/syndrome_extraction/simple_syndrome_extraction.py |
Uses provided data/ancilla physical qubits for syndrome extraction. |
src/epic/modules/qec_primitives/syndrome_extraction/rsc_syndrome_extraction.py |
Uses provided data/ancilla physical qubits for RSC extraction. |
src/epic/modules/qec_primitives/syndrome_extraction/zxcoloring_extraction.py |
Uses provided data/ancilla physical qubits for ZX-coloring extraction. |
src/epic/modules/qec_gadgets/readout_code.py |
Supplies data-qubit allocation snapshots to readout primitives. |
src/epic/modules/qec_gadgets/logical_resets/init_code.py |
Locks ancilla qubits and passes mappings into reset/syndrome primitives. |
src/epic/modules/qec_gadgets/logical_measurements/naive_logical_measurement.py |
Supplies physical data-qubit mappings to logical readout primitives. |
src/epic/modules/qec_gadgets/pauli_product_measurement/rsc_surgery.py |
Locks ancilla qubits and passes physical mappings through surgery primitives. |
src/epic/core/compilation/measurement_record.py |
Removes an unused import. |
src/epic/core/compilation/compiled_experiment.py |
Reorders imports. |
tests/core/compilation/test_quantum_memory.py |
Updates memory tests for PhysicalQubit allocations and size limits. |
tests/core/compilation/test_qec_compiler.py |
Updates compiler tests for gadget memory injection and primitive signature changes. |
docs/qec_primitives.md |
Documents primitive compile signature and explicit physical-qubit usage. |
docs/qec_gadget.md |
Documents gadget access to quantum memory and ancilla locking. |
docs/core_logic.md |
Updates the core compilation memory model documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+80
to
+83
| if node_knowledge != NodeKnowledge.UNKNOWN: | ||
| for t in sanitized_targets: | ||
| for node in t: | ||
| new_dg_port[node] = QubitPortState(knowledge=node_knowledge) |
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.
Rework the way one manage quantum memory. Gadget are now responsible for allocating and getting locks. Primitives are only given the nodes they are working on.