Skip to content

Feat/memory locks - #5

Merged
LennyDZ merged 6 commits into
mainfrom
feat/memory_locks
May 18, 2026
Merged

Feat/memory locks#5
LennyDZ merged 6 commits into
mainfrom
feat/memory_locks

Conversation

@LennyDZ

@LennyDZ LennyDZ commented May 18, 2026

Copy link
Copy Markdown
Owner

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PhysicalQubit and updates QuantumMemory to 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)
Comment thread src/epic/core/qec_primitives/interfaces/qec_primitive.py
Comment thread src/epic/core/compilation/quantum_memory.py
Comment thread src/epic/core/compilation/quantum_memory.py
Comment thread src/epic/core/compilation/quantum_memory.py
@LennyDZ
LennyDZ merged commit b9ec997 into main May 18, 2026
1 check passed
@LennyDZ
LennyDZ deleted the feat/memory_locks branch May 18, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants