API Reference: qbraid.runtime.native

Installation & Setup

To interface with the qBraid QIR simulator or any of the other 10+ quantum devices that support managed access through qBraid, install the qBraid runtime extra:

pip install 'qbraid[qir]'

Next, obtain your qBraid API key:

  1. Login or create an account at account.qbraid.com.
  2. Copy your API Key from the Plan info card on the left side of your account page.

Save account to disk

Once you have your API key, you can save it locally in a configuration file ~/.qbraid/qbraidrc, where ~ corresponds to your home ($HOME) directory:

Account credentials are saved in plain text, so only do so if you are using a trusted device.

from qbraid.runtime import QbraidProvider

provider = QbraidProvider(api_key='API_KEY')

Once the account is saved on disk, you can instantiate the provider without any arguments:

provider = QbraidProvider()

Load account from environment variables

Alternatively, the qBraid-SDK can discover credentials from environment variables:


Basic Usage

Given a qbraid_id, a QbraidDevice object can be created as follows:

>>> from qbraid.runtime.native import QbraidProvider
>>> provider = QbraidProvider()
>>> provider.get_devices()
>>> device = provider.get_device('qbraid_qir_simulator')
>>> type(device)
<class 'qbraid.runtime.native.device.QbraidDevice'>

From here, class methods are available to get information about the device, execute quantum programs, access the wrapped device object directly, and more.

>>> device.metadata()
{'device_id': 'qbraid_qir_simulator',
 'device_type': 'SIMULATOR',
 'num_qubits': 64,
 'status': 'ONLINE',
 'queue_depth': 0}

Then you can submit quantum jobs to the device.

run_input = [qiskit_circuit, braket_circuit, cirq_circuit, qasm3_str]

jobs = device.run(run_input, shots=100)

results = [job.result() for job in jobs]

# {'00': 50, '01': 2, '10': 47, '11': 1}

See how to visualize these results in the Visualization section.