Overview
qBraid
| SDK
A Python toolkit for cross-framework abstraction, transpilation, and execution of quantum programs.
- Release
0.4.0
Features
Unified quantum frontend interface. Transpile quantum circuits between supported packages. Leverage the capabilities of multiple frontends through simple, consistent protocols.
Build once, target many. Create quantum programs using your preferred circuit-building package, and execute on any backend that interfaces with a supported frontend.
Benchmark, compare, interpret results. Built-in compatible post-processing enables comparing results between runs and across backends.
Installation
For the best experience, install the qBraid SDK on lab.qbraid.com. Login (or create an account) on account.qbraid.com and then follow the steps to install an environment. Using the SDK on qBraid Lab means direct, pre-configured access to all Amazon Braket supported devices and IBM Quantum open systems with no additional access keys or API tokens required. See qBraid Quantum Jobs for more.
The qBraid-SDK, and all of its dependencies, can also be installed using pip:
pip install qbraid
If using locally, follow linked instructions to configure your qBraid, AWS, and IBMQ credentials.
Usage
Construct a quantum program of any supported program type:
>>> from qbraid import QPROGRAM_LIBS
>>> from qbraid.interface import random_circuit
>>> QPROGRAM_LIBS
['braket', 'cirq', 'qiskit', 'pyquil', 'pytket', 'qasm']
>>> circuit = random_circuit("qiskit", num_qubits=1, measure=True)
Search for quantum backend(s) on which to execute your program:
>>> from qbraid import get_devices
>>> from qbraid.api import ibm_least_busy_qpu
>>> get_devices(filters={"architecture": {"$regex": "superconducting"}, "vendor": "AWS"})
Device status updated 0 minutes ago
Device ID Status
--------- ------
aws_oqc_lucy ONLINE
aws_rigetti_aspen_m2 OFFLINE
aws_rigetti_aspen_m3 ONLINE
>>> ibm_least_busy_qpu()
ibm_q_perth
Apply the device wrapper and send your quantum jobs:
>>> from qbraid import device_wrapper
>>> jobs = []
>>> qbraid_ids = ['aws_oqc_lucy', 'ibm_q_perth']
>>> for device in qbraid_ids:
... qdevice = device_wrapper(device)
... qjob = qdevice.run(circuit, shots=1000)
... jobs.append(qjob)
List your submitted jobs and view their status:
>>> from qbraid import get_jobs
>>> get_jobs(filters={"numResults": 2})
Displaying 2 most recent jobs matching query:
Job ID Submitted Status
------ --------- ------
aws_oqc_lucy-exampleuser-qjob-zzzzzzz... 2023-05-21T21:13:47.220Z QUEUED
ibm_q_perth-exampleuser-qjob-xxxxxxx... 2023-05-21T21:13:48.220Z RUNNING
Compare the results:
>>> print("{:<20} {:<20}".format('Device','Counts'))
... for i, job in enumerate(jobs):
... result = job.result()
... counts = result.measurement_counts()
... print("{:<20} {:<20}".format(qbraid_ids[i],str(counts)))
Device Counts
aws_oqc_lucy {'0': 477, '1': 547}
ibm_q_perth {'0': 550, '1': 474}