This post is written as part of the Q# Advent Calendar 2021. Happy Holidays!
If you’ve taken a stab at quantum programming, you’ll probably have heard of “hybrid quantum-classical computing”. Not to be confused with hybrid cloud or hybrid computers, hybrid quantum-classical computing is a popular topic among quantum computing aficionados and typically refers to a class of programs that you can run on modern quantum processors. Some of those programs include, for example, variational quantum algorithms and quantum approximate optimization algorithms. But what does “hybrid” really mean in that context?
Naively speaking, “hybrid” means a program that runs both classical and quantum code. Quantum code, here, is defined as a sequence of quantum gates that you apply to one or more qubits on a quantum device or Quantum Processing Unit (QPU). “Classical” refers to a program that runs on a regular computer, written in any programming language. Typically, you would choose one that can easily interface with a quantum computing service.
While this might seem straightforward, there’s more than one way to turn a quantum program into a hybrid one. The simplest way to do this is to run the classical part on your computer and submit the quantum part to a quantum cloud service. Typically, such a program will define a parameterized quantum circuit that is executed on a quantum processor (QPU) in a classical optimization loop. This means that each iteration in the loop will specify a different set of parameters that are passed to the parameterized quantum circuit, generating a new standalone quantum circuit.
Figure 1: A simple model for accessing a quantum processing unit (QPU) in the cloud.
If you’ve given this mode of operation a try, you’ve probably found that the unit of work is typically referred to as a “Job”. Each Job gets created when you submit a quantum circuit and is associated with a “Result”, that contains the qubit measurements data. If you submit multiple jobs as part of your hybrid program, then you get back multiple results.
Another thing you might have noticed is that this type of workflow generates a lot of Jobs. Each Job is added to a queue. If your unit of work is no longer a single circuit but a program that generates circuits, this means that your hybrid execution model can benefit from a more integrated approach. This is where hybrid quantum-classical cloud services can come in.
Figure 2: A a service that runs hybrid programs that generate quantum circuits.
In such a hybrid cloud service, rather than submitting a single circuit, you’ll submit a classical program that generates quantum circuits. Moreover, in this kind of execution model you could generate only a single Job per hybrid program, which would make it much easier to fetch results later and takes out a lot of the churn and data processing steps of combining data from multiple circuits.
While this kind of model works well for hybrid programs and could even have performance benefits, for instance, due to shorter wait times on the QPU queue, the quantum circuit itself is still quantum-only. What if you could create a quantum program that includes hybrid quantum operations, such as conditional or rotational gates that depend on qubit measurements?
This is where the model that runs on something I’ll call a hybrid quantum processor comes in. In such a hybrid quantum stack, the classical compute is integrated with the quantum device. This means you can create a program that includes not only a classical loop that generates quantum circuits, but also quantum circuits that include hybrid operations. For instance, rather than returning only measurement data, the processor can now use the classical compute to perform simple calculations with multiple measurement results to return a value that is input to, for example, a conditional or rotational quantum gate.
Figure 3: A service that runs full hybrid quantum programs on a Hybrid Quantum Processor.
There are several interesting applications for hybrid quantum algorithms such as Repeat-Until-Success, Iterative Phase Estimation or implementations of Quantum Error Correction. As the quantum control stack gains more complexity and features, more classical compute could make its way to the lower levels of the stack. Moreover, as demands for more performant qubits increase, quantum error correction features could become accessible to quantum developers.
You can imagine there are probably even more execution models for hybrid quantum programs, for instance, different variations of the above that include another step of cloud compute, or even models that include distributed quantum computing. While I haven’t covered them all, I hope this post has given you some insights into what models are out there for hybrid quantum-classical programs, and in what situations they are most useful.
If you want to give Q#, a high-level programming language built for hybrid quantum processing a try on a simple hybrid algorithm, take a look at the Teleportation Quantum Kata. If you want to see how you can build a Variational Quantum Algorithm with Q#, take a look at my blog post here: Quantum developer tools for chemistry – Q# Blog (microsoft.com).
0 comments