How to perform long-running experiments on Azure Quantum

When you submit a quantum program to Azure Quantum, the job is uploaded to the Azure Storage account that you configured in the workspace waiting to be executed in the QPU provider you've selected. When your quantum program is next on the queue for the corresponding provider, Azure Quantum downloads your program and submits it to the provider, going from waiting to executing state. For more information about the state of Azure Quantum jobs, see Monitoring jobs.

If your quantum program requires many iterations, each one is submitted as a single job. For some quantum experiments, such as variational algorithms (VQE) and optimization algorithms (QAOA), it's common to run for hours or days, in particular when QPU queue times are high and the programs require many iterations.

Important

Azure Quantum hosted notebooks offer a free no-installation experience to run small scale experiments lasting less than one hour.

See the following suggestion to run long-runtime experiments in Azure Quantum.

Program with few loops

If your program doesn't require many loops and the QPU queue time is high, you may wait a couple of hours and submit your job later, or submit your program to a different provider from the ones available in Azure Quantum.

Sessions

A session is a logical grouping of any combination of one or more jobs against a single target. Sessions allow you to organize multiple quantum computing jobs with the ability to run classical code between quantum jobs. You'll be able to run complex algorithms to better organize and track your individual quantum computing jobs.

Each quantum hardware provider defines their own heuristics to best manage the prioritization of jobs within a session. In some cases, jobs submitted within a session are prioritized in the queue of that target.

For more information, see Get started with Sessions and How to manage sessions.

Local development

Installing the Azure Quantum Development Kit (QDK) extension for Visual Studio Code on your local computer provides support for Jupyter Notebooks, Python, and Q# files. You can develop quantum computing applications in your preferred IDE and language and run them on quantum simulators and quantum hardware using the Azure Quantum service.

Some scenarios where you may prefer a local environment:

  • You have a customized environment or preferred tools that are not available online.
  • You require source control on your project.
  • You are working with a multi-file project.

For more information, see Get started with the QDK.

Jupyter notebooks with Google Colab

Google Colab is a free cloud-based tool offered by Google Research that allows users to write and execute Python code in their web browsers. Google Colab is based on the Jupyter open source, and essentially allows you to create and share files without having to download or install anything.

To start using Google Colab notebooks to run your quantum programs on Azure Quantum, follow these steps:

  1. Add a new cell in the notebook, and Copy the following code to install the required Python packages:
!pip install -U azure-quantum
!pip install -U azure-quantum[qiskit]
  1. Click Runtime and select Restart runtime
  2. To access to your Azure Quantum workspace, you need to Authenticate. For example, you get a prompt like the following one: WARNING:azure.identity._internal.interactive:InteractiveBrowserCredential.get_token failed: Failed to open a browser. To sign in, use a Web browser to open the page https://microsoft.com/devicelogin and enter the code ET8BM63F3 to authenticate.
  3. Once you went through the authentication process, you should be able to run all the cells as if you were doing it from Azure Quantum hosted notebooks or from a local environment.