Quantum instruction glossary

This page is a reference that defines the various quantum instructions you can use to manipulate qubits in a quantum circuit. Quantum instructions include quantum gates, such as the Hadamard gate, as well as operations that are not quantum gates, such as the measurement instruction.

To learn more about using quantum gates to create quantum algorithms, see the single- and multi-qubit gates chapter of the IBM textbook, Learn Quantum Computation using Qiskit.

Click on a quantum instruction below to view its definition.

H gate CX gate Identity gate Rx gate Ry gate Rz gate X gate Y gate Z gate S gate Sdg gate T gate Tdg gate cH gate cZ gate cRz gate ccX gate SWAP gate Barrier operation |0> operation IF operation z measurement U3 gate U2 gate U1 gate

H gate

The H or Hadamard gate rotates the states \left|0\right\rangle and \left|1\right\rangle to \left|+\right\rangle and \left|-\right\rangle , respectively. It is useful for making superpositions. As a Clifford gate, it is useful for moving information between the x and z bases.

Composer reference

OpenQASM reference

        Bloch sphere rotation

h-gate

h q[0];

image1

CX gate

The controlled-X gate is also known as the controlled-NOT. It acts on a pair of qubits, with one acting as ‘control’ and the other as ‘target’. It performs an X on the target whenever the control is in state \left|1\right\rangle . If the control qubit is in a superposition, this gate creates entanglement.

Composer reference

OpenQASM reference

cxgate

cx q[0], q[1];

Id gate

The identity gate is actually the absence of a gate. It ensures that nothing is applied to a qubit for one unit of gate time.

Composer reference

OpenQASM reference

idgate

id q[0];

Rx gate

The Rx gate requires a single parameter: an angle expressed in radians. On the Bloch sphere, this gate corresponds to rotating the qubit state around the x axis by the given angle.

Composer reference

OpenQASM reference

        Bloch sphere rotation

rx_gate

rx(pi/2) q[0];

image13

Ry gate

The Ry gate requires a single parameter: an angle expressed in radians. On the Bloch sphere, this gate corresponds to rotating the qubit state around the y axis by the given angle.

Composer reference

OpenQASM reference

        Bloch sphere rotation

ry_gate

ry(pi/2) q[0];

image15

Rz gate

The Rz gate requires a single parameter: an angle expressed in radians. On the Bloch sphere, this gate corresponds to rotating the qubit state around the z axis by the given angle.

Composer reference

OpenQASM reference

        Bloch sphere rotation

rz_gate

rz(pi/2) q[0];

image17

X gate

The Pauli X gate has the property of flipping the \left|0\right\rangle state to \left|1\right\rangle , and vice versa. It is equivalent to Rx for the angle \pi .

Composer reference

OpenQASM reference

        Bloch sphere rotation

_x_gate

x q[0];

image19

Y gate

The Pauli Y gate is equivalent to Ry for the angle \pi . It is also equivalent to the combined effect of X and Z.

Composer reference

OpenQASM reference

        Bloch sphere rotation

_y_gate

y q[0];

image21

Z gate

The Pauli Z gate has the property of flipping the \left|+\right\rangle to \left|-\right\rangle , and vice versa. It is equivalent to Rz for the angle \pi .

Composer reference

OpenQASM reference

        Bloch sphere rotation

_z_gate

z q[0];

image23

S gate

The S gate is equivalent to Rz for the angle \pi/2 . As a Clifford gate, it is useful for moving information between the x and y bases.

Composer reference

OpenQASM reference

        Bloch sphere rotation

_s_gate

s q[0];

image25

Sdg gate

The inverse of the S gate. Equivalent to Rz for the angle -\pi/2 . As a Clifford gate, it is useful for moving information between the x and y bases.

Composer reference

OpenQASM reference

        Bloch sphere rotation

sdggate

sdg q[0];

image27

T gate

The T gate is equivalent to Rz for the angle \pi/4 . Fault-tolerant quantum computers will compile all quantum programs down to just the T gate and its inverse, as well as the Clifford gates.

Composer reference

OpenQASM reference

        Bloch sphere rotation

_t_gate

t q[0];

image29

Tdg gate

The inverse of the T gate, which is equivalent to Rz for the angle -\pi/4 . Fault-tolerant quantum computers will compile all quantum programs down to just the T gate and its inverse, as well as the Clifford gates.

Composer reference

OpenQASM reference

        Bloch sphere rotation

tdggate

tdg q[0];

image31

cH gate

The controlled-Hadamard gate, like the controlled-NOT, acts on a control and target qubit. It performs an H on the target whenever the control is in state \left|1\right\rangle .

Composer reference

OpenQASM reference

ch-gate

ch q[0], q[1];

cZ gate

The controlled-Z gate, like the controlled-NOT, acts on a control and target qubit. It performs a Z on the target whenever the control is in state \left|1\right\rangle .

Composer reference

OpenQASM reference

cz-gate

cz q[0], q[1];

cRz gate

The controlled-Rz gate, like the controlled-NOT, acts on a control and target qubit. It performs a Rz rotation on the target whenever the control is in state \left|1\right\rangle .

Composer reference

OpenQASM reference

crzgate

crz(pi/2) q[0], q[1];

ccX gate

The ccX gate, commonly known as the Toffoli, has two control qubits and one target. At applies an X to the target only when both controls are in state \left|1\right\rangle .

Composer reference

OpenQASM reference

ccx-gat

ccx q[0], q[1], q[2];

SWAP gate

The SWAP gate simply swaps the states of two qubits.

Composer reference

OpenQASM reference

swap-ga

swap q[0], q[1];

Barrier operation

To make your quantum program more efficient, the compiler will try to combine gates. The barrier is an instruction to the compiler to prevent these combinations being made.

Composer reference

OpenQASM reference

barrier

barrier q;

\left|0\right\rangle operation

The reset operation returns a qubit to state \left|0\right\rangle , irrespective of its state before the operation was applied. It is not a reversible operation.

Composer reference

OpenQASM reference

0-opera

reset q[0];

IF operation

The IF operation allows quantum gates to be conditionally applied, depending on the state of a classical register.

Composer reference

OpenQASM reference

if-oper

if (c==0) x q[0];

z measurement

Measurement in the standard basis, also known as the z basis or computational basis. Can be used to implement any kind of measurement when combined with gates. It is not a reversible operation.

Composer reference

OpenQASM reference

z-measu

measure q[0];

U3 gate

The three parameters allow the construction of any single-qubit gate. Has a duration of one unit of gate time.

Composer reference

OpenQASM reference

Bloch sphere rotation

u3gate

u3(pi/2,pi/2,pi/2) q[0];

image7

U2 gate

The two parameters control two different rotations within the gate. Has a duration of one unit of gate time.

Composer reference

OpenQASM reference

        Bloch sphere rotation

u2gate

u2(pi/2,pi/2) q[0];

image9

U1 gate

Equivalent to Rz. This can be implemented by the control software, requiring no actual manipulation of the qubits, and so effectively has a duration of zero.

Composer reference

OpenQASM reference

        Bloch sphere rotation

u1_gate

u1(pi/2) q[0];

image11