Pattern Generation

graphix.transpiler module

Gate-to-MBQC transpiler.

accepts desired gate operations and transpile into MBQC measurement patterns.

class graphix.transpiler.Circuit(width: int)[source]

Gate-to-MBQC transpiler.

Holds gate operations and translates into MBQC measurement patterns.

width

Number of logical qubits (for gate network)

Type:

int

instruction

List containing the gate sequence applied.

Type:

list

__init__(width: int)[source]

Construct a circuit.

Parameters:

width (int) – number of logical qubits for the gate network

transpile() TranspileResult[source]

Transpile the circuit to a pattern.

Returns:

result

Return type:

TranspileResult object

simulate_statevector(input_state: State | Statevec | Iterable[State] | Iterable[Expression | SupportsComplex] | None = None) SimulateResult[source]

Run statevector simulation of the gate sequence.

Parameters:

input_state (graphix.sim.statevec.Statevec)

Returns:

result – output state of the statevector simulation and results of classical measures.

Return type:

SimulateResult

cnot(control: int, target: int)[source]

Apply a CNOT gate.

Parameters:
  • control (int) – control qubit

  • target (int) – target qubit

h(qubit: int)[source]

Apply a Hadamard gate.

Parameters:

qubit (int) – target qubit

s(qubit: int)[source]

Apply an S gate.

Parameters:

qubit (int) – target qubit

x(qubit)[source]

Apply a Pauli X gate.

Parameters:

qubit (int) – target qubit

y(qubit: int)[source]

Apply a Pauli Y gate.

Parameters:

qubit (int) – target qubit

z(qubit: int)[source]

Apply a Pauli Z gate.

Parameters:

qubit (int) – target qubit

rx(qubit: int, angle: Expression | SupportsFloat)[source]

Apply an X rotation gate.

Parameters:
  • qubit (int) – target qubit

  • angle (Angle) – rotation angle in radian

ry(qubit: int, angle: Expression | SupportsFloat)[source]

Apply a Y rotation gate.

Parameters:
  • qubit (int) – target qubit

  • angle (Angle) – angle in radian

rz(qubit: int, angle: Expression | SupportsFloat)[source]

Apply a Z rotation gate.

Parameters:
  • qubit (int) – target qubit

  • angle (Angle) – rotation angle in radian

ccx(control1: int, control2: int, target: int)[source]

Apply a CCX (Toffoli) gate.

Prameters

control1int

first control qubit

control2int

second control qubit

targetint

target qubit

m(qubit: int, plane: Plane, angle: Expression | SupportsFloat)[source]

Measure a quantum qubit.

The measured qubit cannot be used afterwards.

Parameters:
  • qubit (int) – target qubit

  • plane (Plane)

  • angle (Angle)

class graphix.transpiler.TranspileResult(pattern: Pattern, classical_outputs: tuple[int, ...])[source]

The result of a transpilation.

pattern : graphix.pattern.Pattern object classical_outputs : tuple[int,…], index of nodes measured with M gates

class graphix.transpiler.SimulateResult(statevec: Statevec, classical_measures: tuple[int, ...])[source]

The result of a simulation.

statevec : graphix.sim.statevec.Statevec object classical_measures : tuple[int,…], classical measures

graphix.generator module

MBQC pattern generator.

graphix.generator.generate_from_graph(graph: nx.Graph[int], angles: Mapping[int, float] | Sequence[float] | npt.NDArray[np.float64], inputs: Iterable[int], outputs: Iterable[int], meas_planes: Mapping[int, Plane] | None = None) Pattern[source]

Generate the measurement pattern from open graph and measurement angles.

This function takes an open graph G = (nodes, edges, input, outputs), specified by networks.Graph and two lists specifying input and output nodes. Currently we support XY-plane measurements.

Searches for the flow in the open graph using graphix.gflow.find_flow() and if found, construct the measurement pattern according to the theorem 1 of [NJP 9, 250 (2007)].

Then, if no flow was found, searches for gflow using graphix.gflow.find_gflow(), from which measurement pattern can be constructed from theorem 2 of [NJP 9, 250 (2007)].

The constructed measurement pattern deterministically realize the unitary embedding

\[U = \left( \prod_i \langle +_{\alpha_i} |_i \right) E_G N_{I^C},\]

where the measurements (bras) with always \(\langle+|\) bases determined by the measurement angles \(\alpha_i\) are applied to the measuring nodes, i.e. the randomness of the measurement is eliminated by the added byproduct commands.

Parameters:
  • graph (networkx.Graph) – graph on which MBQC should be performed

  • angles (dict) – measurement angles for each nodes on the graph (unit of pi), except output nodes

  • inputs (list) – list of node indices for input nodes

  • outputs (list) – list of node indices for output nodes

  • meas_planes (dict) – optional: measurement planes for each nodes on the graph, except output nodes

Returns:

pattern – constructed pattern.

Return type:

graphix.pattern.Pattern