QEC graph-state builder

graphqomb.qec.qeccode provides the stabilizer-code representation and the Type I and Type II graph-state builders used by the QEC helper workflow.

Coordinate tuples are retained without restricting their dimensionality. The graph-state builder uses the first two qubit-coordinate components for the data plane and the first three explicitly supplied stabilizer-coordinate components for ancilla placement.

With data_as_io=True, the stabilizer-measurement unit has a separate, unmeasured output layer. Type I therefore has two measured data layers followed by an output layer. Type II uses three Y-measured layers for qubits with Y support, followed by an output layer; qubits without Y support retain the Type I two-measurement-layer layout. Ancilla support edges only touch measurement layers, and the output of one composed unit becomes the input of the next.

QEC Code object.

class graphqomb.qec.qeccode.YFoliation[source]

Bases: Enum

Y-foliation graph-state builder variant.

class graphqomb.qec.qeccode.StabilizerCode[source]

Bases: object

A stabilizer code.

__init__(stabilizer_matrix, *, stabilizer_coords=None, qubit_coords=None)[source]
property num_stabilizers: int

Number of stabilizers.

property num_qubits: int

Number of qubits.

class graphqomb.qec.qeccode.StabilizerGraphStateBuildResult[source]

Bases: NamedTuple

Result of building a graph state from a stabilizer code.

graph is the constructed graph state with data and ancilla nodes, edges, coordinates, and measurement bases. data_nodes maps each (physical_qubit, data_layer) pair to its graph node id. ancilla_nodes maps each stabilizer row index to its ancilla graph node id.

graph: GraphState

Alias for field number 0

data_nodes: dict[tuple[int, int], int]

Alias for field number 1

ancilla_nodes: dict[int, int]

Alias for field number 2

static __new__(_cls, graph, data_nodes, ancilla_nodes)

Create new instance of StabilizerGraphStateBuildResult(graph, data_nodes, ancilla_nodes)

graphqomb.qec.qeccode.build_graph_state(code, z_base=0, *, y_foliation=YFoliation.TYPE_I, data_as_io=False, qubit_indices=None)[source]

Build a graph-state unit from a stabilizer code.

Parameters:
  • code (StabilizerCode) – Stabilizer code to convert. The X support is connected to the upper data layer and the Z support is connected to the lower data layer.

  • z_base (int, optional) – Lower stabilizer-measurement data-layer index, by default 0. Type I uses two measurement layers; Type II uses three for Y support. When data_as_io is enabled, a separate output layer is appended.

  • y_foliation (YFoliation, optional) – Foliation variant. Type II uses a three-node Y-measured data chain only for qubits that have an Hx=Hz=1 support in at least one stabilizer row.

  • data_as_io (bool, optional) – Whether to register the first stabilizer-measurement data nodes as inputs and append separate unmeasured output nodes, by default False.

  • qubit_indices (collections.abc.Mapping[int, int] | None, optional) – Mapping from stabilizer-code qubit columns to graph qindices when data_as_io is enabled. If omitted, code qubit columns are used.

Returns:

Graph state and maps from stabilizer/data indices to graph nodes.

Return type:

StabilizerGraphStateBuildResult

Raises:
  • TypeError – If z_base is not an integer.

  • ValueError – If qubit_indices is invalid for the requested data I/O layout.