Gates and Instructions¶
A Program
is effectively a list of gates and instructions which
can be created using the function documented in this section:
>>> p = Program()
>>> p += H(qubit=0)
>>> p += RY(angle=pi/3, qubit=1)
>>> p += CNOT(0, 1)
...
Native gates for Rigetti QPUs¶
Physical quantum processors can enact a subset of all named gates. Luckily,
a small set of gates is universal for quantum computation, so all named gates
can be enacted by suitable combinations of physically realizable gates. Rigetti’s
superconducting quantum processors can perform RX()
with angle=+-pi/2
or
angle=+-pi
, RZ()
with an arbitrary angle, and CZ()
interactions
between neighboring qubits. Rigetti QPUs can natively measure in the computational (Z) basis.
RX (angle, qubit) |
Produces the RX gate. |
RZ (angle, qubit) |
Produces the RZ gate. |
CZ (control, target) |
Produces a controlled-Z gate. |
MEASURE (qubit, classical_reg) |
Produce a MEASURE instruction. |
All gates and instructions¶
In general, you will write a quantum program using the full suite of Quil gates and instructions and use the Quil compiler to compile programs into the target instruction set (ISA). The full list of quantum gates and classical Quil instructions is enumerated here.
Single-qubit gates
I (qubit) |
Produces the I identity gate. |
X (qubit) |
Produces the X (“NOT”) gate. |
Y (qubit) |
Produces the Y gate. |
Z (qubit) |
Produces the Z gate. |
H (qubit) |
Produces the Hadamard gate. |
S (qubit) |
Produces the S gate. |
T (qubit) |
Produces the T gate. |
RX (angle, qubit) |
Produces the RX gate. |
RY (angle, qubit) |
Produces the RY gate. |
RZ (angle, qubit) |
Produces the RZ gate. |
PHASE (angle, qubit) |
Produces the PHASE gate. |
Multi-qubit gates
CZ (control, target) |
Produces a controlled-Z gate. |
CNOT (control, target) |
Produces a controlled-NOT (controlled-X) gate. |
CCNOT (control1, control2, target) |
Produces a doubly-controlled NOT gate. |
CPHASE00 (angle, control, target) |
Produces a controlled-phase gate that phases the |00> state. |
CPHASE01 (angle, control, target) |
Produces a controlled-phase gate that phases the |01> state. |
CPHASE10 (angle, control, target) |
Produces a controlled-phase gate that phases the |10> state. |
CPHASE (angle, control, target) |
Produces a controlled-phase instruction. |
SWAP (q1, q2) |
Produces a SWAP gate which swaps the state of two qubits. |
CSWAP (control, target_1, target_2) |
Produces a controlled-SWAP gate. |
ISWAP (q1, q2) |
Produces an ISWAP gate. |
PSWAP (angle, q1, q2) |
Produces a parameterized SWAP gate. |
Classical instructions
WAIT |
This instruction tells the quantum computation to halt. |
RESET ([qubit_index]) |
Reset all qubits or just a specific qubit at qubit_index. |
NOP |
This instruction applies no operation at that timestep. |
HALT |
This instruction ends the program. |
MEASURE (qubit, classical_reg) |
Produce a MEASURE instruction. |
NEG (classical_reg) |
Produce a NEG instruction. |
NOT (classical_reg) |
Produce a NOT instruction. |
AND (classical_reg1, classical_reg2) |
Produce an AND instruction. |
OR (classical_reg1, classical_reg2) |
Produce an OR instruction. |
IOR (classical_reg1, classical_reg2) |
Produce an inclusive OR instruction. |
XOR (classical_reg1, classical_reg2) |
Produce an exclusive OR instruction. |
MOVE (classical_reg1, classical_reg2) |
Produce a MOVE instruction. |
EXCHANGE (classical_reg1, classical_reg2) |
Produce an EXCHANGE instruction. |
LOAD (target_reg, region_name, offset_reg) |
Produce a LOAD instruction. |
STORE (region_name, offset_reg, source) |
Produce a STORE instruction. |
CONVERT (classical_reg1, classical_reg2) |
Produce a CONVERT instruction. |
ADD (classical_reg, right) |
Produce an ADD instruction. |
SUB (classical_reg, right) |
Produce a SUB instruction. |
MUL (classical_reg, right) |
Produce a MUL instruction. |
DIV (classical_reg, right) |
Produce an DIV instruction. |
EQ (classical_reg1, classical_reg2, …) |
Produce an EQ instruction. |
LT (classical_reg1, classical_reg2, …) |
Produce an LT instruction. |
LE (classical_reg1, classical_reg2, …) |
Produce an LE instruction. |
GT (classical_reg1, classical_reg2, …) |
Produce an GT instruction. |
GE (classical_reg1, classical_reg2, …) |
Produce an GE instruction. |
Collections
QUANTUM_GATES |
Dictionary of quantum gate functions keyed by gate names. |
STANDARD_INSTRUCTIONS |
Dictionary of standard instruction functions keyed by instruction names. |