options and run_options for the Sampler and Estimator classes

The Sampler and Estimator classes provided in the Quantum Rings toolkit provide a way to provide additional configuration parameters as a dictionary and passed on as options or run_options parameters. Supported parameters are listed below.

Parameter

Options

Description

token

a string value

Your account’s API key. Downloaded it from the “Manage Keys” section from <https://portal.quantumrings.com>

name

a string value

Your account name. The e-mail ID with which you created your Quantum Rings Account.

backend

One of the following:
“scarlet_quantum_rings”
“amber_quantum_rings”
“serin_quantum_rings”

select from one of these three backends depending upon your installation

precision

“single” or “double”

The default is “single”. Select “double”, if you need high accuracy.

gpu

an integer >= 0

In a multiple GPU installation, you can provide the gpu_id to use. Usually, this is an integer >= 0, with 0 being the first GPU.

shots

an integer > 1

Sets the number of bitstrings to be sampled in the experiment

mode

“sync” or “async”

Selects whether to run the circuit in synchronous or asynchronous mode

performance

One of the following
“HIGHESTEFFICIENCY”
“BALANCEDACCURACY”
“HIGHESTACCURACY”
“AUTOMATIC”
“CUSTOM”

Selects an internal threshold value for permance. If “CUSTOM” then a threshold value is to be provided

threshold

an integer > 16

Sets the threshold value of performance is set to “CUSTOM”

transfer_to_cpu

True or False

If using a GPU mode, selecting this to False will keep the operation in the GPU mode while performing measurements.

generate_amplitude

True or False

If set, generates amplitudes for the measured bitstrings. Supported only in QrBackendV2.run method.
a file name must be provided.

file

a fully qualified string file name.

File for storing measurements and amplitudes. Supported only in QrBackendV2.run method.

max_threads

an integer > 1

Sets the maximum number of threads while performing measurements.
Supported only in QrBackendV2.run method.

The following code fragment is a practical illustration of how to use these settings in your own work.

# Obtain the API key and account name from the OS environment, assuming the user has set so.

import os
my_token = os.environ["QR_TOKEN"]
my_name = os.environ["QR_ACCOUNT"]
my_backend = "scarlet_quantum_rings"

from quantumrings.toolkit.qiskit import QrRuntimeService
from quantumrings.toolkit.qiskit import QrSamplerV2 as Sampler

qr_services = QrRuntimeService(name = my_name, token = my_token)
qr_backend = qr_services.backend(name = my_backend)

sampler=Sampler(backend = qr_backend, options={"shots": 100, "precision": "double"})

# Rest of the code

Another example illustrating the use in a QrBackendV2.run method is as follows.

import os

my_token = os.environ["QR_TOKEN"]
my_name = os.environ["QR_ACCOUNT"]
my_backend = "scarlet_quantum_rings"

from qiskit.circuit import QuantumCircuit
from qiskit import QuantumCircuit, transpile, QuantumRegister, ClassicalRegister, AncillaRegister
from qiskit.visualization import plot_histogram
from matplotlib import pyplot as plt

from quantumrings.toolkit.qiskit import QrBackendV2
backend = QrBackendV2(token = my_token, name = my_name, backend = my_backend, num_qubits = 12)

shots = 10000
numberofqubits = backend.num_qubits
q = QuantumRegister(numberofqubits , 'q')
c = ClassicalRegister(numberofqubits , 'c')
qc = QuantumCircuit(q, c)

# Create the GHZ state (Greenberger-Horne-Zeilinger)
qc.h(0);
for i in range (qc.num_qubits - 1):
    qc.cx(i, i + 1);

# Measure all qubits
qc.measure_all();

run_parameters = {"shots": shots, "precision":"double", "max_threads":10}
job = backend.run(qc, **run_parameters)
result = job.result()
counts = result.get_counts()
plot_histogram(counts)