Skip to content

Commit

Permalink
Fix noise model construction for a backend with no T2 value for a qub…
Browse files Browse the repository at this point in the history
…it (Qiskit#1912)

* Fix a bug failing to create device gate errors when t2==None while t1!=None for a qubit.

* Add reno

---------

Co-authored-by: Jun Doi <doichan@jp.ibm.com>
  • Loading branch information
itoko and doichanj authored Aug 25, 2023
1 parent d8beeab commit ada56a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qiskit_aer/noise/device/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ def _device_thermal_relaxation_error(

def _truncate_t2_value(t1, t2):
"""Return t2 value truncated to 2 * t1 (for t2 > 2 * t1)"""
if t1 is None or t2 is None:
if t1 is None:
return t2
elif t2 is None:
return 2 * t1
return min(t2, 2 * t1)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
fixes:
- |
Fixed a bug where :meth:`~.NoiseModel.from_backend` raises an error when
a backend reports no T2 value (while it reports T1 value) for a qubit,
which was an oversight in the previous fix on None handling:
`#1818 <https://github.com/Qiskit/qiskit-aer/issues/1818>`__.
Fixed `#1896 <https://github.com/Qiskit/qiskit-aer/issues/1896>`__.
7 changes: 7 additions & 0 deletions test/terra/noise/test_device_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ def test_basic_device_gate_errors_from_target_and_properties(self):
self.assertEqual(name1, name2)
self.assertEqual(tuple(qargs1), qargs2)
self.assertEqual(err1, err2)

def test_basic_device_gate_errors_from_target_with_no_t2_value(self):
"""Test if gate errors are successfully created from a target with qubits not reporting T2.
See https://github.com/Qiskit/qiskit-aer/issues/1896 for the details."""
target = FakeNairobiV2().target
target.qubit_properties[0].t2 = None
basic_device_gate_errors(target=target)

0 comments on commit ada56a3

Please sign in to comment.