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.

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.Aria1

  • Devices.IonQ.Forte1

See https://docs.aws.amazon.com/braket/latest/developerguide/braket-devices.html

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"

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
    )
    .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.

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"

An IQM token is required to access IQM’s cloud.

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.

import qrunch as qc
from qcaas_client.compiler_config import ErrorMitigationConfig  # type: ignore

# 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"

An OQC token is required to access OQC’s cloud.

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