qrmfold.quantum_reed_muller module

class qrmfold.quantum_reed_muller.ReedMuller(order: int, num_variables: int, minimize_weight: bool = True)[source]

Bases: object

The 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: object

The 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.

print()[source]

Print the stabilizer generators and logical operators.

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 pairs must 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.Circuit representing 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 pairs must 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.Circuit representing 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.Circuit acting 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.Circuit acting on the logical qubits of the code.

Raises:

ValueError – If pairs longer than self.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.Circuit inducing the requested logical action.

Raises:

ValueError – If a 2-qubit gate is requested with an odd number of targets.

stabilizers_preserved(physical_circuit: Circuit)[source]

Check if a physical circuit preserves the stabilizer group.

Parameters:

physical_circuit – A physical circuit with 2^m qubits.

Returns preserved:

True if the stabilizer group is preserved, else False.

get_logical_tableau(physical_circuit: Circuit)[source]

Compute the logical action induced by a physical circuit.

Parameters:

physical_circuit – A physical circuit with 2^m qubits that preserves the stabilizer group.

Returns tableau:

The induced logical tableau.