qrmfold.quantum_reed_muller module¶
- class qrmfold.quantum_reed_muller.ReedMuller(order: int, num_variables: int, minimize_weight: bool = True)[source]¶
Bases:
objectThe classical Reed-Muller code RM(r, m).
- ORDER¶
The order r of the code.
- NUM_VARIABLES¶
The number m of variables of the code.
- BASIS¶
0 <= i < m} for the Reed-Muller code of m variables.
- Type:
Basis vectors {v_i
- generator_matrix¶
Matrix with a row for every subset of the basis vectors of cardinality at most the order r of the code.
- class qrmfold.quantum_reed_muller.QuantumReedMuller(num_variables: int, minimize_weight: bool = True, logical_qubit_ordering: None | dict[int, set[int]] = None)[source]¶
Bases:
objectThe quantum Reed-Muller code CSS(RM(m/2 - 1, m), RM(m/2 - 1, m)).
- NUM_VARIABLES¶
The number m of variables of the underlying classical Reed-Muller code.
- classical¶
The underlying classical Reed-Muller code RM(m/2 - 1, m).
- stabilizer_generators¶
Map from Pauli (X or Z) to a list of stabilizer generators of that type.
- logical_operators: dict[frozenset[int], tuple[PauliString, PauliString]]¶
Map from logical qubit (labelled by a subset of [m]) to its X and Z logical operators.
- logical_qubit_ordering¶
Map from logical qubit index to a unique subset of [m] of cardinality m/2.
- subset_to_logical_index¶
Map from subset of [m] of cardinality m/2 to logical qubit index.
- property LOGICAL_QUBIT_COUNT¶
The number of logical qubits encoded by the code.
- property stabilizer_generators_rref¶
The stabilizer generators as a binary symplectic matrix in reduced row echelon form.
- automorphism(pairs: None | Collection[tuple[int, int]] = None, automorphism_type: Literal['trivial', 'P', 'Q'] = 'Q', gate_type: Literal['swap', 'phase'] = 'phase')[source]¶
Return the physical circuit of U_t(a(K)).
- Parameters:
pairs – Set K of integer pairs (i, j) satisfying 1 <= i, j <= m, where m is the number of variables of the underlying Reed-Muller code. Each integer in
pairsmust be distinct. If omitted, treated as empty.automorphism_type – The automorphism type a: ‘trivial’, ‘P’, or ‘Q’. The trivial automorphism maps every element to itself. P(i, j) swaps basis vectors v_i and v_j. Q(i, j) adds basis vector v_j onto basis vector v_i.
gate_type – Gate type t: swap or phase.
- Returns circuit:
A
stim.Circuitrepresenting the physical circuit of U_t(a(K)).
- automorphism_product(pairs: None | Collection[tuple[int, int]] = None, automorphism_type: Literal['trivial', 'P', 'Q'] = 'Q', gate_type: Literal['swap', 'phase'] = 'phase')[source]¶
Return the physical circuit of
\prod_{L \subseteq K} U_t(a(L)).- Parameters:
pairs – Set K of integer pairs (i, j) satisfying 1 <= i, j <= m, where m is the number of variables of the underlying Reed-Muller code. Each integer in
pairsmust be distinct. If omitted, treated as empty.automorphism_type – The automorphism type a: ‘trivial’, ‘P’, or ‘Q’. The trivial automorphism maps every element to itself. P(i, j) swaps basis vectors v_i and v_j. Q(i, j) adds basis vector v_j onto basis vector v_i.
gate_type – Gate type t: swap or phase.
- Returns circuit:
A
stim.Circuitrepresenting the physical circuit of the product.
- q_phase_logical_action(pairs: Collection[tuple[int, int]])[source]¶
Compute the logical action of U_P(Q(K)).
- Parameters:
pairs – Set K of pairs.
- Returns circuit:
A
stim.Circuitacting on the logical qubits of the code.
- q_phase_product_logical_action(pairs: Collection[tuple[int, int]])[source]¶
Compute the logical action of
\prod_{L \subseteq K} U_P(Q(L)).- Parameters:
pairs – Set K of pairs.
- Returns circuit:
A
stim.Circuitacting on the logical qubits of the code.- Raises:
ValueError – If
pairslonger thanself.NUM_VARIABLES/2.
- gate(name: Literal['S', 'H', 'ZZCZ', 'SWAP'], targets: Iterable[int], reduce_depth: bool = True)[source]¶
Build the physical circuit inducing a logical gate.
- Parameters:
name – The name of the logical gate to implement. This can be S, H, ZZCZ, or SWAP.
targets – Logical qubit indices to apply the gate on. For 2-qubit gates, the operation is broadcast over consecutive target pairs, so an even target count is required.
reduce_depth – Whether to apply basic depth reduction before returning.
- Returns circuit:
A
stim.Circuitinducing the requested logical action.- Raises:
ValueError – If a 2-qubit gate is requested with an odd number of targets.