Pattern data structure¶
graphix.command module¶
This module defines standard data structure for pattern commands.
Data validator command classes.
- class graphix.command.N(node: int, state: ~graphix.states.State = <factory>)[source]¶
Preparation command.
- Parameters:
node (int) – Index of the qubit to prepare.
state (State, optional) – Initial state, defaults to
PLUS.
- class graphix.command.M(node: int, plane: ~graphix.fundamentals.Plane = Plane.XY, angle: ~graphix.parameter.Expression | float = 0.0, s_domain: set[int] = <factory>, t_domain: set[int] = <factory>)[source]¶
Measurement command.
- Parameters:
node (int) – Node index of the measured qubit.
plane (Plane, optional) – Measurement plane, defaults to
XY.angle (ExpressionOrFloat, optional) – Rotation angle divided by \(\pi\).
s_domain (set[int], optional) – Domain for the X byproduct operator.
t_domain (set[int], optional) – Domain for the Z byproduct operator.
- class graphix.command.E(nodes: tuple[int, int])[source]¶
Entanglement command between two qubits.
- Parameters:
nodes (tuple[int, int]) – Pair of nodes to entangle.
- class graphix.command.C(node: int, clifford: Clifford)[source]¶
Local Clifford gate command.
- Parameters:
node (int) – Node index on which to apply the gate.
clifford (Clifford) – Clifford operator to apply.
- class graphix.command.X(node: int, domain: set[int] = <factory>)[source]¶
X correction command.
- Parameters:
node (int) – Node to correct.
domain (set[int], optional) – Domain for the byproduct operator.
- class graphix.command.Z(node: int, domain: set[int] = <factory>)[source]¶
Z correction command.
- Parameters:
node (int) – Node to correct.
domain (set[int], optional) – Domain for the byproduct operator.
- class graphix.command.MeasureUpdate(new_plane: Plane, coeff: int, add_term: float)[source]¶
Describe how a measure is changed by signals and a vertex operator.
- Parameters:
new_plane (Plane) – Updated measurement plane after commuting gates.
coeff (int) – Coefficient by which the angle is multiplied.
add_term (float) – Additional term to add to the measurement angle.
graphix.fundamentals module¶
This module defines standard data structure for Pauli operators.
Fundamental components related to quantum mechanics.
- class graphix.fundamentals.Axis(value)[source]¶
Axis: X, Y or Z.
- property matrix: npt.NDArray[np.complex128]¶
Return the matrix representation.
- class graphix.fundamentals.ComplexUnit(value)[source]¶
Complex unit: 1, -1, j, -j.
Complex units can be multiplied with other complex units, with Python constants 1, -1, 1j, -1j, and can be negated.
- static from_properties(*, sign: Sign = Sign.PLUS, is_imag: bool = False) ComplexUnit[source]¶
Construct ComplexUnit from its properties.
- property is_imag: bool¶
Return True if j or -j.
- static try_from(value: ComplexUnit | SupportsComplex | SupportsFloat | SupportsIndex | complex) ComplexUnit | None[source]¶
Return the ComplexUnit instance if the value is compatible, None otherwise.
- class graphix.fundamentals.IXYZ(value)[source]¶
I, X, Y or Z.
- property matrix: npt.NDArray[np.complex128]¶
Return the matrix representation.
- class graphix.fundamentals.Plane(value)[source]¶
Plane: XY, YZ or XZ.
- polar(angle: float) tuple[float, float, float][source]¶
- polar(angle: Expression) tuple[Expression, Expression, Expression]
Return the Cartesian coordinates of the point of module 1 at the given angle, following the conventional orientation for cos and sin.
graphix.pauli module¶
This module defines standard data structure for Pauli operators.
Pauli gates ± {1,j} × {I, X, Y, Z}.
- class graphix.pauli.Pauli(symbol: IXYZ = IXYZ.I, unit: ComplexUnit = ComplexUnit.ONE)[source]¶
Pauli gate:
u * {I, X, Y, Z}where u is a complex unit.Pauli gates can be multiplied with other Pauli gates (with
@), with complex units and unit constants (with*), and can be negated.
graphix.instruction module¶
This module defines standard data structure for gate seqence (circuit model) used for graphix.transpiler.Circuit.
Instruction classes.
- class graphix.instruction.RX(target: int, angle: Expression | float, meas_index: int | None = None)[source]¶
X rotation circuit instruction.
- class graphix.instruction.RZ(target: int, angle: Expression | float, meas_index: int | None = None)[source]¶
Z rotation circuit instruction.
- class graphix.instruction.RY(target: int, angle: Expression | float, meas_index: int | None = None)[source]¶
Y rotation circuit instruction.
- class graphix.instruction.M(target: int, plane: Plane, angle: Expression | float)[source]¶
M circuit instruction.
graphix.parameter module¶
This module defines parameter objects and parameterized expressions. Parameterized expressions can appear in measurement angles in patterns and rotation angles in circuits, and they can be substituted with actual values.
The module provides generic interfaces for parameters and expressions,
as well as a simple Placeholder class that can be used in
affine expressions (AffineExpression). Affine expressions are
sufficient for transpiling and pattern optimizations (such as
standardization, minimization, signal shifting, and Pauli
preprocessing), but they do not support simulation.
Parameter objects that support symbolic simulation with sympy are available in a separate package: https://github.com/TeamGraphix/graphix-symbolic.
- class graphix.parameter.AffineExpression(a: float, x: Parameter, b: float)[source]¶
Affine expression.
An affine expression is of the form a*x+b where a and b are numbers and x is a parameter.
- class graphix.parameter.Placeholder(name: str)[source]¶
Placeholder for measurement angles.
These placeholder may appear in affine expressions. Placeholders and affine expressions may be used as angles in rotation gates of
Circuitclass or for the measurement angle of the measurement commands. Pattern optimizations such that standardization, signal shifting and Pauli preprocessing can be applied to patterns with placeholders.These placeholders and affine expressions do not support arbitrary computation and are not suitable for simulation. You may use
Circuit.subs()orPattern.subs()with an actual value before the computation.
graphix.states module¶
Quantum states and operators.