A platform-agnostic quantum runtime framework.

The qBraid-SDK is a platform-agnostic quantum runtime framework designed for both quantum software and hardware providers. This Python-based tool streamlines the full lifecycle management of quantum jobs—from defining program specifications to job submission, and through to the post-processing and visualization of results.

Distinguishing itself through a streamlined and highly-configurable approach to cross-platform integration, the qBraid-SDK does not assume a fixed target software framework. Instead, it allows providers to dynamically register any desired run input program type as the target, depending on their specific needs. These program types are interconnected via a graph-based transpiler, where each program type is represented as a node and supported conversions as edges. The breadth, depth, and connectivity of this ConversionGraph can be customized by the provider.

The framework also facilitates the insertion of additional program validations, circuit transformations, and transpiler/compiler steps into its modular pipeline through a comprehensive TargetProfile. This profile encapsulates both device properties (such as number of qubits, maximum shots, native gate set) and the software requirements (ProgramSpec) needed to submit a job, vastly reducing the overhead and redundancy typically associated with cross-platform integrations in quantum computing.

Key Features

1. Quantum Program Integration

Offers native support for 10 major quantum programming libraries including 20+ inter-library conversions with the ability to dynamically register new program types and conversions on the fly. This enables flexible program submissions to cater to the unique capabilities and constraints of your preferred framework, facilitated by a unique conversion map that automatically adapts quantum programs during runtime according to the given specifications.

2. Modular Design

  • qbraid.programs: Extracts and manages metadata from supported quantum program types, with the flexibility to introduce new types.
  • qbraid.transpiler: Bridges different quantum programming IRs through native and customizable circuit conversions.
  • qbraid.passes: Ensures quantum programs conform to hardware specifications through essential runtime transformations.
  • qbraid.runtime: Defines essential abstractions for providers, devices, jobs, and results, integrated through a coherent runtime profile.
  • qbraid.visualization: Provides tools for visualizing quantum circuits and experimental data, enhancing data interpretation.

3. Extensibility and Customization

The framework encourages community contributions and extensions, supporting an evolving ecosystem of program types and conversions, adaptable to specific provider needs. By providing a comprehensive runtime solution, the qBraid-SDK offers significant advantages to both hardware and software providers:

  • Reduces Overhead: Minimizes the effort required to develop client-side applications for securely submitting and managing quantum experiments remotely.
  • Enhances Integration: Facilitates seamless integration and interoperability of quantum software tools across all layers of the stack.
  • Broad Compatibility: Supports a diverse range of API complexities, catering to both established players like IBM and AWS as well as emerging providers.

Installation & Setup

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 QPUs from IonQ, Oxford Quantum Circuits, QuEra, Rigetti, and IQM, as well as on-demand simulators from qBraid and AWS. Use access key EHNU6626 for 1000 free credits to get started. See qBraid Quantum Jobs for more.

Local Installation

The qBraid-SDK, and all of its dependencies, can be installed using pip:

pip install qbraid

You can also install from source by cloning the GitHub repository and running a pip install command in the root directory:

git clone https://github.com/qBraid/qBraid.git
cd qBraid
pip install .
Note: The qBraid-SDK requires Python 3.9 or greater.

To use qBraid runtime locally, you must also install the necessary extras and configure your account credentials according to the device(s) that you are targeting. Follow the linked, provider-specific, instructions for the QbraidProvider, BraketProvider, QiskitRuntimeProvider, IonQProvider, and OQCProvider, as applicable.

Quickstart

Transpiler

Construct a quantum program of any supported program type:

Below, QPROGRAM_REGISTRY maps shorthand identifiers for supported quantum programs, each corresponding to a type in the typed QPROGRAM Union. For example, ‘qiskit’ maps to qiskit.QuantumCircuit in QPROGRAM. Notably, ‘qasm2’ and ‘qasm3’ both represent raw OpenQASM strings. This arrangement simplifies targeting and transpiling between different quantum programming frameworks.

>>> from qbraid import QPROGRAM_REGISTRY
>>> QPROGRAM_REGISTRY
{'cirq': cirq.circuits.circuit.Circuit,
 'qiskit': qiskit.circuit.quantumcircuit.QuantumCircuit,
 'pennylane': pennylane.tape.tape.QuantumTape,
 'pyquil': pyquil.quil.Program,
 'pytket': pytket._tket.circuit.Circuit,
 'braket': braket.circuits.circuit.Circuit,
 'braket_ahs': braket.ahs.analog_hamiltonian_simulation.AnalogHamiltonianSimulation
 'openqasm3': openqasm3.ast.Program,
 'pyqir': builtins.Module,
 'cpp_pyqubo': cpp_pyqubo.Model,
 'qasm2': str,
 'qasm3': str,
 'qubo': ~QuboCoefficientsDict,
 'bloqade': bloqade.builder.assign.BatchAssign}

Pass any registered quantum program along with a target package from QPROGRAM_REGISTRY to “transpile” your circuit to a new program type:

Conversions

Behind the scenes, the qBraid-SDK uses rustworkx to create a directional graph that maps all possible conversions between supported program types:

from qbraid import ConversionGraph, ExperimentType

# Loads native conversions from QPROGRAM_REGISTRY
graph = ConversionGraph()

# Plot GATE_MODEL nodes and "Conversion" edges
graph.plot(experiment_type=ExperimentType.GATE_MODEL, legend=True)

You can use the native conversions supported by qBraid, or define your own custom nodes and/or edges. For example:

from unittest.mock import Mock

from qbraid import register_program_type, Conversion

# replace with any program type
register_program_type(Mock, alias="mock")

# replace with your custom conversion function
example_qasm3_to_mock_func = lambda x: x

conversion = Conversion("qasm3", "mock", example_qasm3_to_mock_func)

graph.add_conversion(conversion)

# filter ConversionGraph to include only GATE_MODEL nodes
graph = graph.subplot(ExperimentType.GATE_MODEL)

# using a seed is helpful to ensure reproducibility
graph.plot(seed=20, k=3, legend=True)

QbraidProvider

Run experiments using on-demand simulators provided by qBraid using the qbraid.runtime.QbraidProvider. You can get a Python list of device objects using:

Or, instantiate a known device by ID via the QbraidProvider.get_device() method, and submit quantum jobs from any supported program type:

device = provider.get_device("qbraid_qir_simulator")
jobs = device.run([qiskit_ckt, braket_ckt, cirq_ckt, qasm3_str], shots=1000)
results = [job.result() for job in jobs]

print(results[0].data.get_counts())
# {'00': 483, '01': 14, '10': 486, '11': 17}

Supported Frontends