mqt.qecc.circuit_synthesis.cnot

CNOT-based candidate generation for CSS codes.

Classes

GreedyCNOTGenerator

Generates CNOT candidates using greedy heuristic for CSS codes.

Functions

find_multi_step_reduction(tableau) → collections.abc.Sequence[mqt.qecc.circuit_synthesis.operations.TableauOperation] | None

Find a sequence of CNOT operations that reduces the weight of the tableau.

greedy_matrix_elimination_candidates(matrix) → list[tuple[mqt.qecc.circuit_synthesis.operations.CNOT, int]]

Get all possible CNOT candidates for a CSS check matrix.

Module Contents

class GreedyCNOTGenerator(n_stabs: int, filters: Sequence[OperationFilter] | None = None)[source]

Bases: mqt.qecc.circuit_synthesis.elimination.CandidateGenerator

Generates CNOT candidates using greedy heuristic for CSS codes.

get_candidates(tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix) → Sequence[tuple[TableauOperation, int | tuple[int, ...]]][source]

Generate CNOT candidates sorted by heuristic score.

Parameters:

tableau – The current check matrix.

Returns:

List of (operation, score) tuples sorted by preference.

escape_local_minimum(tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix) → Sequence[TableauOperation] | None[source]

Generate candidates to escape local minimum.

Parameters:

tableau – The current check matrix.

Returns:

List of (operation, score) tuples for escaping local minimum.

update(op: TableauOperation, tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix) → None[source]

Update operation history and filters after applying an operation.

Parameters:
  • op – The operation that was applied.

  • tableau – The resulting tableau after applying the operation.

reset() → None[source]

Reset the operation history.

find_multi_step_reduction(tableau: CheckMatrix) → Sequence[TableauOperation] | None[source]

Find a sequence of CNOT operations that reduces the weight of the tableau.

This is a brute-force search over all sequences of CNOTs up to a certain length. It is not efficient but should only be needed in very rare cases when we are stuck in a local minimum with no single-step improvements.

greedy_matrix_elimination_candidates(matrix: CheckMatrix) → list[tuple[CNOT, int]][source]

Get all possible CNOT candidates for a CSS check matrix.

Parameters:

matrix (BinaryMatrix) – The CSS check matrix.

Returns:

A list of (CNOT, score) tuples that can be applied.

Return type:

list[tuple[CNOT, int]]