From ab17095c9ff353a041fc5c11acde9dadcbd57b2f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 22:28:02 +0100 Subject: [PATCH] Round durations in `GenericBackendV2` (#11780) (#12079) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Round durations * Update generic_backend_v2.py * Clamp rounded durations (cherry picked from commit 35a8e5312147a537fc3ad635901621506a6ca007) Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --- .../fake_provider/generic_backend_v2.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/qiskit/providers/fake_provider/generic_backend_v2.py b/qiskit/providers/fake_provider/generic_backend_v2.py index 57a0b139c78..3776211cc08 100644 --- a/qiskit/providers/fake_provider/generic_backend_v2.py +++ b/qiskit/providers/fake_provider/generic_backend_v2.py @@ -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), } @@ -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)