Skip to content

loqs.codepacks.codepack_7_1_3_multipatch

Multi-patch machinery for the [[7,1,3]] color code codepack.

This module provides a transversal logical CX between two patches built from codepack_7_1_3_quantinuum2021: one physical Gcnot per aligned data-qubit pair, plus a bookkeeping instruction that conjugates both patches' logical_pauli_frame and latest_syndrome through the standard CSS transversal-CNOT stabilizer map. The builder takes a PatchGeometry with roles "ctrl"/"tgt", no seam.

Stabilizer coupling and its fix. A transversal CX couples both patches' local stabilizer checks going forward: the control's X-type checks become the product of its own value and the target's (S_X^ctrl -> S_X^ctrl * S_X^tgt), and the target's Z-type checks become the product of the target's own value and the control's (S_Z^tgt -> S_Z^ctrl * S_Z^tgt); the control's Z-type and the target's X-type checks are individually unchanged. Because codepack_7_1_3_quantinuum2021's decoder stores only a single latest_syndrome snapshot per patch (overwritten wholesale by every QEC round, rather than an append-only history), this coupling can be corrected with a one-time XOR of that snapshot at CX time -- see conjugate_cx_latest_syndromes() -- fully analogous to conjugate_cx_logical_pauli_frames()'s frame conjugation. Since every subsequent round starts from this corrected baseline and overwrites it completely, this single correction is sufficient for arbitrarily many QEC rounds afterward, not just one: it restores decoding to the same correctness the decoder already has for uncoupled single-patch operation (i.e. its existing single-fault-per-round assumption is not weakened by having gone through a transversal CX). This differs from codepack_surf17_multipatch, which needs a full history-wide XOR because its decoder defers to a joint MWPM pass over an append-only space-time graph rather than decoding one snapshot at a time.

Functions

build_cx_bookkeeping_instruction

build_cx_bookkeeping_instruction(ctrl_patch_label: str, tgt_patch_label: str, name: str = 'Transversal CX frame bookkeeping') -> Instruction

Build the Pauli-frame-bookkeeping half of a transversal logical CX.

Conjugates both patches' logical_pauli_frame (see conjugate_cx_logical_pauli_frames()) and latest_syndrome (see conjugate_cx_latest_syndromes()) through the standard CSS transversal-CNOT rules.

Parameters:

Name Type Description Default
ctrl_patch_label str

Patch label of the control patch.

required
tgt_patch_label str

Patch label of the target patch.

required
name str

Name for logging purposes.

'Transversal CX frame bookkeeping'

Returns:

Type Description
Instruction

The bookkeeping instruction.


build_transversal_cx_circuit_instruction

build_transversal_cx_circuit_instruction(geometry: PatchGeometry, circuit_backend: type[BasePhysicalCircuit] = PyGSTiPhysicalCircuit, include_idles: bool = False, gate_durations: dict[str, int | float] | None = None, idle_gates: dict[int | float, str] | None = None, name: str = 'Transversal CX physical circuit') -> Instruction

Build the physical-circuit half of a transversal logical CX.

One Gcnot per data-qubit pair (7, D0..D6), control patch -> target patch, all in a single layer (every pair acts on disjoint qubits, so they commute freely and can run in parallel).

Parameters:

Name Type Description Default
geometry PatchGeometry

A PatchGeometry with roles "ctrl"/"tgt", each assigned a patch's full qubit list (template order A0,A1,A2,D0..D6); no seam is used by a transversal CX. Only the last 7 (data) qubits of each role participate.

required
circuit_backend type[BasePhysicalCircuit]

The circuit backend. Default is PyGSTiPhysicalCircuit.

PyGSTiPhysicalCircuit
include_idles bool

Whether to pad the layer's non-participating qubits with an idle gate (True) or leave them genuinely blank (False, default).

False
gate_durations dict[str, int | float] | None

See create_qec_code(); defaults to that codepack's own duration-2 Gcnot convention.

None
idle_gates dict[str, int | float] | None

See create_qec_code(); defaults to that codepack's own duration-2 Gcnot convention.

None
name str

Name for logging purposes.

'Transversal CX physical circuit'

Returns:

Type Description
Instruction

A physical circuit instruction (no Pauli frame update; that is done by the bookkeeping instruction).


build_transversal_cx_instruction

build_transversal_cx_instruction(geometry: PatchGeometry, circuit_backend: type[BasePhysicalCircuit] = PyGSTiPhysicalCircuit, include_idles: bool = False, gate_durations: dict[str, int | float] | None = None, idle_gates: dict[int | float, str] | None = None, name: str = 'Transversal Logical CX') -> Instruction

Build a transversal logical CX between two [[7,1,3]] patches.

Composite of build_transversal_cx_circuit_instruction() followed by build_cx_bookkeeping_instruction(). Intended to be placed in a program stack as a global instruction, e.g. (cx_inst, None). See this module's docstring for the stabilizer-coupling correction this instruction applies.

Parameters:

Name Type Description Default
geometry PatchGeometry

A PatchGeometry with roles "ctrl"/"tgt", no seam.

required
circuit_backend type[BasePhysicalCircuit]

The circuit backend. Default is PyGSTiPhysicalCircuit.

PyGSTiPhysicalCircuit
include_idles bool False
gate_durations bool False
idle_gates bool False
name str

Name for logging purposes.

'Transversal Logical CX'

Returns:

Type Description
Instruction

The composite transversal logical CX instruction.


conjugate_cx_latest_syndromes

conjugate_cx_latest_syndromes(syndrome_ctrl: list[int], syndrome_tgt: list[int]) -> tuple[list[int], list[int]]

Conjugate two latest_syndromes through a transversal CX.

Each syndrome is a 6-element [S1, S2, S3, S4, S5, S6] list (X-type checks S1-S3, Z-type checks S4-S6), per codepack_7_1_3_quantinuum2021's convention. This is the syndrome analog of conjugate_cx_logical_pauli_frames(), fixing the two patches' checks to reflect the standard CSS transversal-CNOT stabilizer map (S_X^ctrl -> S_X^ctrl * S_X^tgt, S_Z^tgt -> S_Z^ctrl * S_Z^tgt): the control's X-type checks pick up the target's pre-CX X-type values, and the target's Z-type checks pick up the control's pre-CX Z-type values. The control's Z-type and the target's X-type checks are individually unchanged. Note this is the opposite pairing from the frame conjugation (there, the target's X-bit picks up the control's) -- the frame tracks a physical error operator whose identity spreads forward through the gate, while a syndrome bit is the eigenvalue of a fixed local measurement, which shifts due to stabilizer-group closure across the entangling gate.

Parameters:

Name Type Description Default
syndrome_ctrl list[int]

The control patch's latest_syndrome.

required
syndrome_tgt list[int]

The target patch's latest_syndrome.

required

Returns:

Type Description
tuple[list[int], list[int]]

Updated copies of (syndrome_ctrl, syndrome_tgt).


conjugate_cx_logical_pauli_frames

conjugate_cx_logical_pauli_frames(frame_ctrl: list[int], frame_tgt: list[int]) -> tuple[list[int], list[int]]

Conjugate two logical_pauli_frames through a transversal CX.

Each frame is a 2-element [Z_bit, X_bit] list, per codepack_7_1_3_quantinuum2021's convention. The control's X-bit propagates onto the target and the target's Z-bit propagates onto the control, matching the standard CNOT conjugation rule.

Parameters:

Name Type Description Default
frame_ctrl list[int]

The control patch's logical_pauli_frame.

required
frame_tgt list[int]

The target patch's logical_pauli_frame.

required

Returns:

Type Description
tuple[list[int], list[int]]

Updated copies of (frame_ctrl, frame_tgt).