Azure Quantum introduces sessions to accelerate your research with variational algorithms

Lucas Enloe

To take full advantage of an Interactive Hybrid architecture, many popular algorithms such as the Variational Quantum Eigensolver (VQE) and the Quantum Approximate Optimization Algorithm (QAOA) require tight integration between the cloud provider and the quantum hardware manufacturer. 

 

Today, Azure Quantum is introducing sessions, freeing you from the need to understand specificities of the cloud provider or quantum manufacturer. With a simple Python API call you can start a session that will logically group your jobs and take advantage of performance optimizations that the quantum manufacturer may provide, combining simplicity of use and performance.  

In partnership with Quantinuum, we are also announcing that you can get exclusive access to the QPU for the duration of the session.  

Organize your quantum jobs with sessions 

Without sessions, running multiple iterations of algorithms that each contain multiple quantum jobs can quickly become confusing. Sessions allow you to group jobs within a single run of an algorithm, making it easier to track and manage them. When managing jobs in your Azure Quantum workspace via the Azure Portal, sessions are now displayed alongside any jobs submitted without a session. You can drill into a session to see the job details for all jobs that make up the session. 

Sessions are now displayed in your Quantum Workspace along with any jobs not associated with a session

 

Clicking on a session lets you drill down to see all jobs within the session

Similarly, you can manage your sessions locally using the Microsoft QDK.

Improve performance with dedicated QPU access for sessions with Quantinuum 

Session IDs are attached to all jobs sent to Azure Quantum’s hardware partners, allowing them to identify related jobs and improve processing. As part of our sessions release, Quantinuum now offers an exciting feature that can dramatically improve performance for researchers running complex hybrid algorithms. 

For all Quantinuum targets, once the first job in a session is completed, subsequent jobs in the same session get exclusive access to the target for the duration of the session as long as Quantinuum receives them within a minute of previous job execution. Individual jobs no longer need to get in the back of the queue, with Quantinuum’s support for sessions they’re treated as components of a single algorithm with dedicated QPU access! 

 “Variational algorithms play an important role in the NISQ timeframe. Quantinuum provides batching capability for running a set of circuits back-to-back in a quick succession. Now this capability is available to our Azure customers via Azure Quantum Sessions providing increased convenience to the algorithm developers who need to run their experiments with minimal delay between individual circuits.” 

Alex Chernoguzov, Sr. Technical Fellow, Quantinuum 

Quantinuum has been an important partner for Azure Quantum and the quantum community, and their additional support for sessions will help researchers push the boundaries of quantum computing as hardware and algorithms continue to scale. 

Save time and money with job failure policies 

As quantum algorithms become more complex, cost and runtime considerations become increasingly important. Parameterized hybrid algorithms like VQE and QAOA can fail if an individual quantum job failure prevents classical code from defining appropriate parameters for the next job. Submitting improperly parameterized jobs after a previous job failure can waste valuable time and resources. 

To prevent this, jobs within a session have a cancel-on-failure policy by default: if a job within a session fails, Azure Quantum automatically stops submission of subsequent jobs in the session and attempts to cancel any jobs already submitted to a target. This policy can be disabled if you’d like subsequent jobs in your session to continue to run even if previous jobs fail. 

How to create a session 

The basic sample below shows how to create a session in Python with Qiskit using a simple circuit run three times. 

from qiskit import QuantumCircuit 
from qiskit.tools.monitor import job_monitor 
from azure.quantum.qiskit import AzureQuantumProvider 
 
# Enter your Azure Quantum workspace details here 
provider = AzureQuantumProvider( 
            resource_id = "", 
            location = "") 
 
# Define a circuit 
circuit = QuantumCircuit(2, 2) 
circuit.name = "GenerateRandomBit" 
circuit.h(0) 
circuit.cnot(0,1) 
circuit.measure([0,1], [0,1]) 
circuit.draw() 
 
# Choose a target 
backend = provider.get_backend("quantinuum.sim.h1-1e") 
 
# Create a session and run three jobs in the session 
with backend.open_session(name="Qiskit Session") as session: 
    for i in range(3): 
        # Some classical logic could go here 
        job = backend.run(circuit=circuit, shots=100, job_name="Job "+str(i+1))
        job_monitor(job) 
 
# Check the state of the session 
session.refresh() 
print("Session " + session.id + " is in " + session.details.status + " state.") 

It’s easy to extend sessions to more advanced scenarios. As part of our sessions release, Azure Quantum published new sample code for running VQE on a hydrogen molecule that you can use in the Azure portal or your preferred IDE. Running the sample in a session is as easy as adding one line of code: 

with backend_target.open_session(name="VQE Nature IonQ Sim") as session: 
    calc = GroundStateEigensolver(qubit_converter, vqe_solver) 
    print(calc.get_qubit_operators(problem)) 
    res = calc.solve(problem) 
    print(res.groundenergy) 

You can also create sessions with Cirq and Q# via Azure Quantum’s Python SDK. See the sessions documentation for the full list of supported scenarios. 

Learn more 

Sessions are one part of Microsoft’s work to enable hybrid quantum computing at scale. You can read the full details of sessions in our documentation. 

To get started with sessions with Azure Quantum, create your own free Azure Quantum workspace and check out our new VQE sample in the Azure Portal or your preferred development environment 

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • Stuart Flannigan 0

    Hi there, this looks awesome and incredibly useful!

    Can you submit session jobs asynchronously? I don’t want to have to leave my console open while the job is running. I want to get back a job_id and then check on results later.

    • Lucas EnloeMicrosoft employee 0

      Hi Stuart, yes job results are saved, so you can submit jobs and then come back later to access job results. You can do this in the Azure Portal from the job management blade, as well as the SDK or tool you used to submit the job. You can find more info on managing jobs here.

Feedback usabilla icon