Fast hybrid programming with Quantum Cloud Services

By Peter Karalekas and Nikolas Tezak

Near-term quantum computers work as co-processors with powerful classical computers, shouldering elements of a problem that are inefficient using classical methods. This hybrid quantum-classical programming paradigm has been a guiding principle for our team as we work toward building a platform tailored to the capabilities of the first generation of quantum hardware. To maximize performance, a hybrid computing platform needs to be easy to use, reliable, and most importantly, fast — the interaction between quantum and classical resources must be seamless.

Quantum Cloud Services is the fastest quantum computing platform available today. We’ve eliminated much of the overhead associated with the exchange between quantum and classical compute, resulting in up to a 30x improvement in program runtime over web API models. We’ll walk through three features that enable these performance gains and how you can leverage them in your quantum programs.


QCS introduces an entirely new access model for quantum computing. The Quantum Machine Image (QMI) is a virtual development and execution environment that comes pre-configured with Forest, our SDK for writing quantum programs. Each user gets a dedicated QMI that is colocated with the quantum processors, or QPUs, in our quantum data center. This proximity to the QPU drastically reduces network latency, which makes up the majority of the round-trip time to run quantum programs using a web API. Additionally, the cloud computing architecture of QCS unlocks new features across our compilation, simulation, and execution stack toward achieving fast hybrid programming.

The integrated architecture of QCS tightens the loop between quantum and classical resources.

Parametric compilation

Users develop quantum programs on the QMI using Quil, our quantum instruction language. For Quil to manipulate the state of the QPU, we must first convert it into instrument commands through a process called quantum compilation. Compilation is an expensive procedure, and in a typical web API offering, each program has to pass through the compilation stack on its way to the QPU. However, a certain class of interesting problems that can be run on a quantum computer, called variational hybrid algorithms, is implemented by optimizing over many iterations of the same quantum program with different classical parameters. We leverage Quil’s native support for classical shared memory to enable parametric compilation in QCS, which allows users to run all program variations with only one pass through the compiler, providing input parameters at run-time rather than compile-time. In the following notebook, we walk through how to define, compile, and rapidly execute parametric Quil programs on the QPU.

Active qubit reset

At the beginning of each quantum computation, all qubits must be returned to some state |0⟩, which is typically the ground state. This reset typically happens passively, by waiting for the qubits to “relax” to |0⟩ over some period of time. As qubit quality improves, however, relaxation takes longer and this method becomes increasingly slow. For web API access models, the relaxation time is negligible compared with the overhead of sending quantum programs over the internet. But because we’ve eliminated this network latency with QCS, suddenly relaxation becomes the largest contributor to round-trip execution time. To drive down this time, we have implemented an active qubit reset protocol, which allows users to quickly set all qubits to the |0⟩ state at the end of a computation.

Total execution time for 1000 shots of a small parametric program

Active reset decreases the delay between running successive programs on the QPU by an order of magnitude, and is a major contributor to the low-latency hybrid execution that is available in QCS. Additionally, because it is implemented by running programs that depend on the outcome of single-qubit measurements, active qubit reset is a stepping stone along the path toward arbitrary control flow and eventually quantum error correction. In the following notebook, we demonstrate how this feature can speed up your quantum programs, without having a material effect on overall performance.

Max-Cut QAOA

Now that we have worked through some of the features available in QCS, we will tie them all together with a real-world example. One popular algorithm for near-term (NISQ) devices is QAOA, the quantum approximate optimization algorithm. QAOA works by alternating between two parameterized unitaries — one that encodes the problem trying to be solved and another that explores the space of potential solutions. It can be used for finding approximate solutions to combinatorial optimization problems (COPs), which often do not have an efficient classical solution, meaning that they quickly become intractable as the problem size grows. COPs are one area some believe will be the first to allow for the demonstration of quantum advantage.

Max-Cut QAOA landscapes for three qubits on the QPU and QVM

Famous combinatorial optimization problems include the Traveling Salesman (TSP) and the Maximum Cut (Max-Cut) problems. In Max-Cut, the goal is to find a partitioning of a graph that has the largest possible cut, which is the number of edges that separate the two partitions of the graph. Some familiar machine learning problems can also be formulated as a COP. For example, clustering can be reduced to a weighted Max-Cut problem. The weighted Max-Cut problem is a small variant of Max-Cut, generalized for weighted graphs. In the following notebook we walk through how to run QAOA for weighted Max-Cut using the grid search optimizer, and show that the results from our Aspen QPU match the expected results from the QVM.

By tightly integrating our classical and quantum resources and removing the need for recompiling or waiting for qubits to relax, QCS provides more than an order of magnitude speedup over web API models. Together, colocation, parametric compilation, and active qubit reset allow for rapid iteration in hybrid quantum-classical programs. For example, the above Max-Cut QAOA problem runs in less than a minute on QCS, compared to more than 25 minutes when using a web API. These improvements make Quantum Cloud Services the fastest and easiest platform for building quantum applications on near-term quantum hardware.

Peter Karalekas and Nikolas Tezak are Quantum Software Engineers at Rigetti Computing. This work represents a full-stack collaboration between the Software, Hardware, and Quantum Engineering teams at Rigetti.

All of the Jupyter notebooks shared in this post come pre-loaded on every QMI.