Skip to content

Commit

Permalink
Fix GenericBackendV2 duration tests (#12136)
Browse files Browse the repository at this point in the history
* Round fallback values and adjust test to rounded values

* Remove duplicate key in test dict

(cherry picked from commit f76f692)
  • Loading branch information
ElePT authored and mergify[bot] committed Apr 4, 2024
1 parent 770a86b commit 1b19b9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions qiskit/providers/fake_provider/generic_backend_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@

# Fallback values for gates with unknown noise default ranges.
_NOISE_DEFAULTS_FALLBACK = {
"1-q": (3e-8, 6e-8, 9e-5, 1e-4),
"multi-q": (8e-8, 9e-7, 1e-5, 5e-3),
"1-q": (2.997e-08, 5.994e-08, 9e-5, 1e-4),
"multi-q": (7.992e-08, 8.99988e-07, 5e-3),
}

# Ranges to sample qubit properties from.
Expand Down
29 changes: 15 additions & 14 deletions test/python/providers/fake_provider/test_generic_backend_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,20 @@ def test_duration_defaults(self):

basis_gates = ["cx", "id", "rz", "sx", "x", "sdg", "rxx"]
expected_durations = {
"cx": (8e-8, 9e-7),
"id": (3e-8, 6e-8),
"cx": (7.992e-08, 8.99988e-07),
"id": (2.997e-08, 5.994e-08),
"rz": (0.0, 0.0),
"sx": (3e-8, 6e-8),
"x": (3e-8, 6e-8),
"measure": (7e-7, 1.5e-6),
"sdg": (3e-8, 6e-8),
"rxx": (8e-8, 9e-7),
"sx": (2.997e-08, 5.994e-08),
"x": (2.997e-08, 5.994e-08),
"measure": (6.99966e-07, 1.500054e-06),
"sdg": (2.997e-08, 5.994e-08),
"rxx": (7.992e-08, 8.99988e-07),
}
target = GenericBackendV2(num_qubits=2, basis_gates=basis_gates).target
for inst in target:
for qargs in target.qargs_for_operation_name(inst):
duration = target[inst][qargs].duration
if inst not in ["delay", "reset"]:
self.assertGreaterEqual(duration, expected_durations[inst][0])
self.assertLessEqual(duration, expected_durations[inst][1])
for _ in range(20):
target = GenericBackendV2(num_qubits=2, basis_gates=basis_gates).target
for inst in target:
for qargs in target.qargs_for_operation_name(inst):
duration = target[inst][qargs].duration
if inst not in ["delay", "reset"]:
self.assertGreaterEqual(duration, expected_durations[inst][0])
self.assertLessEqual(duration, expected_durations[inst][1])

0 comments on commit 1b19b9a

Please sign in to comment.