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, instr: Iterable[Instruction] | None = None)[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, instr: Iterable[Instruction] | None = None) None[source]¶
Construct a circuit.
- Parameters:
width (int) – number of logical qubits for the gate network
instr (list[instruction.Instruction] | None) – Optional. List of initial instructions.
- transpile() TranspileResult[source]¶
Transpile the circuit to a pattern.
- Returns:
result
- Return type:
TranspileResultobject
- simulate_statevector(input_state: Data | None = None, branch_selector: BranchSelector | None = None, rng: Generator | None = None) SimulateResult[source]¶
Run statevector simulation of the gate sequence.
- Parameters:
input_state (Data)
branch_selector (
graphix.branch_selector.BranchSelector) – branch selector for measures (default:RandomBranchSelector).rng (Generator, optional) – Random-number generator for measurements. This generator is used only in case of random branch selection (see
RandomBranchSelector).
- Returns:
result – output state of the statevector simulation and results of classical measures.
- Return type:
- cnot(control: int, target: int) None[source]¶
Apply a CNOT gate.
- Parameters:
control (int) – control qubit
target (int) – target qubit
- rx(qubit: int, angle: Expression | float) None[source]¶
Apply an X rotation gate.
- Parameters:
qubit (int) – target qubit
angle (Angle) – rotation angle in radian
- ry(qubit: int, angle: Expression | float) None[source]¶
Apply a Y rotation gate.
- Parameters:
qubit (int) – target qubit
angle (Angle) – angle in radian
- rz(qubit: int, angle: Expression | float) None[source]¶
Apply a Z rotation gate.
- Parameters:
qubit (int) – target qubit
angle (Angle) – rotation angle in radian
- ccx(control1: int, control2: int, target: int) None[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 | float) None[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.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