qrmi.primitives package#
Subpackages#
Submodules#
qrmi.primitives.base_estimator module#
Estimator V2 base class for IBM QRMI
- class qrmi.primitives.base_estimator.Options(default_precision: float = 0.015625, run_options: dict = <factory>)[source]#
Bases:
objectOptions for :class:
~.QRMIBaseEstimatorV2.- default_precision: float = 0.015625#
The default precision to use if none are specified in :meth:
~run. Default: 0.015625 (1 / sqrt(4096)).
- run_options: dict#
Options passed to run.
- Type:
- class qrmi.primitives.base_estimator.QRMIBaseEstimatorV2(qrmi: QuantumResource, *, options: dict | None = None)[source]#
Bases:
BaseEstimatorV2Estimator V2 base class for IBM QRMI
- 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)[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.
qrmi.primitives.base_sampler module#
Sampler V2 base class for IBM QRMI
- class qrmi.primitives.base_sampler.Options(default_shots: int = 1024, run_options: dict = <factory>)[source]#
Bases:
objectOptions for :class:
~.QRMIBaseSamplerV2- default_shots: int = 1024#
The default shots to use if none are specified in :meth:
~.run. Default: 1024.
- run_options: dict#
Options passed to run.
- Type:
- class qrmi.primitives.base_sampler.QRMIBaseSamplerV2(qrmi: QuantumResource, *, options: dict | None = None)[source]#
Bases:
BaseSamplerV2Sampler V2 base class for IBM QRMI
- 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)[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.runtime_job_v2 module#
Runtime job
- class qrmi.primitives.runtime_job_v2.RuntimeJobV2(qrmi: QuantumResource, job_id: str, *, delete_job: bool = False)[source]#
Bases:
BasePrimitiveJob[PrimitiveResult,TaskStatus]Representation of a runtime V2 primitive exeuction.
qrmi.primitives.service module#
QRMI Service
QRMIService is now implemented in Rust and exposed here via the
qrmi._core extension module (re-exported from the top-level qrmi
package), rather than being implemented in pure Python in this file.
This module is kept as a thin re-export so that
from qrmi.primitives.service import QRMIService – the import path used
by earlier releases, when this module contained the actual implementation
– keeps working unchanged. New code should prefer importing from the
package instead: from qrmi.primitives import QRMIService or
from qrmi import QRMIService.
- class qrmi.primitives.service.QRMIService#
Bases:
objectPython wrapper for
QRMIService.Discovers the QPU resources assigned to the current job – read from the
QRMI_JOB_QPU_RESOURCES/QRMI_JOB_QPU_TYPESenvironment variables, or their legacySLURM_JOB_QPU_RESOURCES/SLURM_JOB_QPU_TYPESequivalents – and exposes the ones that are currently accessible asQuantumResourceinstances.This is a thin wrapper around the plain-Rust [
crate::QRMIService], which does the actual discovery/filtering and is usable on its own from Rust (see its docs for a Rust example). This wrapper’s job is only to bridge that to Python: it drivesQRMIService::new()’sFutureto completion on a private tokioRuntime(mirroringPyResourceProviderandPyQuantumResourceelsewhere in this module, sincepyo3classes can’t themselves beasync), then moves each resource returned byQRMIService::into_resource_map()into its own, independently ownedPyQuantumResource– exactly asPyResourceProvider::resources()does for eachBox<dyn QuantumResource>returned byResourceProvider::resources().# Example (Python)
from qrmi import QRMIService service = QRMIService() for resource in service.resources(): print(resource.resource_id()) resource = service.resource("ibm_torino")
- resource(resource_id)#
Returns a single resource matching the specified resource identifier.
# Arguments
resource_id- A resource identifier, i.e. backend name for IBM Quantum.
Returns
Noneif not found.
- resources()#
Returns all accessible QRMI resources.
Module contents#
QRMI primitives