Skip to content

Commit

Permalink
Round durations in GenericBackendV2 (Qiskit#11780)
Browse files Browse the repository at this point in the history
* Round durations

* Update generic_backend_v2.py

* Clamp rounded durations
  • Loading branch information
ElePT authored Mar 25, 2024
1 parent 40e654f commit 35a8e53
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions qiskit/providers/fake_provider/generic_backend_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
# if the defaults are ranges.
# - (duration, error), if the defaults are fixed values.
_NOISE_DEFAULTS = {
"cx": (8e-8, 9e-7, 1e-5, 5e-3),
"ecr": (8e-8, 9e-7, 1e-5, 5e-3),
"cz": (8e-8, 9e-7, 1e-5, 5e-3),
"id": (3e-8, 6e-8, 9e-5, 1e-4),
"cx": (7.992e-08, 8.99988e-07, 1e-5, 5e-3),
"ecr": (7.992e-08, 8.99988e-07, 1e-5, 5e-3),
"cz": (7.992e-08, 8.99988e-07, 1e-5, 5e-3),
"id": (2.997e-08, 5.994e-08, 9e-5, 1e-4),
"rz": (0.0, 0.0),
"sx": (3e-8, 6e-8, 9e-5, 1e-4),
"x": (3e-8, 6e-8, 9e-5, 1e-4),
"measure": (7e-7, 1.5e-6, 1e-5, 5e-3),
"sx": (2.997e-08, 5.994e-08, 9e-5, 1e-4),
"x": (2.997e-08, 5.994e-08, 9e-5, 1e-4),
"measure": (6.99966e-07, 1.500054e-06, 1e-5, 5e-3),
"delay": (None, None),
"reset": (None, None),
}
Expand Down Expand Up @@ -424,6 +424,12 @@ def _add_noisy_instruction_to_target(
)
else:
calibration_entry = None
if duration is not None and len(noise_params) > 2:
# Ensure exact conversion of duration from seconds to dt
dt = _QUBIT_PROPERTIES["dt"]
rounded_duration = round(duration / dt) * dt
# Clamp rounded duration to be between min and max values
duration = max(noise_params[0], min(rounded_duration, noise_params[1]))
props.update({qargs: InstructionProperties(duration, error, calibration_entry)})
self._target.add_instruction(instruction, props)

Expand Down

0 comments on commit 35a8e53

Please sign in to comment.