mqt.qecc.circuit_synthesis.encoding

Methods for synthesizing encoding circuits for CSS codes.

Functions

depth_optimal_encoding_circuit_non_css(code, max_depth) → mqt.qecc.circuit_synthesis.circuits.CliffordIsometry | str

Synthesize a depth-optimal encoding circuit for a (possibly non-CSS) stabilizer code.

gate_optimal_encoding_circuit(code[, min_gates, ...]) → mqt.qecc.circuit_synthesis.circuits.CNOTCircuit | None

Synthesize an encoding circuit for the given CSS code using the minimal number of gates.

depth_optimal_encoding_circuit(code[, min_depth, ...]) → mqt.qecc.circuit_synthesis.circuits.CNOTCircuit | None

Synthesize an encoding circuit for the given CSS code using minimal depth.

gottesman_encoding_circuit(tableau) → mqt.qecc.circuit_synthesis.circuits.CliffordIsometry

Synthesize encoding circuit for a stabilizer code as described in chapter 6.4 of Gottesman's book.

synthesize_clifford(tableau[, use_cnots_if_css, config]) → mqt.qecc.circuit_synthesis.circuits.CliffordIsometry

Synthesize a stim circuit implementing a Clifford operation to minimize two-qubit gate count.

synthesize_encoding_circuit(code[, config, ...]) → mqt.qecc.circuit_synthesis.circuits.CliffordIsometry

Synthesize an encoding circuit for the given stabilizer code.

resynthesize_stim_circuit(circ[, use_cnots_if_css, config]) → stim.Circuit

Resynthesize a stim circuit implementing a Clifford operation to minimize two-qubit gate count.

encoder_from_stabilizers_and_logicals(stabilizers, ...) → mqt.qecc.circuit_synthesis.circuits.CliffordIsometry

Synthesize an encoding circuit for a stabilizer code given its stabilizers and logicals as tableaux.

optimize_tableau(tableau, stab_rows) → mqt.qecc.codes.core.pauli.PauliTableau

Optimize a stabilizer tableau by performing row operations to reduce the cost of the initial tableau for synthesis.

combine_stabilizer_and_logical_tableau(stabilizers, ...) → mqt.qecc.codes.core.pauli.PauliTableau

Combine a stabilizer tableau and a logical tableau, then complete with destabilizers.

cnot_encoding_circuit(checks, logicals[, config]) → mqt.qecc.circuit_synthesis.circuits.CNOTCircuit

Synthesize an encoding circuit for the given CSS code using a heuristic greedy search.

Module Contents

depth_optimal_encoding_circuit_non_css(code: mqt.qecc.codes.StabilizerCode, max_depth: int, min_depth: int = 1, max_two_qubit_gates: int | None = None) → CliffordIsometry | str[source]

Synthesize a depth-optimal encoding circuit for a (possibly non-CSS) stabilizer code.

Thin wrapper around synthesize_isometry_exact() (CLIFFORD_ISOMETRY / DEPTH over the extended gate set); see the Exact Circuit Synthesis guide for the full, general interface.

Parameters:
  • code – The stabilizer code to synthesize an encoding circuit for.

  • max_depth – Maximum circuit depth to search up to.

  • min_depth – Minimum circuit depth to start the search from. Raising this skips the (often expensive) proofs that no shallower circuit exists.

  • max_two_qubit_gates – Optional upper bound on the total number of two-qubit gates.

Returns:

The encoding circuit as a CliffordIsometry, or "UNSAT" if no circuit exists in [min_depth, max_depth] (or a diagnostic string if the search is inconclusive).

gate_optimal_encoding_circuit(code: mqt.qecc.codes.CSSCode, min_gates: int = 1, max_gates: int = 10, min_timeout: int = 1, max_timeout: int = 3600) → CNOTCircuit | None[source]

Synthesize an encoding circuit for the given CSS code using the minimal number of gates.

Parameters:
  • code – The CSS code to synthesize the encoding circuit for.

  • min_gates – The minimum number of gates to use in the circuit.

  • max_gates – The maximum number of gates to use in the circuit.

  • min_timeout – The minimum time to spend on the synthesis.

  • max_timeout – The maximum time to spend on the synthesis.

Returns:

The synthesized encoding circuit and the qubits that are used to encode the logical qubits.

depth_optimal_encoding_circuit(code: mqt.qecc.codes.CSSCode, min_depth: int = 1, max_depth: int = 10, min_timeout: int = 1, max_timeout: int = 3600) → CNOTCircuit | None[source]

Synthesize an encoding circuit for the given CSS code using minimal depth.

Parameters:
  • code – The CSS code to synthesize the encoding circuit for.

  • min_depth – The minimum number of gates to use in the circuit.

  • max_depth – The maximum number of gates to use in the circuit.

  • min_timeout – The minimum time to spend on the synthesis.

  • max_timeout – The maximum time to spend on the synthesis.

Returns:

The synthesized encoding circuit and the qubits that are used to encode the logical qubits.

gottesman_encoding_circuit(tableau: PauliTableau | Sequence[str]) → CliffordIsometry[source]

Synthesize encoding circuit for a stabilizer code as described in chapter 6.4 of Gottesman’s book.

Assumes all signs of the stabilizers are +1.

Parameters:

tableau – The stabilizer tableau of the code to synthesize the encoding circuit for.

Returns:

stim circuit implementing the encoding and a list of qubits that are used to encode the logical qubits.

synthesize_clifford(tableau: PauliTableau, use_cnots_if_css: bool = True, config: SynthesisConfig | None = None) → CliffordIsometry[source]

Synthesize a stim circuit implementing a Clifford operation to minimize two-qubit gate count.

Parameters:
  • tableau – The stabilizer tableau representing the Clifford operation to synthesize.

  • use_cnots_if_css – Whether to use CNOT-only synthesis if the tableau is CSS.

  • config – Configuration options for the synthesis process.

Returns:

A CliffordIsometry representing the synthesized Clifford operation that implements the same operation as the input tableau. The synthesis aims to minimize the two-qubit gate count. If the tableau is CSS and use_cnots_if_css is True, the circuit uses only CNOT gates; otherwise, a general Clifford synthesis is performed.

synthesize_encoding_circuit(code: mqt.qecc.codes.StabilizerCode, config: SynthesisConfig | None = None, use_cnots_if_css: bool = True, fixed_logical_qubits: dict[int, Literal['0', '+']] | None = None) → CliffordIsometry[source]

Synthesize an encoding circuit for the given stabilizer code.

Parameters:
  • code – The stabilizer code to synthesize the encoding circuit for.

  • config – Configuration options for the synthesis process.

  • use_cnots_if_css – Whether to use CNOT-only synthesis if the code is CSS.

  • fixed_logical_qubits – Dictionary mapping logical qubit indices to their desired states (‘0’ or ‘+’) in the circuit. Fixing f of the k logical inputs effectively synthesizes an encoder for a [[n, k - f, d]] code. Note that the returned isometry therefore encodes a different code than code, so helpers that assume the original code (e.g. logical_to_input_mapping) do not behave as expected on such circuits.

Returns:

A CliffordIsometry that implements the encoding circuit for the given stabilizer code.

resynthesize_stim_circuit(circ: stim.Circuit, use_cnots_if_css: bool = True, config: SynthesisConfig | None = None) → stim.Circuit[source]

Resynthesize a stim circuit implementing a Clifford operation to minimize two-qubit gate count.

Parameters:
  • circ – The stim.Circuit to resynthesize.

  • use_cnots_if_css – Whether to use CNOT-only synthesis if the circuit is CSS.

  • config – Configuration options for the synthesis process.

Returns:

A stim.Circuit that implements the same operation as the input circuit but with potentially fewer two

encoder_from_stabilizers_and_logicals(stabilizers: PauliTableau, logicals: PauliTableau, optimize_tableau_before_synthesis: bool = True, config: SynthesisConfig | None = None) → CliffordIsometry[source]

Synthesize an encoding circuit for a stabilizer code given its stabilizers and logicals as tableaux.

Parameters:
  • stabilizers – A tableau representing the stabilizers of the code.

  • logicals – A tableau representing the logical operators of the code.

  • optimize_tableau_before_synthesis – Whether to perform row operations on the combined tableau to optimize it for synthesis before synthesizing the circuit.

  • config – Configuration options for the synthesis process.

Returns:

A CliffordIsometry that implements the encoding circuit for the given stabilizer code.

optimize_tableau(tableau: PauliTableau, stab_rows: list[int]) → PauliTableau[source]

Optimize a stabilizer tableau by performing row operations to reduce the cost of the initial tableau for synthesis.

combine_stabilizer_and_logical_tableau(stabilizers: PauliTableau, logicals: PauliTableau) → PauliTableau[source]

Combine a stabilizer tableau and a logical tableau, then complete with destabilizers.

Parameters:
  • stabilizers – A tableau representing the stabilizers of the code (without destabilizers).

  • logicals – A tableau containing logical operators.

Returns:

A combined tableau with destabilizers added, suitable for circuit synthesis.

cnot_encoding_circuit(checks: CheckMatrix, logicals: CheckMatrix, config: SynthesisConfig | None = None) → CNOTCircuit[source]

Synthesize an encoding circuit for the given CSS code using a heuristic greedy search.

Parameters:
  • checks – The stabilizer check matrix of the CSS code.

  • logicals – The logical operator matrix of the CSS code.

  • config – The configuration for the CNOT synthesis process.

Returns:

The synthesized encoding circuit.