Gates
This submodule provides the necessary components to define and manipulate quantum gates for use in digital quantum circuits.
Simple Gates
Use these constructors to apply standard single- and two-qubit operations:
X(qubit: int)Pauli X (bit-flip) on the specified qubit.Y(qubit: int)Pauli Y (bit-and-phase-flip).Z(qubit: int)Pauli Z (phase-flip).H(qubit: int)Hadamard: creates superposition.I(qubit: int)Identity gate: leaves the qubit unchanged.S(qubit: int)Phase gate (π/2 rotation about Z).T(qubit: int)T gate (π/4 rotation about Z).RX(qubit: int, theta: float | Parameter | Term)Rotation by angle theta around X.RY(qubit: int, theta: float | Parameter | Term)Rotation by angle theta around Y.RZ(qubit: int, phi: float | Parameter | Term)Rotation by angle phi around Z.U1(qubit: int, *, phi: float | Parameter | Term)Phase shift equivalent to RZ plus global phase.U2(qubit: int, *, phi: float | Parameter | Term, gamma: float | Parameter | Term)π/2 Y-rotation sandwiched by Z-rotations.U3(qubit: int, *, theta: float | Parameter | Term, phi: float | Parameter | Term, gamma: float | Parameter | Term)General single-qubit unitary: RZ-RY-RZ decomposition.SWAP(a: int, b: int)Exchanges the states of qubitsaandb.CNOT(control: int, target: int)Controlled-X: flips target if control is 1.CZ(control: int, target: int)Controlled-Z: applies Z on target if control is 1.M(*qubits: int)Measures the listed qubits in the computational basis.
Controlled Gates
Any basic gate can be turned into a controlled gate using the Controlled class:
from qilisdk.digital.gates import Controlled, Y
controlled_y = Controlled(0, basic_gate=Y(1))
multiple_controlled_y = Controlled(0, 1, basic_gate=Y(2))
Or alternatively, you can use the .controlled() method on any gate instance:
from qilisdk.digital.gates import Y
controlled_y = Y(1).controlled(0)
multiple_controlled_y = Y(2).controlled(0, 1)
Adjoint Gates
You can create the Hermitian conjugate (dagger) of a gate either using the Adjoint class
or using the .adjoint() method on any gate instance:
from qilisdk.digital.gates import Adjoint, Y
adjoint_y = Adjoint(basic_gate=Y(1))
adjoint_y = Y(1).adjoint()
Exponential Gates
To apply a gate as an exponential operator, use either the Exponential class or
the .exponential() method on any gate instance:
from qilisdk.digital.gates import Exponential, Y
exp_y = Exponential(basic_gate=Y(1))
exp_y = Y(1).exponential()