qrmi.primitives.ibm package#

Submodules#

qrmi.primitives.ibm.backend module#

IBMBackend implementation with IBM QRMI

class qrmi.primitives.ibm.backend.QRMIBackend(qrmi: QuantumResource, **fields)[source]#

Bases: BackendV2

Backend class interfacing with an IBM Quantum backend.

check_faulty(circuit: QuantumCircuit) → None[source]#

Check if the input circuit uses faulty qubits or edges.

Parameters:

circuit – Circuit to check.

Raises:

ValueError – If an instruction operating on a faulty qubit or edge is found.

configuration() → QasmBackendConfiguration[source]#

Return the backend configuration.

Backend configuration contains fixed information about the backend, such as its name, number of qubits, basis gates, coupling map, quantum volume, etc.

The schema for backend configuration can be found in Qiskit/ibm-quantum-schemas/backend_configuration.

More details about backend configuration properties can be found here QasmBackendConfiguration.

IBM backends may also include the following properties:
  • supported_features: a list of strings of supported features like “qasm3”

    for dynamic circuits support.

  • parallel_compilation: a boolean of whether or not the backend can process multiple

    jobs at once. Parts of the classical computation will be parallelized.

Returns:

The configuration for the backend.

property dtm: float#

Return the system time resolution of output signals

Returns:

The output signal timestep in seconds.

Return type:

dtm

get_translation_stage_plugin() → str[source]#

Return the default translation stage plugin name for IBM backends.

property max_circuits: None#

This property used to return the max_experiments value from the backend configuration but this value is no longer an accurate representation of backend circuit limits. New fields will be added to indicate new limits.

property meas_map: List[List[int]]#

Return the grouping of measurements which are multiplexed

This is required to be implemented if the backend supports Pulse scheduling.

Returns:

The grouping of measurements which are multiplexed

Return type:

meas_map

properties(refresh: bool = False) → BackendProperties | None[source]#

Return the backend properties, subject to optional filtering.

This data describes qubits properties (such as T1 and T2), gates properties (such as gate length and error), and other general properties of the backend.

The schema for backend properties can be found in Qiskit/ibm-quantum-schemas/backend_properties.

Parameters:

refresh – If True, re-query the server for the backend properties. Otherwise, return a cached version.

Returns:

The backend properties or None if the backend properties are not currently available.

Raises:
  • TypeError – If an input argument is not of the correct type.

  • NotImplementedError – If datetime is specified when cloud runtime is used.

refresh() → None[source]#

Retrieve the newest backend configuration and refresh the current backend target.

run(*args, **kwargs) → None[source]#
Raises:

IBMBackendError – The run() method is no longer supported.

status() → BackendStatus[source]#

Return the backend status.

Returns:

The status of the backend.

property target: Target#

A :class:qiskit.transpiler.Target object for the backend.

Returns:

Target

qrmi.primitives.ibm.backend.get_backend(qrmi: QuantumResource, use_fractional_gates: bool | None = False) → Backend[source]#

Returns Qiskit transpiler target

Parameters:
  • qrmi – IBM QRMI object

  • use_fractional_gates – Whether to use native “fractional gates” on the device if available.

Returns:

Qiskit Transpiler target

Return type:

qiskit.transpiler.target.Target

qrmi.primitives.ibm.estimator module#

EstimatorV2 Primitive implementation with IBM QRMI

class qrmi.primitives.ibm.estimator.EstimatorV2(**kwargs)[source]#

Bases: QRMIBaseEstimatorV2

EstimatorV2 for QRMI

qrmi.primitives.ibm.executor module#

Executor and client-side SamplerV2 / EstimatorV2 on top of QRMI.

class qrmi.primitives.ibm.executor.Executor(mode: BackendV2 | QuantumResource, *, options: ExecutorOptions | dict | None = None)[source]#

Bases: object

Counterpart of qiskit_ibm_runtime.Executor that submits through QRMI.

run() takes a QuantumProgram (qiskit-ibm-runtime’s or samplomatic’s) and returns a job whose result() is a QuantumProgramResult (raw per-item arrays such as meas). The Sampler/Estimator wrappers additionally attach their post-processor to the job, so their jobs return a PrimitiveResult.

Parameters:
  • mode – A QRMIBackend (qrmi.primitives.ibm.get_backend(qrmi)) or a QRMI QuantumResource.

  • options – ExecutorOptions or a dict for it. Only execution and experimental are sent (same as Executor); job-level settings such as max_execution_time are governed by the QRMI resource configuration.

run(program: QuantumProgram | samplomatic.QuantumProgram) → ExecutorJob[source]#

Encode a quantum program as Executor input and submit it through QRMI.

Parameters:

program – A qiskit_ibm_runtime.quantum_program.QuantumProgram or a samplomatic.QuantumProgram.

Returns:

A job whose result() is a QuantumProgramResult.

class qrmi.primitives.ibm.executor.ExecutorEstimator(mode: BackendV2 | QuantumResource, *, options: EstimatorOptions | dict | None = None)[source]#

Bases: BaseEstimatorV2

EstimatorV2 that runs via the IBM executor program through QRMI.

Pre-processing (twirling, ZNE gate folding, PEC/PEA noise injection, TREX, DD) and post-processing (expectation values, ZNE extrapolation, …) are done client-side by qiskit-ibm-runtime’s executor_estimator.

Parameters:
  • mode – A QRMIBackend (qrmi.primitives.ibm.get_backend(qrmi)), or a QRMI QuantumResource. With a bare resource, the backend (needed only for dynamical decoupling timing) is created on first use via get_backend(qrmi).

  • options – EstimatorOptions or a dict for it.

run(pubs: Iterable[EstimatorPub | tuple[QuantumCircuit, str | Pauli | SparsePauliOp | SparseObservable | Mapping[str | Pauli, float] | ArrayLike] | tuple[QuantumCircuit, str | Pauli | SparsePauliOp | SparseObservable | Mapping[str | Pauli, float] | ArrayLike, Mapping[Parameter | str | tuple[Parameter | str, ...], ArrayLike]] | tuple[QuantumCircuit, str | Pauli | SparsePauliOp | SparseObservable | Mapping[str | Pauli, float] | ArrayLike, Mapping[Parameter | str | tuple[Parameter | str, ...], ArrayLike], Real]], *, precision: float | None = None) → ExecutorJob[source]#

Estimate expectation values for each provided pub (Primitive Unified Bloc).

Parameters:
  • pubs – An iterable of pub-like objects, such as tuples (circuit, observables) or (circuit, observables, parameter_values).

  • precision – The target precision for expectation value estimates of each run Estimator Pub that does not specify its own precision. If None the estimator’s default precision value will be used.

Returns:

A job object that contains results.

class qrmi.primitives.ibm.executor.ExecutorJob(qrmi: QuantumResource, job_id: str, poll_interval: float = 1.0, post_processor: type[BaseClientSideResultDecoder] | None = None)[source]#

Bases: BasePrimitiveJob[Any, JobStatus]

Job handle for an Executor job submitted through QRMI.

cancel() → None[source]#

Attempt to cancel the job.

cancelled() → bool[source]#

Return whether the job has been cancelled.

done() → bool[source]#

Return whether the job has successfully run.

errored() → bool[source]#

Return whether the job has failed.

in_final_state() → bool[source]#

Return whether the job is in a final job state such as DONE or ERROR.

logs() → str[source]#

Return the job logs from the QRMI resource.

Returns:

The log text of the job.

result() → Any[source]#

QuantumProgramResult (plain Executor) or PrimitiveResult (Sampler/Estimator).

running() → bool[source]#

Return whether the job is actively running.

status() → JobStatus[source]#

Return the status of the job.

class qrmi.primitives.ibm.executor.ExecutorSampler(mode: BackendV2 | QuantumResource, *, options: SamplerOptions | dict | None = None)[source]#

Bases: BaseSamplerV2

SamplerV2 that runs via the IBM executor program through QRMI.

Parameters:
  • mode – A QRMIBackend (qrmi.primitives.ibm.get_backend(qrmi)), or a QRMI QuantumResource. With a bare resource, the backend (needed only for dynamical decoupling timing) is created on first use via get_backend(qrmi).

  • options – SamplerOptions or a dict for it (same options as qiskit_ibm_runtime.executor_sampler.Sampler).

run(pubs: Iterable[SamplerPub | QuantumCircuit | tuple[QuantumCircuit] | tuple[QuantumCircuit, Mapping[Parameter | str | tuple[Parameter | str, ...], ArrayLike]] | tuple[QuantumCircuit, Mapping[Parameter | str | tuple[Parameter | str, ...], ArrayLike], Integral | None]], *, shots: int | None = None) → ExecutorJob[source]#

Run and collect samples from each pub.

Parameters:
  • pubs – An iterable of pub-like objects. For example, a list of circuits or tuples (circuit, parameter_values).

  • shots – The total number of shots to sample for each sampler pub that does not specify its own shots. If None, the primitive’s default shots value will be used, which can vary by implementation.

Returns:

The job object of Sampler’s result.

qrmi.primitives.ibm.sampler module#

SamplerV2 Primitive implementation with IBM QRMI

class qrmi.primitives.ibm.sampler.SamplerV2(**kwargs)[source]#

Bases: QRMIBaseSamplerV2

SamplerV2 for QRMI

qrmi.primitives.ibm.target module#

Qiskit Target creation

qrmi.primitives.ibm.target.get_target(qrmi: QuantumResource) → Target[source]#

Returns Qiskit transpiler target

Parameters:

qrmi – IBM QRMI object

Returns:

Qiskit Transpiler target

Return type:

qiskit.transpiler.target.Target

Module contents#

IBM implementations of Primitive