forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate measure mitigation from ignis for QuantumInstance
This commit migrates the measurement mitigation code from qiskit-ignis into qiskit-terra for use with the QuantumInstance class. The QuantumInstance class's usage of the measurement mitigation from ignis is the one thing blocking us from deprecating qiskit-ignis completely. By embedding the code the quantum instance depends on inside qiskit.utils users of QuantumInstance (and therefore qiskit.algorithms) can construct and use measurement mitigation in it's current form. The use of this migrated module is only supported for use with the QuantumInstance class and is explicitly documented as internal/private except for how it gets used by the QuantumInstance. There is ongoing work to create a standardized mitigation API in Qiskit#6485 and Qiskit#6748, this does not preclude that work, but we should adapt this as part of those efforts to use the standardized interface. Ideally this would have been made a private interface and not exposed it as user facing (in deference to the standardization effort), but unfortunately the QuantumInstance expects classes of these classes as it's public interface for selecting a mitigation technique which means users need to be able to use the classes. However, as only the classes are public interfaces we can adapt this as we come up with a standardized mitigation interface and rewrite the internals of this and how the QuantumInstance leverages mitigators to use the new interface. A good follow-up here would be to adapt the mitigator selection kwarg to deprecate the use of classes and then we can make things explicitly private in the migrated code and wait for Qiskit#6495 and Qiskit#6748 to be ready for our user facing API. I opted to not include that in this PR to minimize changes to just what we migrated from ignis and update usage of old ignis classes to rely on the migrated version.
- Loading branch information
Showing
14 changed files
with
2,215 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. _qiskit-utils-mitigation: | ||
|
||
.. automodule:: qiskit.utils.mitigation | ||
:no-members: | ||
:no-inherited-members: | ||
:no-special-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# This code is part of Qiskit. | ||
# | ||
# (C) Copyright IBM 2019. | ||
# | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
# This code was originally copied from the qiskit-ignis repsoitory see: | ||
# https://github.com/Qiskit/qiskit-ignis/blob/b91066c72171bcd55a70e6e8993b813ec763cf41/qiskit/ignis/mitigation/measurement/__init__.py | ||
# it was migrated as qiskit-ignis is being deprecated | ||
|
||
""" | ||
============================================================= | ||
Measurement Mitigation Utils (:mod:`qiskit.utils.mitigation`) | ||
============================================================= | ||
.. currentmodule:: qiskit.utils.mitigation | ||
Measurement correction | ||
====================== | ||
The measurement calibration is used to mitigate measurement errors. | ||
The main idea is to prepare all :math:`2^n` basis input states and compute | ||
the probability of measuring counts in the other basis states. | ||
From these calibrations, it is possible to correct the average results | ||
of another experiment of interest. These tools are intended for use solely | ||
with the :class:`~qiskit.utils.QuantumInstance` class as part of | ||
:mod:`qiskit.algorithms` and :mod:`qiskit.opflow`. | ||
.. warning:: | ||
The user facing API stability of this module is not guaranteed except for | ||
their use with the :class:`~qiskit.utils.QuantumInstance` (ie using the | ||
:class:`~qiskit.utils.mitigation.CompleteMeasFitter` or | ||
:class:`~qiskit.utils.mitigation.TensoredMeasFitter` class as values for the | ||
``meas_error_mitigation_cls``). The rest of this module should be treated as | ||
an internal private API that can not be relied upon. | ||
.. autosummary:: | ||
:toctree: ../stubs/ | ||
CompleteMeasFitter | ||
TensoredMeasFitter | ||
""" | ||
|
||
# Measurement correction functions | ||
from .circuits import complete_meas_cal, tensored_meas_cal | ||
from .filters import MeasurementFilter, TensoredFilter | ||
from .fitters import CompleteMeasFitter, TensoredMeasFitter |
Oops, something went wrong.