Skip to content

Add dt to GenericBackendV2 #13830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions qiskit/providers/fake_provider/generic_backend_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ def __init__(
control_flow: bool = False,
calibrate_instructions: bool | InstructionScheduleMap | None = None,
dtm: float | None = None,
dt: float | None = None,
seed: int | None = None,
pulse_channels: bool = True,
noise_info: bool = True,
Expand Down Expand Up @@ -579,6 +580,9 @@ def __init__(
dtm: System time resolution of output signals in nanoseconds.
None by default.

dt: System time resolution of input signals in nanoseconds.
None by default.

seed: Optional seed for generation of default values.

pulse_channels: DEPRECATED. If true, sets default pulse channel information on the backend.
Expand All @@ -596,6 +600,7 @@ def __init__(
self._sim = None
self._rng = np.random.default_rng(seed=seed)
self._dtm = dtm
self._dt = dt
self._num_qubits = num_qubits
self._control_flow = control_flow
self._calibrate_instructions = calibrate_instructions
Expand Down Expand Up @@ -788,15 +793,15 @@ def _build_generic_target(self):
self._target = Target(
description=f"Generic Target with {self._num_qubits} qubits",
num_qubits=self._num_qubits,
dt=properties["dt"],
dt=properties["dt"] if self._dt is None else self._dt,
qubit_properties=None,
concurrent_measurements=[list(range(self._num_qubits))],
)
else:
self._target = Target(
description=f"Generic Target with {self._num_qubits} qubits",
num_qubits=self._num_qubits,
dt=properties["dt"],
dt=properties["dt"] if self._dt is None else self._dt,
qubit_properties=[
QubitProperties(
t1=self._rng.uniform(properties["t1"][0], properties["t1"][1]),
Expand Down
12 changes: 12 additions & 0 deletions releasenotes/notes/add-dt-generic-backend-v2-822f8806517e5dd1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
features_providers:
- |
Added the ability to set the ``dt`` property of :class:`.GenericBackendV2` in the class initializer
with a new ``dt`` argument. Example usage::

from qiskit.providers.fake_provider import GenericBackendV2
backend = GenericBackendV2(
num_qubits=5,
basis_gates=["cx", "id", "rz", "sx", "x"],
dt= 2.22*e-10,
seed=42)
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,12 @@ def test_duration_defaults(self):
if inst not in ["delay", "reset"]:
self.assertGreaterEqual(duration, expected_durations[inst][0])
self.assertLessEqual(duration, expected_durations[inst][1])

def test_custom_dt(self):
"""Test that the custom dt is respected."""

ref_backend = GenericBackendV2(num_qubits=2, basis_gates=["cx", "id"], seed=42)
double_dt_backend = GenericBackendV2(
num_qubits=2, basis_gates=["cx", "id"], dt=ref_backend.dt * 2, seed=42
)
self.assertEqual(ref_backend.dt * 2, double_dt_backend.dt)