QMBackend

class QMBackend(machine: QuamRoot, channel_mapping: Dict[QiskitChannel, QuAMChannel] | None = None, init_macro: Callable | None = None, qmm: QuantumMachinesManager | CloudQuantumMachinesManager | None = None, name: str | None = None, **fields)[source][source]

Bases: BackendV2

Qiskit backend for Quantum Machines (QuAM).

Represents at the Qiskit level all available operations and qubit properties of a Quantum Abstract Machine (QuAM) instance. The QuAM instance must expose active_qubits, active_qubit_pairs, and per-qubit/pair macros.

Initialize the QM backend.

Parameters:
  • machine – The QuAM instance to wrap.

  • channel_mapping – Optional mapping from Qiskit Pulse channels (DriveChannel, ControlChannel, MeasureChannel, …) to QuAM channels. Required for converting Pulse schedules into parametric QUA macros (Qiskit < 2.0; schedules must have fixed durations).

  • init_macro – Optional QUA macro invoked at the start of each program to initialize the QPU.

  • qmm – Optional QuantumMachinesManager or CloudQuantumMachinesManager. Inferred from the machine when omitted.

  • name – Optional backend name. Defaults to the network backend name or "QMBackend".

  • fields – Optional keyword overrides for default run options: shots (1024), compiler_options, simulate, memory (False), skip_reset (False), meas_level (MeasLevel.CLASSIFIED), meas_return (MeasReturnType.AVERAGE), timeout (60 seconds), and max_circuits (30).

property target: Target

A qiskit.transpiler.Target object for the backend.

Return type:

Target

property custom_instructions: Dict[str, Instruction]

Get the custom instructions for the backend (those that are part of the target but not in the standard Qiskit gate set, inferred from the available macros)

property qubit_dict: Dict[str, int]

Get the qubit dictionary for the backend

property qubit_pair_dict: Dict[str, Tuple[int, int]]

Get the qubit pair dictionary for the backend

get_qubit_index(qubit: str | Qubit) int[source][source]

Get the index of the given qubit or qubit name in Quam.

Parameters:

qubit – The qubit or qubit name

Returns:

The index of the given qubit or qubit name in Quam

get_qubit_pair_indices(qubit_pair: str | QubitPair) Tuple[int, int][source][source]

Get the indices of the given qubit pair or qubit pair name in Quam.

Parameters:

qubit_pair – The qubit pair or qubit pair name

Returns:

The indices of the given qubit pair or qubit pair name in Quam

get_qubit(qubit: int | str) Qubit[source][source]

Get the Qubit object for a qubit index or name.

Parameters:

qubit – Qubit index or name.

Returns:

The corresponding Qubit.

get_qubit_pair(qubits: Tuple[int | str | Qubit, int | str | Qubit]) QubitPair[source][source]

Get the QubitPair for two qubit indices or names.

Parameters:

qubits – Pair of qubit indices, names, or Qubit objects.

Returns:

The corresponding QubitPair.

property qubit_mapping: QubitsMapping

Build the qubit to quantum elements mapping for the backend. Should be of the form {qubit_index: (quantum_element1, quantum_element2, …)}

property qubit_index_dict

Returns a dictionary mapping qubit indices (Qiskit numbering) to corresponding Qubit objects (based on the active_qubits attribute of QuAM instance)

property qmm: QuantumMachinesManager | CloudQuantumMachinesManager

Returns the QuantumMachinesManager instance. Gets a new QuantumMachinesManager instance if none is already set.

property qm: QuantumMachine | CloudQuantumMachine

Returns the QuantumMachine instance. Gets a new QuantumMachine instance if none is already set, using the current QM config.

close_all_qms()[source][source]

Close all QuantumMachines managed by the QuantumMachinesManager

property qm_config: FullQuaConfig

Returns the QUA configuration for the backend

property max_circuits

Maximum number of circuits (or PUBs for Primitives) packed into a single QUA program.

backend.run, QMSamplerV2, and QMEstimatorV2 all split larger batches into several queued QUA programs whose results are stitched back transparently.

Must be a positive integer (>= 1). Defaults to 30. Can be updated at any time via backend.set_options(max_circuits=N).

property meas_map: List[List[int]]

Retrieve the measurement map for the backend.

run(run_input: QuantumCircuit | List[QuantumCircuit], **options) QMJob[source][source]

Run one or more QuantumCircuit objects on the QM backend.

This method now delegates the heavy lifting (circuit validation, compilation to QUA, job submission and result assembly) to the QMJob interface, keeping the public behaviour identical while centralising execution logic in the job layer.

Parameters:
  • run_input – The QuantumCircuit (or list thereof) to run on the backend.

  • options – Backend run options (shots, simulate, compiler options, etc.).

Returns:

A QMJob (or IQCCJob for cloud backends) instance.

update_target(input_type: InputType | None = None)[source][source]

Synchronize Target object with _operation_mapping_QUA.

This method performs a one-way sync from Target to _operation_mapping_QUA:

  1. Updates _operation_mapping_QUA from machine macros (incrementally).

  2. Syncs operations from Target to _operation_mapping_QUA, overwriting entries for the same OperationIdentifier.

  3. Updates the calibration mapping.

The sync is additive (never removes operations) and Target entries take precedence over machine macros for the same identifier.

Parameters:

input_type – Input type for converting parameterized instructions to QUA variables. Required when the Target contains parameterized pulse schedules.

quantum_circuit_to_qua(qc: QuantumCircuit, param_table: ParameterTable | Sequence[ParameterTable | Parameter] | Dict[str | QiskitParameter | Var, Scalar] | None = None) QuaCircuitCompilation[source][source]

Convert a QuantumCircuit to a QUA program fragment.

Can be called inside an existing with program(): block or standalone. When called standalone, access the generated program via result.qua_program or result.result_program.dsl_program.

Parameters:
  • qc – The circuit to compile.

  • param_table – Parameter mapping for real-time QUA variables. Required when the circuit contains symbolic parameters or classical inputs that must be streamed during execution.

Returns:

QuaCircuitCompilation wrapping the compilation result and wired measurement outputs.

property compiler: Compiler

The OpenQASM to QUA compiler.

connect() QuantumMachinesManager[source][source]

Connect to the Quantum Machines Manager

generate_config() FullQuaConfig[source][source]

Generate the configuration for the Quantum Machine

property init_macro: Callable

The macro to be called at the beginning of the QUA program

property qubits: List[Qubit]

Retrieve the list of active qubits of the machine

property qubit_pairs: List[QubitPair]

Retrieve the list of active qubit pairs of the machine

property qm_qasm_basis_gates: List[str]

Retrieve the list of OpenQASM 3 basis gates supported by the backend

property qasm3_exporter: Exporter

Retrieve the OpenQASM 3 exporter for the backend