Skip to main contentIBM 

Qiskit Serverless sets the stage for Qiskit Functions in the cloud

With Qiskit Serverless, users can build, deploy, and run workloads remotely using the compute resources of IBM Quantum™ platform.


4 Sep 2024

Kaelyn Ferris

Sanket Panda

Robert Davis

Qiskit Serverless has reached a new stage of maturity. We first introduced the concept of serverless quantum computing in 2021, and since then, we've been working hard to bring that concept to life. This work is essential because Qiskit Serverless will soon form the foundation for Qiskit Functions — powerful, pre-built workflows that allow researchers and developers to interact with quantum computers at a higher level of abstraction than ever before. With that rollout fast approaching, it’s the perfect time to refresh ourselves on the capabilities Qiskit Serverless introduces, and its important role in the Qiskit software stack.

The Qiskit Serverless service is a programming model — now available as a private preview — that allows users to leverage both quantum and classical resources in a cloud environment. It is particularly useful for performing complex, long-running tasks, and for running workflows that are intended to be executed on a regular basis. Qiskit Serverless gives you the ability to scale quantum jobs by running them across multiple quantum and classical compute resources, meaning you can continue to efficiently execute your workflows even after you’ve hit the resources limits of the local machine you may be using for quantum experiments.

Below, we take a closer look at how users can take advantage of these capabilities, explain how Qiskit Serverless actually works, and give readers an inside look at the improvements we’ve been making to it over the past several months.

Who should use Qiskit Serverless

There are two primary ways to make use of Qiskit Serverless — one relevant for researchers and computational scientists, and another intended for organizations or teams that want to build a cloud-based infrastructure of their own that includes quantum compute resources.

Researchers who have premium access to our fleet of QPUs can already utilize the instance of Qiskit Serverless that we’ve built on the IBM Quantum Platform. Check out our documentation page for more details on how to take advantage of this service.

For organizations looking to build their own infrastructure comprising both classical and quantum compute resources, we also provide Qiskit Serverless as an open-source tool that you can deploy on that infrastructure. For more details on this, be sure to review the package’s documentation on GitHub. The documentation includes useful resources showing how to deploy the package either locally or in the cloud.

Local configuration, remote execution

So, how exactly does Qiskit Serverless work? Where is it useful? If you’re a researcher and computational scientist, the essential concept to understand with Qiskit Serverless is that it allows you to locally configure a workload and deploy it for remote execution. This simple idea can prove immensely valuable for anyone running large, computationally intensive workloads.

Conceptually, it may be helpful to think of Qiskit Serverless in the context of Qiskit patterns, our framework for leveraging the combination of quantum and classical computing to tackle domain-specific problems. A Qiskit pattern is made up of four essential steps: (1) map problem to quantum circuits and operators, (2) optimize for target hardware, (3) execute on target hardware, and (4) post-process the results.

Qiskit Serverless doesn’t belong to any one of those steps. Instead, it sits below the entirety of the Qiskit patterns workflow, operating as a kind of support structure. Once you’ve defined your workload locally, Qiskit Serverless simplifies the process of deploying your workloads and running them remotely through each step of the pattern.

More than that, Qiskit Serverless also provides horizontal scalability for both quantum and classical workloads by allowing users to run jobs in parallel across multiple classical and quantum compute resources. In other words, Qiskit Serverless helps to ensure you have the resources they need to complete each step of a Qiskit pattern with optimal performance and minimal time to completion.

In practice, this combination of local configuration and remote execution could mean preparing many different transpilation pipelines for an ansatz circuit in a variational algorithm, executing them all in parallel, and picking the transpiled ansatz with the lowest depth before uploading your job to the cloud and running it with a mix of classical and quantum resources. Alternatively, it could mean preparing circuits to simulate the dynamics of many different chemistry models, measuring several different expectation values for each model, and then processing that data in a separate pipeline for analysis.

In either case, Serverless will persist your long-running variational quantum algorithm in the cloud for hours — even when your local computing environment is no longer active. Once you submit it, your program stays active in the cloud.

This is the primary utility of the Qiskit Serverless service — to enable users to deploy their workloads to the cloud, where remote resources provided by IBM can do the bulk of the work. Doing so helps to ensure that users don’t need to leave their local machine occupied running complex code and waiting in long queues, when they could be using those compute resources for something else.

Qiskit Serverless by example

To better understand just how useful Qiskit Serverless can be, let’s walk through an example of how we can use it to create a parallel transpilation program and deploy it to the IBM Quantum Platform as a reusable remote service.

It’s helpful to think about how this fits into the Qiskit patterns. Conceptually, Qiskit Serverless is a layer of abstraction that supports each step in the Qiskit patterns workflow. Qiskit Serverless can help you map problem to quantum circuits and operators, optimize for target hardware, execute on target hardware, post-process the results, or perform any combination of those four essential steps.

In this example, however, we’re focusing on the deployment of a program for quantum circuit transpilation, the process of converting a high-level quantum circuit into a circuit optimized to run on target hardware. In other words, we’re focusing on step 2 of Qiskit patterns, “optimize for target hardware.” We’ll begin by generating 30 randomly created circuits:

Next, we’ll create a function to transpile our abstract circuit for a given backend. For now, this is going to be run locally, but we’ll eventually modify this to run remotely across several circuits in parallel.

Now that we’ve set up our local program, we’ll want to deploy our circuits to the IBM Quantum Platform. Before we do that, however, let’s run the local program and check the results:

Performing this local run on a laptop took a total of 683 seconds. Keep in mind that we cannot turn the laptop off during this time. If we did that, we’d have to start over and run the program again.

With Qiskit Serverless, however, we can send this same workload to the IBM Quantum Platform where it will run using cloud resources that are completely independent of your local machine. If your laptop falls asleep or runs out of battery while this remote execution takes place, it’s no problem at all.

So, let’s do exactly that—deploy our local program to Qiskit Serverless on the IBM Quantum Platform. To start, we’ll use the default IBM Quantum Platform API Token to authenticate with the Qiskit Serverless service.

After that, we’ll update our implementation to collect inputs and run in parallel:

Finally, we can upload our custom workflow:

Now we’re ready to run our program in a serverless environment. We’re able to do this with just a few lines of code:

This will start our remote job in a queue and print the status. At any time, you can close your local system or print logs. Once the job is complete, we’ll print the results, as follows:

And there we have it! A reusable transpilation program deployed to IBM Quantum Platform as a reusable remote service.

Improvements to Qiskit Serverless set the stage for Qiskit Functions

We’ve made a number of improvements to Qiskit Serverless since we first unveiled it last fall during IBM Quantum Summit 2023. Adjustments to the Serverless interface have helped to make it much more approachable for users experimenting with it for the first time. We’ve also implemented a number of enhancements on the backend that make it even easier to upload workloads and run them remotely over the cloud.

Beyond those fundamental technical improvements, we’re pleased to share the new Qiskit Serverless documentation, which offers a detailed guide to installing, getting started with, and deploying the Qiskit Serverless programming model. The documentation will be an invaluable resource, helping to simplify the process of getting started with and becoming a productive user of Qiskit Serverless.

That, however, is just the beginning. Qiskit Serverless sets the stage for a new era in cloud-enabled quantum computing, and opens the door to a variety of new managed quantum-classical services, such as the forthcoming introduction of Qiskit Functions.

First announced late last year, Qiskit Functions will be a catalog of functions operating in the managed Qiskit Serverless environment, which users can integrate into their workflow. Provided both by IBM and third-party partners, users will be able to choose from a number of powerful functions for tasks related to quantum chemistry simulation, quantum optimization, and quantum hardware performance management.

Stay tuned for a more detailed Qiskit Functions announcement coming soon, and in the meantime, get started with Qiskit Serverless here.


View documentation