-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from Qiskit-Partners/update_faulty_qubits
[WIP] Relax faulty qubit checking
- Loading branch information
Showing
4 changed files
with
89 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,4 @@ mthree/version.py | |
docs/*.json | ||
docs/stubs/* | ||
docs/tutorials/ | ||
bad_cals.json |
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,53 @@ | ||
# This code is part of Mthree. | ||
# | ||
# (C) Copyright IBM 2023. | ||
# | ||
# 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. | ||
# pylint: disable=no-name-in-module | ||
|
||
"""Test faulty qubits handling""" | ||
import numpy as np | ||
import pytest | ||
|
||
import mthree | ||
|
||
|
||
def test_faulty_logic(): | ||
"""Test faulty qubits block correction""" | ||
|
||
mit = mthree.M3Mitigation(None) | ||
mit.single_qubit_cals = [np.array([[0.9819, 0.043], | ||
[0.0181, 0.957]]), | ||
np.array([[0.4849, 0.5233], | ||
[0.5151, 0.4767]]), | ||
np.array([[0.9092, 0.4021], | ||
[0.0908, 0.5979]]), | ||
np.array([[0.4117, 0.8101], | ||
[0.5883, 0.1899]])] | ||
mit.faulty_qubits = [1, 3] | ||
counts = {"00": 0.4, "01": 0.1, "11": 0.5} | ||
with pytest.raises(mthree.exceptions.M3Error) as _: | ||
_ = mit.apply_correction(counts, qubits=[3, 2]) | ||
|
||
|
||
def test_faulty_io(): | ||
"""Check round-tripping IO still has faulty qubits""" | ||
mit = mthree.M3Mitigation(None) | ||
mit.single_qubit_cals = [np.array([[0.9819, 0.043], | ||
[0.0181, 0.957]]), | ||
np.array([[0.4849, 0.5233], | ||
[0.5151, 0.4767]]), | ||
np.array([[0.9092, 0.4021], | ||
[0.0908, 0.5979]]), | ||
np.array([[0.4117, 0.8101], | ||
[0.5883, 0.1899]])] | ||
mit.cals_to_file('bad_cals.json') | ||
mit2 = mthree.M3Mitigation(None) | ||
mit2.cals_from_file('bad_cals.json') | ||
assert mit2.faulty_qubits == [1, 3] |
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 |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
from Cython.Build import cythonize | ||
|
||
MAJOR = 2 | ||
MINOR = 2 | ||
MINOR = 3 | ||
MICRO = 0 | ||
|
||
ISRELEASED = False | ||
|