Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto noise-learner2
  • Loading branch information
SamFerracin committed Aug 1, 2024
2 parents f2eca26 + 6355798 commit bbb593d
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 46 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.26.0'
release = '0.27.0'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.26.0
0.27.0
28 changes: 28 additions & 0 deletions qiskit_ibm_runtime/base_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,38 @@ def _get_mode_service_backend(
if isinstance(mode, (Session, Batch)):
return mode, mode.service, mode._backend
elif isinstance(mode, IBMBackend): # type: ignore[unreachable]
if get_cm_session():
warnings.warn(
(
"Passing a backend as the mode currently runs the job in job mode even "
"if inside of a session/batch context manager. As of qiskit-ibm-runtime "
"version 0.26.0, this behavior is deprecated and in a future "
"release no sooner than than 3 months "
"after the release date, the session/batch will take precendence and "
"the job will not run in job mode. To ensure that jobs are run in session/batch "
"mode, pass in the session/batch or leave the mode parameter emtpy."
),
DeprecationWarning,
stacklevel=4,
)
return None, mode.service, mode
elif isinstance(mode, (BackendV1, BackendV2)):
return None, QiskitRuntimeLocalService(), mode
elif isinstance(mode, str):
if get_cm_session():
warnings.warn(
(
"Passing a backend as the mode currently runs the job in job mode even "
"if inside of a session/batch context manager. As of qiskit-ibm-runtime "
"version 0.26.0, this behavior is deprecated and in a future "
"release no sooner than than 3 months "
"after the release date, the session/batch will take precendence and "
"the job will not run in job mode. To ensure that jobs are run in session/batch "
"mode, pass in the session/batch or leave the mode parameter emtpy."
),
DeprecationWarning,
stacklevel=4,
)
service = (
QiskitRuntimeService()
if QiskitRuntimeService.global_service is None
Expand Down
52 changes: 52 additions & 0 deletions release-notes/0.26.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
0.26.0 (2024-07-31)
===================

Deprecation Notes
-----------------

- Passing in a backend as a string into ``Session``, ``Batch``, ``EstimatorV2``, and ``SamplerV2``
has been deprecated. Use the actual backend object instead. (`1804 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1804>`__)
- Passing a backend as the mode in :class:`SamplerV2` and :class:`EstimatorV2`
currently runs a job in job mode even if inside of a :class:`Session` or
:class:`Batch` context manager. This behavior is deprecated and in a future release
the the Session/Batch will take precedence. (`1816 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1816>`__)
- Passing in ``service`` in ``Session``, ``Batch``
has been deprecated. The ``service`` parameter is no longer necessary because the service
can be extracted from the backend. (`1826 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1826>`__)


New Features
------------

- The methods ``properties``, ``defaults``, ``configuration``,
and ``check_faulty`` have been added to :class:`FakeBackendV2`. (`1765 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1765>`__)
- If jobs are run in a session created with :meth:`QiskitRuntimeService.Session.from_id` where the
session is already closed, the jobs are rejected immediately. (`1780 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1780>`__)
- The input parameters for jobs will no longer be cached. These parameters can include large circuits
and should not be automatically kept in memory. (`1783 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1783>`__)
- :class:`QiskitRuntimeLocalService` was created to support a local
testing mode. To avoid having to initialize a separate class, "local"
has been added as a valid :class:`QiskitRuntimeService` channel.

.. code-block:: python
service = QiskitRuntimeService(channel="local")
will return a :class:`QiskitRuntimeLocalService` instance. (`1793 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1793>`__)
- When running jobs on the open plan, there will now be a warning if the limit for the
maximum number of pending jobs has been reached. The service will also attempt to wait
for the oldest pending jobs to finish running before submitting a new job. (`1794 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1794>`__)
- Added :class:`NoiseLearner` and related functionality, such as
:class:`NoiseLearnerOptions` and :class:`NoiseLearnerResults`. (`1805 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1805>`__)


Bug Fixes
---------

- Every circuit is checked to be ISA compliant. As part of this check, an error is raised if instructions that are not supported by the backend are detected. Previously, a bug caused some of the instructions to be skipped (those that reside inside bodies of control flow operations). We have fixed the bug in this release. (`1784 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1784>`__)
- Fixed an issue where calling :meth:`IBMBackend.target_history` would cache the backend target and
then calling :meth:`IBMBackend.target` would incorrectly return that cached target. (`1791 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1791>`__)
- The options validation for checking if ``zne_mitigation`` or ``pec_mitigation`` are set
to ``True`` when using other related options has been removed. (`1792 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1792>`__)
- Fixed an issue where users were unable to retrieve job results if
the python library ``simplejson`` was installed in their environment. (`1800 <https://github.com/Qiskit/qiskit-ibm-runtime/pull/1800>`__)
2 changes: 0 additions & 2 deletions release-notes/unreleased/1765.feat.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1780.feat.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1783.feat.rst

This file was deleted.

1 change: 0 additions & 1 deletion release-notes/unreleased/1784.bug.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1791.bug.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1792.bug.rst

This file was deleted.

8 changes: 0 additions & 8 deletions release-notes/unreleased/1793.feat.rst

This file was deleted.

3 changes: 0 additions & 3 deletions release-notes/unreleased/1794.feat.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1800.bug.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1804.deprecation.rst

This file was deleted.

2 changes: 0 additions & 2 deletions release-notes/unreleased/1805.feat.rst

This file was deleted.

4 changes: 0 additions & 4 deletions release-notes/unreleased/1816.deprecation.rst

This file was deleted.

3 changes: 0 additions & 3 deletions release-notes/unreleased/1826.deprecation.rst

This file was deleted.

22 changes: 13 additions & 9 deletions test/integration/test_noise_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""Integration tests for NoiseLearner."""

from copy import deepcopy
from unittest import SkipTest
import numpy as np

from qiskit.circuit import QuantumCircuit
Expand All @@ -33,7 +34,10 @@ class TestIntegrationNoiseLearner(IBMIntegrationTestCase):

def setUp(self) -> None:
super().setUp()
self.backend = "test_eagle"
try:
self.backend = self.service.backend("test_eagle")
except:
raise SkipTest("test_eagle not available in this environment")

c1 = QuantumCircuit(2)
c1.cx(0, 1)
Expand All @@ -55,9 +59,9 @@ def setUp(self) -> None:
}

@run_integration_test
def test_with_default_options(self, service):
def test_with_default_options(self, service): # pylint: disable=unused-argument
"""Test noise learner with default options."""
backend = service.backend(self.backend)
backend = self.backend

options = NoiseLearnerOptions()
learner = NoiseLearner(mode=backend, options=options)
Expand All @@ -68,9 +72,9 @@ def test_with_default_options(self, service):
self._verify(job, self.default_input_options)

@run_integration_test
def test_with_non_default_options(self, service):
def test_with_non_default_options(self, service): # pylint: disable=unused-argument
"""Test noise learner with non-default options."""
backend = service.backend(self.backend)
backend = self.backend

options = NoiseLearnerOptions()
options.max_layers_to_learn = 1
Expand All @@ -88,7 +92,7 @@ def test_with_non_default_options(self, service):
@run_integration_test
def test_in_session(self, service):
"""Test noise learner when used within a session."""
backend = service.backend(self.backend)
backend = self.backend

options = NoiseLearnerOptions()
options.max_layers_to_learn = 1
Expand Down Expand Up @@ -116,9 +120,9 @@ def test_in_session(self, service):
self._verify(job2, input_options)

@run_integration_test
def test_with_no_layers(self, service):
def test_with_no_layers(self, service): # pylint: disable=unused-argument
"""Test noise learner when `max_layers_to_learn` is `0`."""
backend = service.backend(self.backend)
backend = self.backend

options = NoiseLearnerOptions()
options.max_layers_to_learn = 0
Expand Down Expand Up @@ -154,7 +158,7 @@ def _verify(self, job: RuntimeJob, expected_input_options: dict) -> None:
self.assertEqual(len(generators), len(rates))

metadata = deepcopy(result.metadata)
self.assertEqual(metadata.pop("backend", None), self.backend)
self.assertEqual(metadata.pop("backend", None), self.backend.name)
for key, val in expected_input_options.items():
metadatum = metadata["input_options"].pop(key, None)
self.assertEqual(val, metadatum)
Expand Down

0 comments on commit bbb593d

Please sign in to comment.