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
TranspileResultobject
- 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.Patternobject
- 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
- cnot(control: int, target: int)[source]
CNOT gate
- Parameters
control (int) – control qubit
target (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
- class graphix.transpiler.TranspileResult(pattern: Pattern, classical_outputs: tuple[int, ...])[source]
The result of a transpilation.
pattern :
graphix.pattern.Patternobject 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.Statevecobject 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