Documentation Index
Fetch the complete documentation index at: https://docs.qbraid.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation & Setup
To interface with Azure Quantum supported devices, install the azure extra:
pip install 'qbraid[azure]'
Then, follow the Azure Quantum setup instructions to create a workspace and get your credentials.
Authentication Methods
The AzureQuantumProvider integrates with Azure Quantum via the azure-quantum package. It connects to an Azure Quantum Workspace, which manages your quantum resources.
Using a Connection String
You can authenticate using an Azure connection string, which provides a direct way to access your workspace. First, retrieve your connection string by following these instructions. Then, use it to initialize a Workspace object and pass it to AzureQuantumProvider:
# Authenticate using a connection string
from azure.quantum import Workspace
from qbraid.runtime import AzureQuantumProvider
connection_string = "[Your connection string here]"
workspace = Workspace.from_connection_string(connection_string)
provider = AzureQuantumProvider(workspace=workspace)
Using Environment Variables
To avoid hardcoding credentials in your code, you can store the connection string as an environment variable instead:
export AZURE_QUANTUM_CONNECTION_STRING="your-connection-string"
Then, initialize AzureQuantumProvider without passing explicit credentials:
from qbraid.runtime import AzureQuantumProvider
provider = AzureQuantumProvider() # Uses the environment variable
Related Content
Basic Usage
Submit a Quantum Task to an Azure Quantum device using the AzureQuantumProvider:
from qbraid.runtime import AzureQuantumProvider
provider = AzureQuantumProvider() # Uses environment variables
# List available devices
provider.get_devices()
# [<qbraid.runtime.azure.device.AzureDevice('ionq.simulator')>,
# <qbraid.runtime.azure.device.AzureDevice('ionq.qpu')>,
# <qbraid.runtime.azure.device.AzureDevice('quantinuum.hqs-lt-s1')>,
# <qbraid.runtime.azure.device.AzureDevice('quantinuum.hqs-lt-s2')>,
# <qbraid.runtime.azure.device.AzureDevice('quantinuum.h1-1')>]
# Get a specific device
device = provider.get_device("ionq.simulator")
type(device)
# qbraid.runtime.azure.device.AzureDevice
device.metadata()
# {'device_id': 'ionq.simulator',
# 'device_type': 'SIMULATOR',
# 'num_qubits': 29,
# 'provider_name': 'IonQ',
# 'status': 'ONLINE'}
Now that we’ve instantiated our device, in this case the IonQ simulator on Azure Quantum, we can construct a quantum circuit and submit a task using the .run method:
from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
job = device.run(circuit, shots=10)
We now have job which is of type AzureQuantumTask, which inherits from QuantumJob. To see the results:
res = job.result()
res.data.get_counts()
# {'00': 5, '11': 5}
res.data.measurements
# array([[0, 0],
# [1, 1],
# [0, 0],
# [1, 1],
# [0, 0],
# [1, 1],
# [0, 0],
# [1, 1],
# [0, 0],
# [1, 1]])
See how to visualize these results in the Visualization section.
Supported Providers
Azure Quantum provides access to quantum hardware and simulators from several providers:
- IonQ
- Quantinuum
- Rigetti
- Pasqal
Each provider may have different requirements and capabilities. Refer to the Azure Quantum documentation for more details about specific providers.
Runtime Options
The AzureQuantumDevice.run() and .submit() methods accept an input_params keyword argument
that is passed through to the Azure Quantum backend. Each hardware provider supports different
options.
Quantinuum
Quantinuum emulators and hardware support several input parameters for controlling
simulation type, noise models, and compiler optimization.
Simulator type
Quantinuum emulators support both state-vector (default) and stabilizer simulation:
device = provider.get_device("quantinuum.sim.h2-1e")
# Use the stabilizer simulator (Clifford circuits only)
job = device.run(circuit, shots=100, input_params={"simulator": "stabilizer"})
Noise model
Disable the emulator’s noise model for ideal simulation:
job = device.run(circuit, shots=100, input_params={"error-model": False})
Customize individual noise parameters:
job = device.run(
circuit,
shots=100,
input_params={
"error-params": {
"p1": 4e-5,
"p2": 3e-3,
"p_meas": [3e-3, 3e-3],
"p_init": 4e-5,
"p_crosstalk_meas": 1e-5,
"p_crosstalk_init": 3e-5,
}
},
)
Compiler options
Control TKET optimization level or disable optimization entirely:
# Set optimization level (0, 1, or 2; default is 2)
job = device.run(circuit, shots=100, input_params={"tket-opt-level": 1})
# Disable optimization
job = device.run(circuit, shots=100, input_params={"no-opt": True})
See Quantinuum provider for full details.
IonQ
IonQ devices on Azure support error mitigation and noise model simulation.
Error mitigation
Debiasing is enabled by default on Aria and Forte systems. To explicitly control it:
device = provider.get_device("ionq.qpu.aria-1")
# Disable debiasing
job = device.run(circuit, shots=1000, input_params={"error-mitigation": {"debias": False}})
Noise model simulation
Run on the IonQ simulator with a hardware noise profile:
device = provider.get_device("ionq.simulator")
job = device.run(
circuit,
shots=1000,
input_params={
"noise": {
"model": "aria-1",
"seed": 42,
}
},
)
Set "model": "ideal" for noiseless simulation (up to 29 qubits).
See IonQ provider for full details.
Rigetti
Rigetti devices on Azure support compiler control and parameter substitutions.
Skip quilc compilation
When using native Quil or Quil-T programs, you can bypass the quilc compiler:
device = provider.get_device("rigetti.qpu.ankaa-3")
job = device.submit(quil_program, shots=100, input_params={"skipQuilc": True})
Parameter substitutions
For parametrized Quil programs, provide values for declared variables:
quil_program = """
DECLARE ro BIT[2]
DECLARE theta REAL[2]
RX(theta[0]) 0
RX(theta[1]) 1
MEASURE 0 ro[0]
MEASURE 1 ro[1]
"""
job = device.submit(
quil_program,
shots=100,
input_params={
"substitutions": {
"theta": [[0.0, 3.14], [1.57, 3.14]]
}
},
)
See Rigetti provider for full details.
Options Reference
| Provider | Parameter | Type | Description |
|---|
| Quantinuum | simulator | str | "stabilizer" or "state-vector" (default) |
| Quantinuum | error-model | bool | Enable/disable noise model (default True) |
| Quantinuum | error-params | dict | Custom noise parameters |
| Quantinuum | tket-opt-level | int | TKET optimization level (0-2) |
| Quantinuum | no-opt | bool | Disable compiler optimization |
| IonQ | error-mitigation | dict | {"debias": True/False} |
| IonQ | noise | dict | {"model": "aria-1", "seed": int} |
| Rigetti | skipQuilc | bool | Skip quilc compiler |
| Rigetti | substitutions | dict | Parameter values for Quil programs |
Via qBraid Runtime API
When submitting jobs through the QbraidProvider, these same
options can be passed via the runtimeOptions field. The runtime API forwards them as input_params
to the Azure device.run() or device.submit() call:
from qbraid.runtime import QbraidProvider
provider = QbraidProvider()
device = provider.get_device("azure:quantinuum:sim:h2-1e")
# Use stabilizer simulator with no noise
job = device.run(
circuit,
shots=100,
runtime_options={"simulator": "stabilizer", "error-model": False},
)
device = provider.get_device("azure:ionq:sim:simulator")
# Run with hardware noise model
job = device.run(
circuit,
shots=1000,
runtime_options={"noise": {"model": "aria-1", "seed": 42}},
)