Choose a Backend

Goal

Choose a backend device: local, cloud or hardware. Optionally, enable error mitigation.

Prerequisites

  • Any provider-specific credentials/tokens if using cloud/hardware backends

  • (Optional) Noise model specifications

Quick Start

The minimal pattern for setting up a backend for a sampler or estimator is as follows:

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    # .<pick-one-backend>(...)
    .create()
)

or

import qrunch as qc

estimator = (
    qc.estimator_creator()
    .backend()
    .choose_backend()
    # .<pick-one-backend>(...)
    .create()
)

This guide explains how to pick one backend among the available options. We will use the sampler example, but the specifications for the estimator are analogous.

Noisy Memory Restricted Simulator

The Noisy Memory Restricted Simulator is our proprietary simulator that can emulate physical quantum hardware with user-configured device data. It combines the standard memory restricted simulator with Monte Carlo sampling to emulate hardware-like behavior based on calibration data.

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .local_memory_restricted(
         device_to_simulate=None  # Optional: simulate a specific device locally
         options=qc.options.MemoryRestrictedBackendOptions( # Optional options for the backend
             max_number_of_amplitudes=1_000_000,
             number_of_monte_carlo_runs=100,
             seed=142,
         )
    )
    .create()
)

The device_to_simulate can be None for noiseless simulation or one you create from another backend:

# Create a real Ankaa-3 Quantum Processor hardware backend.
backend = qc.backend_creator().amazon_braket(device=Devices.Rigetti.Ankaa3).create()

# Get device data from the backend - from the Ankaa-3 Quantum Processor
ankaa3_device_data = backend.get_device_data()

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .local_memory_restricted(
         device_to_simulate=ankaa3_device_data
    )
    .create()
)

The local_memory_restricted() backend calculates the approximate state vector using the allowed number of amplitudes of the given circuit, and uses this to find the probabilities for each possible state in the Hilbert space. The backend supports noisy simulations using the given device data through Monte Carlo simulation. See Using a Noisy Simulator for a guide on getting device data for hardware devices.

The result is representative of results from a quantum computer with the errors from the given device data. However, given the nature of Monte Carlo simulations, the result is not an ensemble average and will vary from run to run. Increase the number of Monte Carlo runs for better convergence to the ensemble average.

Local Amazon Braket - Runs Locally

Devices: pure local simulators or local noisy simulators.

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .local_amazon_braket(
        device_to_simulate=None  # Optional: simulate a specific device locally
    )
    .create()
)

The device to simulate can be either None or a device data object obtained from another backend. The backend will use a state vector simulator if None is specified, or it will simulate a provided device using a density matrix simulator. See Using a Noisy Simulator for a guide on getting device data for hardware devices.

Amazon Braket - Cloud Simulators or Hardware

Requirements: A valid AWS configuration with access to AWS Braket, and a configured AWS CLI. See Getting Started.

Devices: Amazon Braket cloud simulators (Devices.Amazon), hardware (IQM, IonQ, Rigetti) or noisy simulators.

import qrunch as qc
from braket.devices import Devices

device = Devices.Amazon.DM1

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .amazon_braket(device=device)
    .create()
)

The device can be any Braket device such as

  • Devices.Amazon.DM1

  • Devices.Amazon.SV1

  • Devices.IQM.Emerald

  • Devices.IQM.Garnet

  • Devices.IonQ.Forte1

See https://docs.aws.amazon.com/braket/latest/developerguide/braket-devices.html for the full list of devices.

Alternatively, you may specify device data from any other backend supported by Kvantify Qrunch. In that case, the backend will simulate the specified device using a density matrix simulator. See Using a Noisy Simulator for a guide on getting device data for hardware devices.

Qiskit - Provider-Agnostic Entry

Use Qiskit’s standard stack.

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .qiskit(seed=142)
    .create()
)

Local Qiskit Aer - Choose Simulation Method

A Local Qiskit Aer simulation method can be chosen explicitly:

import qrunch as qc
from qiskit_aer.noise import NoiseModel

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .local_qiskit_aer(
        method="automatic",              # Backend method
        seed=142,                        # Optional: random seed
        device_to_simulate=device_data,  # Optional: provide your own device to simulate.
    )
    .create()
)

The backend method can be one of:

  • "automatic"

  • "statevector"

  • "density_matrix"

  • "stabilizer"

  • "extended_stabilizer"

  • "matrix_product_state"

(See Qiskit AerSimulator documentation for more details on the methods.)

IBM Quantum Platform

Use IBM’s devices directly.

Requirements: A valid IBM Quantum token, obtained from IBM Quantum.

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .ibm_quantum_platform(
        token="your-ibm-token",           # IBM API token
        device="brisbane",                # IBM device name
        instance="instance-CRN-or-name",  # IBM instance identifier (optional)
    )
    .create()
)

The device can be one of IBM’s devices such as:

  • "pittsburgh"

  • "fez"

  • "marrakesh"

  • "torino"

  • "brisbane"

  • "aachen"

  • "strasbourg"

  • "brussels"

The least busy device in the token region:

  • "least_busy"

Or one of the fake IBM devices for testing:

  • "fake_fez"

  • "fake_marrakesh"

  • "fake_torino"

  • "fake_brisbane"

The fake devices are simulators but act as if they were the real devices. No token is needed for these devices.

An instance identifier (CRN or name) can be given. If not, the instance will be chosen according to the priority defined by IBM Quantum Platform.

IQM Resonance

Use IQM’s devices directly through Resonance.

Requirements: A valid IQM Resonance token, obtained from IQM Resonance. See Getting Started.

import qrunch as qc
from iqm.iqm_client import CircuitCompilationOptions

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .iqm_resonance(
        token="your-iqm-token",                   # IQM API token
        device="garnet",                          # IQM device name
        iqm_options=CircuitCompilationOptions(),  # Optional compilation options
    )
    .create()
)

The device can be one of IQM’s devices such as:

  • "emerald"

  • "garnet"

  • "sirius"

OQC Cloud - Oxford Quantum Circuit’s Cloud

Use Oxford Quantum Circuits quantum devices directly through OQC’s cloud. Includes optional error mitigation.

Requirements: an OQC API token, obtained from OQC.

import qrunch as qc
from qcaas_client.compiler_config import ErrorMitigationConfig

# Optional OQC error mitigation config:
config = ErrorMitigationConfig(enable_kickback_mitigation=True)

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .oqc_cloud(
        token="your-oqc-token",        # OQC API token
        device="OQC Toshiko Tokyo-1",  # OQC device name
        error_mitigation=config        # Optional OQC error mitigation to use.
    )
    .create()
)

The device can be one of OQC’s devices such as:

  • "OQC Toshiko Tokyo-1"

Local Quimb

Tensor-network-based simulation.

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .local_quimb(seed=242)
    .create()
)

Local Qulacs

High-performance C++ simulator.

import qrunch as qc

sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .local_qulacs()
    .create()
)

Microsoft Azure Quantum

This feature is under development. Contact Kvantify support for more information: support-qrunch@kvantify.dk.

Custom Backend

You can also provide your own custom backend. This can be useful when a backend has already been created through the Backend fluent creator.

import qrunch as qc

custom_backend = (
    qc.backend_creator()
    # .<pick-one-backend>(...)
    .create()
)
sampler = (
    qc.sampler_creator()
    .backend()
    .choose_backend()
    .custom(custom_backend)
    .create()
)

Verify the Result

  • The resulting sampler is now a backend-powered object, suitable for Adaptive VQE calculations.

See Also

Next Step