QmioBackend

class qmiotools.integrations.qiskitqmio.QmioBackend(*args: Any, **kwargs: Any)

Bases: qiskit.providers.BackendV2

Backend to execute Jobs in Qmio QPU.

Parameters
  • calibration_file (Str or None) – full path to a calibration file. Default None and loads the last calibration file from the directory indicated by environment QMIO_CALIBRATIONS

  • logging_level (int) – flag to indicate the logging level. Better if use the logging package levels. Default logging.NOTSET

  • logging_filename (str) – Path to store the logging messages. Default None, i.e., output in stdout

  • tunnel_time_limit (str) – time limit user specified for stablish interactive tunnels (for example, “00:15:00” indicates a limit of 15 minutes)

  • reservation_name (str) – reservation name user specified

  • kwargs – Other parameters to pass to Qiskit qiskit.providers.BackendV2 class

It uses qmio.QmioRuntimeService to submit circuits to the QPU. By default, the calibrations are read from the last JSON file in the directory set by environ variable QMIO_CALIBRATIONS, but accepts a direct filename to use instead of.

Attention

The execution using the method run is synchronous.

To create a new backend use:

backend=QmioBackend()

It will print the file where the calibration were read in. If you want to use a specific calibrations file, use:

backend=QmioBackend(<file name>)

where <file name> is the path to the calibrations file that must be used. If the file is not found, it raises a exception.

Example:

from qiskit.circuit import QuantumCircuit
from qiskit import transpile
from qmiotools.integrations.qiskitqmio import QmioBackend

backend=QmioBackend() # loads the last calibration file from the directory $QMIO_CALIBRARTIONS

# Creates a circuit qwith 2 qubits
c=QuantumCircuit(2)
c.h(0)
c.h(0)
c.measure_all()

#Transpile the circuit using the optimization_level equal to 2
c=transpile(c,backend,optimization_level=2)

#Execute the circuit with 1000 shots. Must be executed from a node with a QPU.
job=backend.run(c,shots=1000)

#Return the results
print(job.result().get_counts())

Attributes

max_circuits
target

Methods

connect()

This method connect to the QPU. You do not need to connect, but you can if you want. If a connection exits, it is closed and the class is reconnected again

disconnect()

This method closes the connection with the QPU and destroy the QPUBackend instance. It is recommended to do it before exit the program

classmethod formats()

Returns the possible output formats supported by QMIO.

run(run_input: Union[qiskit.circuit.QuantumCircuit, qiskit.pulse.Schedule, qiskit.pulse.ScheduleBlock, str, List[Union[qiskit.circuit.QuantumCircuit, qiskit.pulse.Schedule, str]]], **options) qmiotools.integrations.qiskitqmio.qmiojob.QmioJob

Run on QMIO QPU. This method is Synchronous, so it will wait for the results from the QPU

Parameters
  • run_input (QuantumCircuit or Schedule or Str - a QASM string - or list) – An individual or a list of QuantumCircuit, or Schedule or a string with a QASM 2.0/3.0 objects to run on the backend.

  • options

    Any kwarg options to pass to the backend for running the config. If a key is also present in the options attribute/object then the expectation is that the value specified will be used instead of what’s set in the options object. Default options can be obtained with _default_options()

    Some specific options for Qmio are:

    • memory: if format is binary_counts (the defualt format), returns also all the sequence.

    • repetition_period, slot of time between shot starts (default, None. Uses the default that it is calibrated)

    • res_format, format for the output (default, ‘binary_count’. You can get the possible formats with formats())

    • output_qasm3, if convert the QuantumCircuit to OpenQASM 3.0 instead of OpenQASM 2.0 - default-)

Attention

When memory option is specified for binary_counts, take into account that the process of converting from raw data to shots is done by this class and not by Qmio QPU. The split is done using values less than 0 or grand than 0.

Returns

The job object for the run

Return type

QmioJob

Raises
  • QPUException – if there is one error in the QPU

  • QmioException – if there are errors in the input parameters.