diff --git a/qiskit_ibm_runtime/base_primitive.py b/qiskit_ibm_runtime/base_primitive.py index f5f145547..db677acc0 100644 --- a/qiskit_ibm_runtime/base_primitive.py +++ b/qiskit_ibm_runtime/base_primitive.py @@ -34,7 +34,7 @@ from .runtime_job_v2 import RuntimeJobV2 from .ibm_backend import IBMBackend from .utils.default_session import get_cm_session -from .utils.deprecation import issue_deprecation_msg +from .utils.deprecation import issue_deprecation_msg, deprecate_function from .utils.utils import validate_isa_circuits, is_simulator from .constants import DEFAULT_DECODERS from .qiskit_runtime_service import QiskitRuntimeService @@ -178,6 +178,16 @@ def _run(self, pubs: Union[list[EstimatorPub], list[SamplerPub]]) -> RuntimeJobV inputs=primitive_inputs, ) + @property + def session(self) -> Optional[Session]: + """Return mode used by this primitive. + + Returns: + Mode used by this primitive, or ``None`` if session is not used. + """ + deprecate_function("session", "0.23.0", "Please use the 'mode' property instead.") + return self._mode + @property def mode(self) -> Optional[Session | Batch | str]: """Return the execution mode used by this primitive. diff --git a/qiskit_ibm_runtime/estimator.py b/qiskit_ibm_runtime/estimator.py index 5768d4b8e..a0c4361d9 100644 --- a/qiskit_ibm_runtime/estimator.py +++ b/qiskit_ibm_runtime/estimator.py @@ -115,13 +115,14 @@ def __init__( """Initializes the Estimator primitive. Args: - mode: The execution mode used to make the primitive query. It can be + mode: The execution mode used to make the primitive query. It can be: * A :class:`Backend` if you are using job mode. * A :class:`Session` if you are using session execution mode. * A :class:`Batch` if you are using batch execution mode. - Refer to the `Qiskit Runtime documentation `_. - for more information about the ``Execution modes``. + + Refer to the `Qiskit Runtime documentation `_. + for more information about the ``Execution modes``. backend: Backend to run the primitive. This can be a backend name or an :class:`IBMBackend` instance. If a name is specified, the default account (e.g. ``QiskitRuntimeService()``) diff --git a/qiskit_ibm_runtime/sampler.py b/qiskit_ibm_runtime/sampler.py index 5e91f51ae..bdef09548 100644 --- a/qiskit_ibm_runtime/sampler.py +++ b/qiskit_ibm_runtime/sampler.py @@ -73,13 +73,14 @@ def __init__( """Initializes the Sampler primitive. Args: - mode: The execution mode used to make the primitive query. It can be + mode: The execution mode used to make the primitive query. It can be: * A :class:`Backend` if you are using job mode. * A :class:`Session` if you are using session execution mode. * A :class:`Batch` if you are using batch execution mode. - Refer to the `Qiskit Runtime documentation `_. - for more information about the ``Execution modes``. + + Refer to the `Qiskit Runtime documentation `_. + for more information about the ``Execution modes``. backend: Backend to run the primitive. This can be a backend name or an :class:`IBMBackend` instance. If a name is specified, the default account (e.g. ``QiskitRuntimeService()``) @@ -87,6 +88,7 @@ def __init__( session: Session in which to call the primitive. + If both ``session`` and ``backend`` are specified, ``session`` takes precedence. If neither is specified, and the primitive is created inside a :class:`qiskit_ibm_runtime.Session` context manager, then the session is used. Otherwise if IBM Cloud channel is used, a default backend is selected.