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])
- enum pytket.circuit.OpType(value)¶
Enum for available operations compatible with tket
Circuit
s.- Member Type:
Valid values are as follows:
- Phase = OpType.Phase¶
Global phase: \((\alpha) \mapsto \left[ \begin{array}{c} e^{i\pi\alpha} \end{array} \right]\)
- Z = OpType.Z¶
Pauli Z: \(\left[ \begin{array}{cc} 1 & 0 \\ 0 & -1 \end{array} \right]\)
- X = OpType.X¶
Pauli X: \(\left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right]\)
- Y = OpType.Y¶
Pauli Y: \(\left[ \begin{array}{cc} 0 & -i \\ i & 0 \end{array} \right]\)
- S = OpType.S¶
\(\left[ \begin{array}{cc} 1 & 0 \\ 0 & i \end{array} \right] = \mathrm{U1}(\frac12)\)
- Sdg = OpType.Sdg¶
\(\mathrm{S}^{\dagger} = \left[ \begin{array}{cc} 1 & 0 \\ 0 & -i \end{array} \right] = \mathrm{U1}(-\frac12)\)
- T = OpType.T¶
\(\left[ \begin{array}{cc} 1 & 0 \\ 0 & e^{i\pi/4} \end{array} \right] = \mathrm{U1}(\frac14)\)
- Tdg = OpType.Tdg¶
\(\mathrm{T}^{\dagger} = \left[ \begin{array}{cc} 1 & 0 \\ 0 & e^{-i\pi/4} \end{array} \right] = \mathrm{U1}(-\frac14)\)
- V = OpType.V¶
\(\frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & -i \\ -i & 1 \end{array} \right] = \mathrm{Rx}(\frac12)\)
- Vdg = OpType.Vdg¶
\(\mathrm{V}^{\dagger} = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & i \\ i & 1 \end{array} \right] = \mathrm{Rx}(-\frac12)\)
- SX = OpType.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 = OpType.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 = OpType.H¶
Hadamard gate: \(\frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right]\)
- Rx = OpType.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 = OpType.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 = OpType.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 = OpType.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 = OpType.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 = OpType.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 = OpType.GPI¶
\((\phi) \mapsto \left[ \begin{array}{cc} 0 & e^{-i\pi\phi} \\ e^{i\pi\phi} & 0 \end{array} \right]\)
- GPI2 = OpType.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 = OpType.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 = OpType.TK1¶
\((\alpha, \beta, \gamma) \mapsto \mathrm{Rz}(\alpha) \mathrm{Rx}(\beta) \mathrm{Rz}(\gamma)\)
- TK2 = OpType.TK2¶
\((\alpha, \beta, \gamma) \mapsto \mathrm{XXPhase}(\alpha) \mathrm{YYPhase}(\beta) \mathrm{ZZPhase}(\gamma)\)
- CX = OpType.CX¶
Controlled \(\mathrm{X}\) gate
- CY = OpType.CY¶
Controlled \(\mathrm{Y}\) gate
- CZ = OpType.CZ¶
Controlled \(\mathrm{Z}\) gate
- CH = OpType.CH¶
Controlled \(\mathrm{H}\) gate
- CV = OpType.CV¶
Controlled \(\mathrm{V}\) gate
- CVdg = OpType.CVdg¶
Controlled \(\mathrm{V}^{\dagger}\) gate
- CSX = OpType.CSX¶
Controlled \(\mathrm{SX}\) gate
- CSXdg = OpType.CSXdg¶
Controlled \(\mathrm{SX}^{\dagger}\) gate
- CS = OpType.CS¶
Controlled \(\mathrm{S}\) gate
- CSdg = OpType.CSdg¶
Controlled \(\mathrm{S}^{\dagger}\) gate
- CRz = OpType.CRz¶
\((\alpha) \mapsto\) Controlled \(\mathrm{Rz}(\alpha)\) gate
- CRx = OpType.CRx¶
\((\alpha) \mapsto\) Controlled \(\mathrm{Rx}(\alpha)\) gate
- CRy = OpType.CRy¶
\((\alpha) \mapsto\) Controlled \(\mathrm{Ry}(\alpha)\) gate
- CU1 = OpType.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 = OpType.CU3¶
\((\theta, \phi, \lambda) \mapsto\) Controlled \(\mathrm{U3}(\theta, \phi, \lambda)\) gate. Similar rules apply.
- PhaseGadget = OpType.PhaseGadget¶
\(\alpha \mapsto e^{-\frac12 i \pi\alpha Z^{\otimes n}}\)
- CCX = OpType.CCX¶
Toffoli gate
- ECR = OpType.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 = OpType.SWAP¶
Swap gate
- CSWAP = OpType.CSWAP¶
Controlled swap gate
- noop = OpType.noop¶
Identity gate. These gates are not permanent and are automatically stripped by the compiler
- Barrier = OpType.Barrier¶
Meta-operation preventing compilation through it. Not automatically stripped by the compiler
- Label = OpType.Label¶
Label for control flow jumps. Does not appear within a circuit
- Branch = OpType.Branch¶
A control flow jump to a label dependent on the value of a given Bit. Does not appear within a circuit
- Goto = OpType.Goto¶
An unconditional control flow jump to a Label. Does not appear within a circuit.
- Stop = OpType.Stop¶
Halts execution immediately. Used to terminate a program. Does not appear within a circuit.
- BRIDGE = OpType.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 = OpType.Measure¶
Z-basis projective measurement, storing the measurement outcome in a specified bit
- Reset = OpType.Reset¶
Resets the qubit to \(\left|0\right>\)
- CircBox = OpType.CircBox¶
Represents an arbitrary subcircuit
- PhasePolyBox = OpType.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 = OpType.Unitary1qBox¶
Represents an arbitrary one-qubit unitary operation by its matrix
- Unitary2qBox = OpType.Unitary2qBox¶
Represents an arbitrary two-qubit unitary operation by its matrix
- Unitary3qBox = OpType.Unitary3qBox¶
Represents an arbitrary three-qubit unitary operation by its matrix
- ExpBox = OpType.ExpBox¶
A two-qubit operation corresponding to a unitary matrix defined as the exponential \(e^{itA}\) of an arbitrary 4x4 hermitian matrix \(A\).
- PauliExpBox = OpType.PauliExpBox¶
An operation defined as the exponential \(e^{-\frac{i\pi\alpha}{2} P}\) of a tensor \(P\) of Pauli operations.
- PauliExpPairBox = OpType.PauliExpPairBox¶
A pair of (not necessarily commuting) Pauli exponentials \(e^{-\frac{i\pi\alpha}{2} P}\) performed in sequence.
- PauliExpCommutingSetBox = OpType.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 = OpType.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 = OpType.QControlBox¶
An arbitrary n-controlled operation
- ToffoliBox = OpType.ToffoliBox¶
A permutation of classical basis states
- ConjugationBox = OpType.ConjugationBox¶
An operation composed of ‘action’, ‘compute’ and ‘uncompute’ circuits
- DummyBox = OpType.DummyBox¶
A placeholder operation that holds resource data
- CustomGate = OpType.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 theCustomGateDef
.
- Conditional = OpType.Conditional¶
An operation to be applied conditionally on the value of some classical register
- ISWAP = OpType.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 = OpType.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 = OpType.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 = OpType.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 = OpType.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 = OpType.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 = OpType.PhasedX¶
\((\alpha,\beta) \mapsto \mathrm{Rz}(\beta)\mathrm{Rx}(\alpha)\mathrm{Rz}(-\beta)\) (matrix-multiplication order)
- NPhasedX = OpType.NPhasedX¶
\((\alpha, \beta) \mapsto \mathrm{PhasedX}(\alpha, \beta)^{\otimes n}\) (n-qubit gate composed of identical PhasedX in parallel.
- CnRx = OpType.CnRx¶
\((\alpha)\) := n-controlled \(\mathrm{Rx}(\alpha)\) gate.
- CnRy = OpType.CnRy¶
\((\alpha)\) := n-controlled \(\mathrm{Ry}(\alpha)\) gate.
- CnRz = OpType.CnRz¶
\((\alpha)\) := n-controlled \(\mathrm{Rz}(\alpha)\) gate.
- CnX = OpType.CnX¶
n-controlled X gate.
- CnY = OpType.CnY¶
n-controlled Y gate.
- CnZ = OpType.CnZ¶
n-controlled Z gate.
- ZZMax = OpType.ZZMax¶
\(e^{-\frac{i\pi}{4}(\mathrm{Z} \otimes \mathrm{Z})}\), a maximally entangling ZZPhase
- ESWAP = OpType.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 = OpType.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 = OpType.Sycamore¶
\(\mathrm{FSim}(\frac12, \frac16)\)
- ISWAPMax = OpType.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 = OpType.ClassicalTransform¶
A general classical operation where all inputs are also outputs
- WASM = OpType.WASM¶
Op containing a classical wasm function call
- SetBits = OpType.SetBits¶
An operation to set some bits to specified values
- CopyBits = OpType.CopyBits¶
An operation to copy some bit values
- RangePredicate = OpType.RangePredicate¶
A classical predicate defined by a range of values in binary encoding
- ExplicitPredicate = OpType.ExplicitPredicate¶
A classical predicate defined by a truth table
- ExplicitModifier = OpType.ExplicitModifier¶
An operation defined by a truth table that modifies one bit
- MultiBit = OpType.MultiBit¶
A classical operation applied to multiple bits simultaneously
- MultiplexorBox = OpType.MultiplexorBox¶
A multiplexor (i.e. uniformly controlled operations)
- MultiplexedRotationBox = OpType.MultiplexedRotationBox¶
A multiplexed rotation gate (i.e. uniformly controlled single-axis rotations)
- MultiplexedU2Box = OpType.MultiplexedU2Box¶
A multiplexed U2 gate (i.e. uniformly controlled U2 gate)
- MultiplexedTensoredU2Box = OpType.MultiplexedTensoredU2Box¶
A multiplexed tensored-U2 gate
- StatePreparationBox = OpType.StatePreparationBox¶
A box for preparing quantum states using multiplexed-Ry and multiplexed-Rz gates
- DiagonalBox = OpType.DiagonalBox¶
A box for synthesising a diagonal unitary matrix into a sequence of multiplexed-Rz gates
- ClExpr = OpType.ClExpr¶
A classical expression
- OpType.from_name(arg: str, /) pytket.circuit.OpType ¶
Construct from name