Skip to content

Gates

QuantSDK provides 50+ quantum gate classes covering single-qubit, two-qubit, three-qubit, and special operations.

Gate Hierarchy

All gates inherit from the Gate base class:

Gate (base)
├── Single-Qubit Gates
│   ├── HGate, XGate, YGate, ZGate, IGate
│   ├── SGate, SdgGate, TGate, TdgGate
│   ├── SXGate, SXdgGate
│   ├── RXGate, RYGate, RZGate, RGate
│   ├── PhaseGate, U1Gate, U2Gate, U3Gate
│   └── Reset
├── Two-Qubit Gates
│   ├── CXGate, CYGate, CZGate, CHGate
│   ├── CSGate, CSdgGate, CSXGate
│   ├── CRXGate, CRYGate, CRZGate, CPhaseGate
│   ├── CU1Gate, CU3Gate
│   ├── SwapGate, iSwapGate, DCXGate, ECRGate
│   └── RZZGate, RXXGate, RYYGate, RZXGate
├── Three-Qubit Gates
│   ├── ToffoliGate (CCX)
│   ├── CCZGate
│   └── FredkinGate (CSWAP)
└── Special Operations
    ├── Measure
    └── Barrier

Quick Reference Table

Gate Class Qubits Parameters Description
H HGate 1 Hadamard
X XGate 1 Pauli-X (NOT)
Y YGate 1 Pauli-Y
Z ZGate 1 Pauli-Z
I IGate 1 Identity
S SGate 1 \(\pi/2\) phase
Sdg SdgGate 1 S-dagger
T TGate 1 \(\pi/4\) phase
Tdg TdgGate 1 T-dagger
SX SXGate 1 \(\sqrt{X}\)
SXdg SXdgGate 1 \(\sqrt{X}\)-dagger
RX RXGate 1 \(\theta\) X-rotation
RY RYGate 1 \(\theta\) Y-rotation
RZ RZGate 1 \(\theta\) Z-rotation
R RGate 1 \(\theta, \phi\) General rotation
Phase PhaseGate 1 \(\lambda\) Phase gate
U1 U1Gate 1 \(\lambda\) U1 (\(= \text{Phase}\))
U2 U2Gate 1 \(\phi, \lambda\) U2
U3 U3Gate 1 \(\theta, \phi, \lambda\) General unitary
CX CXGate 2 CNOT
CY CYGate 2 Controlled-Y
CZ CZGate 2 Controlled-Z
CH CHGate 2 Controlled-H
CS CSGate 2 Controlled-S
CSdg CSdgGate 2 Controlled-Sdg
CSX CSXGate 2 Controlled-SX
CRX CRXGate 2 \(\theta\) Controlled-RX
CRY CRYGate 2 \(\theta\) Controlled-RY
CRZ CRZGate 2 \(\theta\) Controlled-RZ
CP CPhaseGate 2 \(\lambda\) Controlled-Phase
CU1 CU1Gate 2 \(\lambda\) Controlled-U1
CU3 CU3Gate 2 \(\theta, \phi, \lambda\) Controlled-U3
SWAP SwapGate 2 SWAP
iSWAP iSwapGate 2 iSWAP
DCX DCXGate 2 Double-CX
ECR ECRGate 2 Echoed CR
RZZ RZZGate 2 \(\theta\) ZZ-interaction
RXX RXXGate 2 \(\theta\) XX-interaction
RYY RYYGate 2 \(\theta\) YY-interaction
RZX RZXGate 2 \(\theta\) ZX-interaction
CCX ToffoliGate 3 Toffoli
CCZ CCZGate 3 Controlled-CZ
CSWAP FredkinGate 3 Fredkin

API Reference

Base Class

Gate dataclass

Gate(
    name: str,
    qubits: tuple[int, ...],
    params: tuple[float, ...] = tuple(),
)

Base class for all quantum gates.

ATTRIBUTE DESCRIPTION
name

Human-readable gate name (e.g., "H", "CNOT", "RZ").

TYPE: str

qubits

Tuple of qubit indices this gate acts on.

TYPE: tuple[int, ...]

params

Tuple of float parameters (e.g., rotation angles).

TYPE: tuple[float, ...]

num_qubits

Number of qubits this gate acts on.

TYPE: int

Attributes
num_qubits property
num_qubits: int

Number of qubits this gate acts on.

Functions
matrix
matrix() -> ndarray

Return the unitary matrix representation of this gate.

RETURNS DESCRIPTION
ndarray

A 2^n x 2^n complex numpy array representing the gate unitary.

RAISES DESCRIPTION
NotImplementedError

If matrix is not defined for this gate.

Single-Qubit Gates

HGate

HGate(qubit: int)

Bases: Gate

Hadamard gate.

XGate

XGate(qubit: int)

Bases: Gate

Pauli-X (NOT) gate.

YGate

YGate(qubit: int)

Bases: Gate

Pauli-Y gate.

ZGate

ZGate(qubit: int)

Bases: Gate

Pauli-Z gate.

IGate

IGate(qubit: int)

Bases: Gate

Identity gate.

SGate

SGate(qubit: int)

Bases: Gate

S (√Z) gate — phase gate with π/2 rotation.

SdgGate

SdgGate(qubit: int)

Bases: Gate

S-dagger (S†) gate -- adjoint of S.

TGate

TGate(qubit: int)

Bases: Gate

T (√S) gate — phase gate with π/4 rotation.

TdgGate

TdgGate(qubit: int)

Bases: Gate

T-dagger (T†) gate -- adjoint of T.

SXGate

SXGate(qubit: int)

Bases: Gate

Square root of X gate.

SXdgGate

SXdgGate(qubit: int)

Bases: Gate

Square root of X dagger gate.

RXGate

RXGate(qubit: int, theta: float)

Bases: Gate

Rotation around X-axis by angle theta.

RYGate

RYGate(qubit: int, theta: float)

Bases: Gate

Rotation around Y-axis by angle theta.

RZGate

RZGate(qubit: int, theta: float)

Bases: Gate

Rotation around Z-axis by angle theta.

RGate

RGate(qubit: int, theta: float, phi: float)

Bases: Gate

General rotation gate R(theta, phi) on the Bloch sphere.

PhaseGate

PhaseGate(qubit: int, lam: float)

Bases: Gate

Phase gate P(lam) = diag(1, e^{i*lam}).

U1Gate

U1Gate(qubit: int, lam: float)

Bases: Gate

U1 gate -- equivalent to Phase gate. U1(lam) = diag(1, e^{i*lam}).

U2Gate

U2Gate(qubit: int, phi: float, lam: float)

Bases: Gate

U2 gate -- U2(phi, lam) = U3(pi/2, phi, lam).

U3Gate

U3Gate(qubit: int, theta: float, phi: float, lam: float)

Bases: Gate

General single-qubit rotation U3(theta, phi, lambda).

Two-Qubit Gates

CXGate

CXGate(control: int, target: int)

Bases: Gate

Controlled-X (CNOT) gate.

CYGate

CYGate(control: int, target: int)

Bases: Gate

Controlled-Y gate.

CZGate

CZGate(control: int, target: int)

Bases: Gate

Controlled-Z gate.

CHGate

CHGate(control: int, target: int)

Bases: Gate

Controlled-Hadamard gate.

CSGate

CSGate(control: int, target: int)

Bases: Gate

Controlled-S gate.

CSdgGate

CSdgGate(control: int, target: int)

Bases: Gate

Controlled-S-dagger gate.

CSXGate

CSXGate(control: int, target: int)

Bases: Gate

Controlled-SX gate.

CRXGate

CRXGate(control: int, target: int, theta: float)

Bases: Gate

Controlled-RX gate.

CRYGate

CRYGate(control: int, target: int, theta: float)

Bases: Gate

Controlled-RY gate.

CRZGate

CRZGate(control: int, target: int, theta: float)

Bases: Gate

Controlled-RZ gate.

CPhaseGate

CPhaseGate(control: int, target: int, lam: float)

Bases: Gate

Controlled-Phase gate. CP(lam) = diag(1, 1, 1, e^{i*lam}).

CU1Gate

CU1Gate(control: int, target: int, lam: float)

Bases: Gate

Controlled-U1 gate -- equivalent to CPhase.

CU3Gate

CU3Gate(
    control: int,
    target: int,
    theta: float,
    phi: float,
    lam: float,
)

Bases: Gate

Controlled-U3 gate.

SwapGate

SwapGate(qubit1: int, qubit2: int)

Bases: Gate

SWAP gate — swaps two qubits.

iSwapGate

iSwapGate(qubit1: int, qubit2: int)

Bases: Gate

iSWAP gate.

DCXGate

DCXGate(qubit1: int, qubit2: int)

Bases: Gate

Double-CX gate -- CX(0,1) followed by CX(1,0).

ECRGate

ECRGate(qubit1: int, qubit2: int)

Bases: Gate

Echoed Cross-Resonance gate.

RZZGate

RZZGate(qubit1: int, qubit2: int, theta: float)

Bases: Gate

ZZ-rotation gate RZZ(theta) = exp(-i * theta/2 * Z⊗Z).

RXXGate

RXXGate(qubit1: int, qubit2: int, theta: float)

Bases: Gate

XX-rotation gate RXX(theta) = exp(-i * theta/2 * X⊗X).

RYYGate

RYYGate(qubit1: int, qubit2: int, theta: float)

Bases: Gate

YY-rotation gate RYY(theta) = exp(-i * theta/2 * Y⊗Y).

RZXGate

RZXGate(qubit1: int, qubit2: int, theta: float)

Bases: Gate

ZX-rotation gate RZX(theta) = exp(-i * theta/2 * Z⊗X).

Three-Qubit Gates

ToffoliGate

ToffoliGate(control1: int, control2: int, target: int)

Bases: Gate

Toffoli (CCX) gate — double-controlled NOT.

CCZGate

CCZGate(control1: int, control2: int, target: int)

Bases: Gate

Double-controlled Z (CCZ) gate.

FredkinGate

FredkinGate(control: int, target1: int, target2: int)

Bases: Gate

Fredkin (CSWAP) gate — controlled SWAP.

Special Operations

Measure

Measure(qubit: int, classical_bit: int | None = None)

Bases: Gate

Measurement in the computational basis.

Barrier

Barrier(qubits: Sequence[int])

Bases: Gate

Barrier — prevents gate optimization across this point.

Reset

Reset(qubit: int)

Bases: Gate

Reset gate -- resets a qubit to the |0> state.

Gate Map

The GATE_MAP dictionary maps string names to gate classes for use in deserialization and interop:

from quantsdk.gates import GATE_MAP

# 55 entries mapping string names -> Gate classes
print(list(GATE_MAP.keys()))
# ['h', 'x', 'y', 'z', 'i', 'id', 's', 'sdg', 't', 'tdg', ...]