Qmio

class qmiotools.integrations.tkbackend.Qmio(*args: Any, **kwargs: Any)

Bases: pytket.backends.Backend

A pytket Backend wrapping

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

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.

Create a new instance of the class

Attributes

backend_info
rebase_pass = {pytket.circuit.OpType.Rz, pytket.circuit.OpType.Measure, pytket.circuit.OpType.X, pytket.circuit.OpType.SX, pytket.circuit.OpType.Barrier, pytket.circuit.OpType.ECR}
required_predicates

The minimum set of predicates that a circuit must satisfy before it can be successfully run on this backend. :return: Required predicates. :rtype: List[Predicate]

Methods

circuit_status(handle: pytket.backends.ResultHandle) pytket.backends.CircuitStatus

Return a CircuitStatus reporting the status of the circuit execution corresponding to the ResultHandle

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

default_compilation_pass(optimisation_level: int = 1, options: Optional[Dict] = None, placement: Optional[Union[pytket.placement.Placement, Dict[int, int], Dict[pytket.unit_id.Qubit, pytket.unit_id.Node]]] = None) pytket.passes.BasePass

The basic compilation pass that produce a circuit with enough optimisation to run on Qmio.

Parameters
  • optimisation_level

    The level of optimisation to perform during compilation.

    • Level 0 decompose boxes, solves the device constraints without optimising and convert to the supported gates.

    • Level 1 additionally performs some light optimisations.

    • Level 2 adds more intensive optimisations that can increase compilation time for large circuits.

    Any optimisation level includes the options of the previous level. Defaults to 1.

  • options

  • placement – Selected placement for the execution.

Returns

Compilation pass guaranteeing required predicates.

disconnect()

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

draw_graph()

Using matplotlib and networkx, plots the current connectivity of Qmio.

process_circuit(circuit: pytket.Circuit, n_shots: Optional[int] = None, valid_check: bool = True, **kwargs: pytket.utils.results.KwargTypes) pytket.backends.ResultHandle
process_circuits(circuits: Iterable[pytket.Circuit], n_shots: Optional[int] = None, valid_check: bool = True, **kwargs: pytket.utils.results.KwargTypes) List[pytket.backends.ResultHandle]
run_circuit(circuit: pytket.Circuit, n_shots: Optional[int] = None, valid_check: bool = True, binary: bool = False, repetition_period: Optional[float] = None, **kwargs: pytket.utils.results.KwargTypes) pytket.backends.backendresult.BackendResult

Submits a circuit to the backend and returns results

Parameters
  • circuit – Circuit to be executed

  • n_shots – Number of shots. Default: 8192

  • valid_check – Flag to check if the circuit is valid before run

  • binary – Flag to ask for raw binary. Default False, returning the counts

  • repetition_period – Time between two executions of the circuit.

Returns

The results of the execution

Raises

QPUException. If the execution in the QPU fails, including a description of the exception raised by the QPU

run_circuits(circuits: Sequence[pytket.Circuit], n_shots: Optional[Union[int, Sequence[int]]] = None, valid_check: bool = True, binary: bool = False, repetition_period: Optional[int] = None, **kwargs: pytket.utils.results.KwargTypes) List[pytket.backends.backendresult.BackendResult]

Submits circuits to the backend and returns results

Parameters
  • circuits – Sequence of Circuits to be executed

  • n_shots – Passed on to Backend.process_circuits()

  • valid_check – Passed on to Backend.process_circuits()

  • binary – Flag to ask for raw binary. Default False, returning the counts

  • repetition_period – Time between two executions of the circuit.

Returns

List of results

Raises

QmioException