Quil is a quantum instruction language that expresses a quantum program as a flat sequence of gates, measurements, classical memory operations and control-flow instructions, designed to run on a shared quantum-classical machine model. In quantum software, it sits at the level of an assembly language: higher-level tools such as the pyQuil Python library generate Quil, and the quilc compiler rewrites it into the native gate set of a specific superconducting processor.
Quil was introduced in 2016 together with a formal execution model called the Quantum Abstract Machine, and it became the program format of Rigetti quantum processors and simulators. Within quantum computing, it is best understood as an early, explicitly hybrid instruction set architecture, comparable in role to OpenQASM but with its own design choices about memory, parameters and pulse-level extensions.
How Quil models a quantum computer
Quil describes programs for the Quantum Abstract Machine (QAM), a model with three parts: a register of qubits, a classical memory, and a program counter that steps through instructions. Because the classical memory and the qubits belong to one machine, a program can measure a qubit, store the bit and branch on it without leaving the instruction stream.
A Quil program is plain text, one instruction per line. Qubits are addressed by non-negative integer indices, classical memory is declared by name and type, and gates are applied by name with optional parameters, for example RX(pi/2) 0 or CZ 0 1. The machine executes instructions in order, and the result of a run is the contents of classical memory after the final instruction.
The following table lists the main building blocks of the language and what each contributes to a program.
| Construct | Example | Purpose |
|---|---|---|
| Gate application | H 0, CNOT 0 1 | Applies a unitary operation to qubits |
| Memory declaration | DECLARE ro BIT[2] | Reserves typed classical memory |
| Measurement | MEASURE 0 ro[0] | Collapses a qubit and stores the bit |
| Gate definition | DEFGATE with a matrix | Adds a custom unitary by name |
| Control flow | LABEL, JUMP-WHEN | Branches on classical values |
| Reset | RESET | Returns qubits to the ground state |
| Pragma | PRAGMA INITIAL_REWIRING | Passes hints to the compiler |
Parametric programs and classical memory
One of the most practical features of Quil is parametric compilation. A program can declare a real-valued memory region, such as DECLARE theta REAL, and use it as a gate angle in RZ(theta) 0. The program is compiled once, and different angle values are written into memory before each execution.
This design targets variational algorithms such as VQE and QAOA, in which a classical optimizer adjusts dozens or hundreds of angles across many iterations. Recompiling the circuit for every new parameter set would add seconds of latency per step, so binding parameters at run time reduces the classical overhead of hybrid quantum-classical computing considerably.
Quil memory types are deliberately simple. The table below shows the standard types and their typical role.
| Type | Typical use | Example declaration |
|---|---|---|
| BIT | Single measurement outcomes | DECLARE ro BIT[4] |
| OCTET | Packed byte-sized data | DECLARE buf OCTET[8] |
| INTEGER | Counters and indices | DECLARE n INTEGER |
| REAL | Gate angles for parametric programs | DECLARE theta REAL[3] |
Arithmetic instructions such as ADD, MUL and MOVE operate on this memory, and gate modifiers such as DAGGER, CONTROLLED and FORKED derive new gates from existing ones. These modifiers keep programs compact while leaving the decomposition work to the compiler.
The Quil toolchain: pyQuil, quilc and the QVM
Quil rarely appears alone; it is the common format of a toolchain. Developers typically write Python with pyQuil, which builds a Program object and serializes it to Quil text. The quilc compiler then performs gate decomposition, qubit routing and optimization for a target processor, and the result runs either on hardware or on the QVM simulator.
quilc reads the device topology and its native gates, which on Rigetti superconducting chips have historically been `RX` at fixed angles, arbitrary `RZ` and two-qubit `CZ` or `XY` interactions. Arbitrary RZ rotations are implemented as virtual frame changes, so the compiler pushes as much work as possible into them.
| Component | Role | Input and output |
|---|---|---|
| pyQuil | Python SDK for building programs | Python objects to Quil text |
| quilc | Optimizing quantum compiler | Arbitrary Quil to native Quil |
| QVM | Statevector and density matrix simulator | Quil to simulated results |
| Quil-T | Pulse-level language extension | Calibrations, frames and waveforms |
| quil-rs | Rust parser and program model | Quil text to typed structures |
Quil-T and pulse-level control
Quil-T extends the language with timing and analog control, giving access to pulse-level control of the hardware. It introduces frames (DEFFRAME), waveforms (DEFWAVEFORM), and instructions such as PULSE, CAPTURE, DELAY and FENCE.
With DEFCAL, a user can redefine how a named gate is calibrated, replacing the default microwave pulse for RX(pi/2) on a qubit with a custom shape. This matters for research on optimal control, leakage reduction and characterization experiments, but it also demands detailed knowledge of the device, because poorly designed pulses degrade fidelity quickly.
Quil compared with other quantum languages
Quil, OpenQASM and QIR solve a similar problem at different abstraction levels. The table compares their main design points, which helps explain why toolchains often convert between them.
| Aspect | Quil | OpenQASM 3 | QIR |
|---|---|---|---|
| Form | Text instruction list | Text with C-like syntax | LLVM-based representation |
| Classical control | Jumps and labels | Structured loops and branches | Full LLVM control flow |
| Parameters | Run-time memory regions | Input variables | Function arguments |
| Pulse extension | Quil-T | OpenPulse grammar | Vendor-specific |
| Main ecosystem | Rigetti and pyQuil | IBM and broad industry | Microsoft and partners |
In practice, OpenQASM has wider industry adoption, and many cloud services accept it as the interchange format. Quil remains relevant as the native format of Rigetti systems and as a cleanly specified example of a hybrid instruction set.
Limitations and common misconceptions
- Quil is not a high-level language. It has no functions with return values or type inference; abstractions belong in the host language.
- Unstructured jumps limit analysis.
JUMP-WHENis flexible, but compilers struggle to optimize arbitrary control flow, and hardware may support only restricted mid-circuit feedback. - Portability is partial. Native Quil for one chip encodes its topology and gate set, so it will not run unchanged on another device.
- Simulation does not equal hardware. A program that succeeds on the QVM without a noise model can fail on a real processor because of decoherence and gate errors.
Put simply
Quil is a written list of instructions for a quantum computer. Each line says something small and exact: rotate this qubit, link these two qubits, measure that one and write the answer down.
Programmers usually do not type it by hand. They write Python, and the tools turn it into Quil, much as a word processor turns formatting into a file format. The key idea is that Quil keeps quantum steps and ordinary data in one program, so the computer can measure, remember and decide what to do next.
In practice
A research group studies a small molecule with the variational quantum eigensolver on a superconducting processor. Its pyQuil script builds a circuit with 24 tunable angles stored in a REAL memory region and asks quilc to compile it once for a chain of six qubits.
During optimization, the classical optimizer proposes new angles about 400 times. Each time, the script writes the values into memory and runs the same compiled program for 2,000 shots, so no recompilation happens between steps. Before using hardware time, the team runs the program on the QVM with a noise model to check that the energy estimate behaves sensibly.
The result is a much shorter optimization loop than recompiling at every iteration, and the native Quil output lets the group inspect exactly which gates reached the chip.