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
- QCI
Each provider may have different requirements and capabilities. Refer to the Azure Quantum documentation for more details about specific providers.