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
- __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, *, stacklevel: int = 1) 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: ParameterizedAngle) None[source]¶
Apply an X rotation gate.
- Parameters:
qubit (int) – target qubit
angle (ParameterizedAngle) – rotation angle in units of π
- ry(qubit: int, angle: ParameterizedAngle) None[source]¶
Apply a Y rotation gate.
- Parameters:
qubit (int) – target qubit
angle (ParameterizedAngle) – angle in units of π
- rz(qubit: int, angle: ParameterizedAngle) None[source]¶
Apply a Z rotation gate.
- Parameters:
qubit (int) – target qubit
angle (ParameterizedAngle) – rotation angle in units of π
- 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