pytket.circuit.OpType

Enum for available operations compatible with the tket Circuit class.

Warning

All parametrised OpTypes which take angles (e.g. Rz, CPhase, FSim) expect parameters in multiples of pi (half-turns). This may differ from other quantum programming tools you have used, which have specified angles in radians, or perhaps even degrees. Therefore, for instance circuit.add_gate(OpType.Rx, 1, [0]) is equivalent in terms of the unitary to circuit.add_gate(OpType.X, [0])

class pytket._tket.circuit.OpType

Enum for available operations compatible with tket Circuit s.

Members:

Phase : Global phase: \((\alpha) \mapsto \left[ \begin{array}{c} e^{i\pi\alpha} \end{array} \right]\)

Z : Pauli Z: \(\left[ \begin{array}{cc} 1 & 0 \\ 0 & -1 \end{array} \right]\)

X : Pauli X: \(\left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right]\)

Y : Pauli Y: \(\left[ \begin{array}{cc} 0 & -i \\ i & 0 \end{array} \right]\)

S : \(\left[ \begin{array}{cc} 1 & 0 \\ 0 & i \end{array} \right] = \mathrm{U1}(\frac12)\)

Sdg : \(\mathrm{S}^{\dagger} = \left[ \begin{array}{cc} 1 & 0 \\ 0 & -i \end{array} \right] = \mathrm{U1}(-\frac12)\)

T : \(\left[ \begin{array}{cc} 1 & 0 \\ 0 & e^{i\pi/4} \end{array} \right] = \mathrm{U1}(\frac14)\)

Tdg : \(\mathrm{T}^{\dagger} = \left[ \begin{array}{cc} 1 & 0 \\ 0 & e^{-i\pi/4} \end{array} \right] = \mathrm{U1}(-\frac14)\)

V : \(\frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & -i \\ -i & 1 \end{array} \right] = \mathrm{Rx}(\frac12)\)

Vdg : \(\mathrm{V}^{\dagger} = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & i \\ i & 1 \end{array} \right] = \mathrm{Rx}(-\frac12)\)

SX : \(\frac{1}{2} \left[ \begin{array}{cc} 1 + i & 1 - i \\ 1 - i & 1 + i \end{array} \right] = e^{\frac{i\pi}{4}}\mathrm{Rx}(\frac12)\)

SXdg : \(\mathrm{SX}^{\dagger} = \frac{1}{2} \left[ \begin{array}{cc} 1 - i & 1 + i \\ 1 + i & 1 - i \end{array} \right] = e^{\frac{-i\pi}{4}}\mathrm{Rx}(-\frac12)\)

H : Hadamard gate: \(\frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right]\)

Rx : \((\alpha) \mapsto e^{-\frac12 i \pi \alpha \mathrm{X}} = \left[ \begin{array}{cc} \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} \\ -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} \end{array} \right]\)

Ry : \((\alpha) \mapsto e^{-\frac12 i \pi \alpha \mathrm{Y}} = \left[ \begin{array}{cc} \cos\frac{\pi\alpha}{2} & -\sin\frac{\pi\alpha}{2} \\ \sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} \end{array} \right]\)

Rz : \((\alpha) \mapsto e^{-\frac12 i \pi \alpha \mathrm{Z}} = \left[ \begin{array}{cc} e^{-\frac12 i \pi\alpha} & 0 \\ 0 & e^{\frac12 i \pi\alpha} \end{array} \right]\)

U1 : \((\lambda) \mapsto \mathrm{U3}(0, 0, \lambda) = e^{\frac12 i\pi\lambda} \mathrm{Rz}(\lambda)\). U-gates are used by IBM. See https://qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations.html for more information on U-gates.

U2 : \((\phi, \lambda) \mapsto \mathrm{U3}(\frac12, \phi, \lambda) = e^{\frac12 i\pi(\lambda+\phi)} \mathrm{Rz}(\phi) \mathrm{Ry}(\frac12) \mathrm{Rz}(\lambda)\), defined by matrix multiplication

U3 : \((\theta, \phi, \lambda) \mapsto \left[ \begin{array}{cc} \cos\frac{\pi\theta}{2} & -e^{i\pi\lambda} \sin\frac{\pi\theta}{2} \\ e^{i\pi\phi} \sin\frac{\pi\theta}{2} & e^{i\pi(\lambda+\phi)} \cos\frac{\pi\theta}{2} \end{array} \right] = e^{\frac12 i\pi(\lambda+\phi)} \mathrm{Rz}(\phi) \mathrm{Ry}(\theta) \mathrm{Rz}(\lambda)\)

GPI : \((\phi) \mapsto \left[ \begin{array}{cc} 0 & e^{-i\pi\phi} \\ e^{i\pi\phi} & 0 \end{array} \right]\)

GPI2 : \((\phi) \mapsto \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & -ie^{-i\pi\phi} \\ -ie^{i\pi\phi} & 1 \end{array} \right]\)

AAMS : \((\theta, \phi_0, \phi_1) \mapsto \left[ \begin{array}{cccc} \cos\frac{\pi\theta}{2} & 0 & 0 & -ie^{-i\pi(\phi_0+\phi_1)}\sin\frac{\pi\theta}{2} \\ 0 & \cos\frac{\pi\theta}{2} & -ie^{i\pi(\phi_1-\phi_0)}\sin\frac{\pi\theta}{2} & 0 \\ 0 & -ie^{i\pi(\phi_0-\phi_1)}\sin\frac{\pi\theta}{2} & \cos\frac{\pi\theta}{2} & 0 \\ -ie^{i\pi(\phi_0+\phi_1)}\sin\frac{\pi\theta}{2} & 0 & 0 & \cos\frac{\pi\theta}{2} \end{array} \right]\)

TK1 : \((\alpha, \beta, \gamma) \mapsto \mathrm{Rz}(\alpha) \mathrm{Rx}(\beta) \mathrm{Rz}(\gamma)\)

TK2 : \((\alpha, \beta, \gamma) \mapsto \mathrm{XXPhase}(\alpha) \mathrm{YYPhase}(\beta) \mathrm{ZZPhase}(\gamma)\)

CX : Controlled \(\mathrm{X}\) gate

CY : Controlled \(\mathrm{Y}\) gate

CZ : Controlled \(\mathrm{Z}\) gate

CH : Controlled \(\mathrm{H}\) gate

CV : Controlled \(\mathrm{V}\) gate

CVdg : Controlled \(\mathrm{V}^{\dagger}\) gate

CSX : Controlled \(\mathrm{SX}\) gate

CSXdg : Controlled \(\mathrm{SX}^{\dagger}\) gate

CS : Controlled \(\mathrm{S}\) gate

CSdg : Controlled \(\mathrm{S}^{\dagger}\) gate

CRz : \((\alpha) \mapsto\) Controlled \(\mathrm{Rz}(\alpha)\) gate

CRx : \((\alpha) \mapsto\) Controlled \(\mathrm{Rx}(\alpha)\) gate

CRy : \((\alpha) \mapsto\) Controlled \(\mathrm{Ry}(\alpha)\) gate

CU1 : \((\lambda) \mapsto\) Controlled \(\mathrm{U1}(\lambda)\) gate. Note that this is not equivalent to a \(\mathrm{CRz}(\lambda)\) up to global phase, differing by an extra \(\mathrm{Rz}(\frac{\lambda}{2})\) on the control qubit.

CU3 : \((\theta, \phi, \lambda) \mapsto\) Controlled \(\mathrm{U3}(\theta, \phi, \lambda)\) gate. Similar rules apply.

CCX : Toffoli gate

ECR : \(\frac{1}{\sqrt 2} \left[ \begin{array}{cccc} 0 & 0 & 1 & i \\0 & 0 & i & 1 \\1 & -i & 0 & 0 \\-i & 1 & 0 & 0 \end{array} \right]\)

SWAP : Swap gate

CSWAP : Controlled swap gate

noop : Identity gate. These gates are not permanent and are automatically stripped by the compiler

Barrier : Meta-operation preventing compilation through it. Not automatically stripped by the compiler

Label : Label for control flow jumps. Does not appear within a circuit

Branch : A control flow jump to a label dependent on the value of a given Bit. Does not appear within a circuit

Goto : An unconditional control flow jump to a Label. Does not appear within a circuit.

Stop : Halts execution immediately. Used to terminate a program. Does not appear within a circuit.

BRIDGE : A CX Bridge over 3 qubits. Used to apply a logical CX between the first and third qubits when they are not adjacent on the device, but both neighbour the second qubit. Acts as the identity on the second qubit

Measure : Z-basis projective measurement, storing the measurement outcome in a specified bit

Reset : Resets the qubit to \(\left|0\right>\)

CircBox : Represents an arbitrary subcircuit

PhasePolyBox : An operation representing arbitrary circuits made up of CX and Rz gates, represented as a phase polynomial together with a boolean matrix representing an additional linear transformation.

Unitary1qBox : Represents an arbitrary one-qubit unitary operation by its matrix

Unitary2qBox : Represents an arbitrary two-qubit unitary operation by its matrix

Unitary3qBox : Represents an arbitrary three-qubit unitary operation by its matrix

ExpBox : A two-qubit operation corresponding to a unitary matrix defined as the exponential \(e^{itA}\) of an arbitrary 4x4 hermitian matrix \(A\).

PauliExpBox : An operation defined as the exponential \(e^{-\frac{i\pi\alpha}{2} P}\) of a tensor \(P\) of Pauli operations.

PauliExpPairBox : A pair of (not necessarily commuting) Pauli exponentials \(e^{-\frac{i\pi\alpha}{2} P}\) performed in sequence.

PauliExpCommutingSetBox : An operation defined as a setof commuting exponentials of the form \(e^{-\frac{i\pi\alpha}{2} P}\) of a tensor \(P\) of Pauli operations.

TermSequenceBox : An unordered collection of Pauli exponentials that can be synthesised in any order, causing a change in the unitary operation. Synthesis order depends on the synthesis strategy chosen only.

QControlBox : An arbitrary n-controlled operation

ToffoliBox : A permutation of classical basis states

ConjugationBox : An operation composed of ‘action’, ‘compute’ and ‘uncompute’ circuits

DummyBox : A placeholder operation that holds resource data

CustomGate : \((\alpha, \beta, \ldots) \mapsto\) A user-defined operation, based on a Circuit \(C\) with parameters \(\alpha, \beta, \ldots\) substituted in place of bound symbolic variables in \(C\), as defined by the CustomGateDef.

Conditional : An operation to be applied conditionally on the value of some classical register

ISWAP : \((\alpha) \mapsto e^{\frac14 i \pi\alpha (\mathrm{X} \otimes \mathrm{X} + \mathrm{Y} \otimes \mathrm{Y})} = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos\frac{\pi\alpha}{2} & i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ 0 & 0 & 0 & 1 \end{array} \right]\)

PhasedISWAP : \((p, t) \mapsto \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos\frac{\pi t}{2} & i\sin\frac{\pi t}{2}e^{2i\pi p} & 0 \\ 0 & i\sin\frac{\pi t}{2}e^{-2i\pi p} & \cos\frac{\pi t}{2} & 0 \\ 0 & 0 & 0 & 1 \end{array} \right]\) (equivalent to: Rz(p)[0]; Rz(-p)[1]; ISWAP(t); Rz(-p)[0]; Rz(p)[1])

XXPhase : \((\alpha) \mapsto e^{-\frac12 i \pi\alpha (\mathrm{X} \otimes \mathrm{X})} = \left[ \begin{array}{cccc} \cos\frac{\pi\alpha}{2} & 0 & 0 & -i\sin\frac{\pi\alpha}{2} \\ 0 & \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ -i\sin\frac{\pi\alpha}{2} & 0 & 0 & \cos\frac{\pi\alpha}{2} \end{array} \right]\)

YYPhase : \((\alpha) \mapsto e^{-\frac12 i \pi\alpha (\mathrm{Y} \otimes \mathrm{Y})} = \left[ \begin{array}{cccc} \cos\frac{\pi\alpha}{2} & 0 & 0 & i\sin\frac{\pi\alpha}{2} \\ 0 & \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ i\sin\frac{\pi\alpha}{2} & 0 & 0 & \cos\frac{\pi\alpha}{2} \end{array} \right]\)

ZZPhase : \((\alpha) \mapsto e^{-\frac12 i \pi\alpha (\mathrm{Z} \otimes \mathrm{Z})} = \left[ \begin{array}{cccc} e^{-\frac12 i \pi\alpha} & 0 & 0 & 0 \\ 0 & e^{\frac12 i \pi\alpha} & 0 & 0 \\ 0 & 0 & e^{\frac12 i \pi\alpha} & 0 \\ 0 & 0 & 0 & e^{-\frac12 i \pi\alpha} \end{array} \right]\)

XXPhase3 : A 3-qubit gate XXPhase3(α) consists of pairwise 2-qubit XXPhase(α) interactions. Equivalent to XXPhase(α)[0, 1] XXPhase(α)[1, 2] XXPhase(α)[0, 2].

PhasedX : \((\alpha,\beta) \mapsto \mathrm{Rz}(\beta)\mathrm{Rx}(\alpha)\mathrm{Rz}(-\beta)\) (matrix-multiplication order)

NPhasedX : \((\alpha, \beta) \mapsto \mathrm{PhasedX}(\alpha, \beta)^{\otimes n}\) (n-qubit gate composed of identical PhasedX in parallel.

CnRx : \((\alpha)\) := n-controlled \(\mathrm{Rx}(\alpha)\) gate.

CnRy : \((\alpha)\) := n-controlled \(\mathrm{Ry}(\alpha)\) gate.

CnRz : \((\alpha)\) := n-controlled \(\mathrm{Rz}(\alpha)\) gate.

CnX : n-controlled X gate.

CnY : n-controlled Y gate.

CnZ : n-controlled Z gate.

ZZMax : \(e^{-\frac{i\pi}{4}(\mathrm{Z} \otimes \mathrm{Z})}\), a maximally entangling ZZPhase

ESWAP : \(\alpha \mapsto e^{-\frac12 i\pi\alpha \cdot \mathrm{SWAP}} = \left[ \begin{array}{cccc} e^{-\frac12 i \pi\alpha} & 0 & 0 & 0 \\ 0 & \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ 0 & 0 & 0 & e^{-\frac12 i \pi\alpha} \end{array} \right]\)

FSim : \((\alpha, \beta) \mapsto \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos \pi\alpha & -i\sin \pi\alpha & 0 \\ 0 & -i\sin \pi\alpha & \cos \pi\alpha & 0 \\ 0 & 0 & 0 & e^{-i\pi\beta} \end{array} \right]\)

Sycamore : \(\mathrm{FSim}(\frac12, \frac16)\)

ISWAPMax : \(\mathrm{ISWAP}(1) = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{array} \right]\)

ClassicalTransform : A general classical operation where all inputs are also outputs

WASM : Op containing a classical wasm function call

SetBits : An operation to set some bits to specified values

CopyBits : An operation to copy some bit values

RangePredicate : A classical predicate defined by a range of values in binary encoding

ExplicitPredicate : A classical predicate defined by a truth table

ExplicitModifier : An operation defined by a truth table that modifies one bit

MultiBit : A classical operation applied to multiple bits simultaneously

ClassicalExpBox : A box for holding compound classical operations on Bits.

DEPRECATED: Please use WiredClExpr instead. This class will be removed after pytket 1.40.

MultiplexorBox : A multiplexor (i.e. uniformly controlled operations)

MultiplexedRotationBox : A multiplexed rotation gate (i.e. uniformly controlled single-axis rotations)

MultiplexedU2Box : A multiplexed U2 gate (i.e. uniformly controlled U2 gate)

MultiplexedTensoredU2Box : A multiplexed tensored-U2 gate

StatePreparationBox : A box for preparing quantum states using multiplexed-Ry and multiplexed-Rz gates

DiagonalBox : A box for synthesising a diagonal unitary matrix into a sequence of multiplexed-Rz gates

ClExpr : A classical expression

static from_name(arg0: str) pytket._tket.circuit.OpType

Construct from name

property name