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.circuit.OpType

Enum for available operations compatible with tket Circuit s.

Members:

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)\)

TK1 : \((\alpha, \beta, \gamma) \mapsto \mathrm{Rz}(\alpha) \mathrm{Rx}(\beta) \mathrm{Rz}(\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

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

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.

QControlBox : An arbitrary n-controlled operation

Custom : \((\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.

ConditionalGate : 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)

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

CnX : n-controlled X 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

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.

property name