Pattern Generation

graphix.transpiler module

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]
Parameters

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

transpile(opt: bool = False) TranspileResult[source]

gate-to-MBQC transpile function.

Parameters

opt (bool) – Whether or not to use pre-optimized gateset with local-Clifford decoration.

Returns

result

Return type

TranspileResult object

standardize_and_transpile(opt: bool = True) TranspileResult[source]

gate-to-MBQC transpile function. Commutes all byproduct through gates, instead of through measurement commands, to generate standardized measurement pattern.

Parameters

opt (bool) – Whether or not to use pre-optimized gateset with local-Clifford decoration.

Returns

pattern

Return type

graphix.pattern.Pattern object

simulate_statevector(input_state: Optional[Statevec] = None) SimulateResult[source]

Run statevector simultion of the gate sequence, using graphix.Statevec

Parameters

input_state (graphix.Statevec) –

Returns

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

Return type

SimulateResult

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

CNOT gate

Parameters
  • control (int) – control qubit

  • target (int) – target qubit

h(qubit: int)[source]

Hadamard gate

Parameters

qubit (int) – target qubit

s(qubit: int)[source]

S gate

Parameters

qubit (int) – target qubit

x(qubit)[source]

Pauli X gate

Parameters

qubit (int) – target qubit

y(qubit: int)[source]

Pauli Y gate

Parameters

qubit (int) – target qubit

z(qubit: int)[source]

Pauli Z gate

Parameters

qubit (int) – target qubit

rx(qubit: int, angle: float)[source]

X rotation gate

Parameters
  • qubit (int) – target qubit

  • angle (float) – rotation angle in radian

ry(qubit: int, angle: float)[source]

Y rotation gate

Parameters
  • qubit (int) – target qubit

  • angle (float) – angle in radian

rz(qubit: int, angle: float)[source]

Z rotation gate

Parameters
  • qubit (int) – target qubit

  • angle (float) – rotation angle in radian

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

CCX (Toffoli) gate.

Prameters

control1int

first control qubit

control2int

second control qubit

targetint

target qubit

m(qubit: int, plane: Plane, angle: float)[source]

measure a quantum qubit

The measured qubit cannot be used afterwards.

Parameters
  • qubit (int) – target qubit

  • plane (graphix.pauli.Plane) –

  • angle (float) –

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

graphix.generator.generate_from_graph(graph, angles, inputs, outputs, meas_planes=None)[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 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 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.

See also

find_flow() find_gflow() graphix.pattern.Pattern

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 object