diff --git a/qiskit_experiments/test/pulse_backend.py b/qiskit_experiments/test/pulse_backend.py index 70267440fc..5b6ea600f9 100644 --- a/qiskit_experiments/test/pulse_backend.py +++ b/qiskit_experiments/test/pulse_backend.py @@ -13,10 +13,13 @@ """A Pulse simulation backend based on Qiskit-Dynamics""" import datetime +import importlib.metadata +from functools import cached_property from itertools import chain from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np +from packaging.version import Version from qiskit import QuantumCircuit from qiskit.circuit import CircuitInstruction @@ -510,10 +513,25 @@ def __init__( self.rabi_rate_12 = 6.876 if noise is True: - evaluation_mode = "dense_vectorized" + if self._dynamics_ge_05: + solver_args = { + "array_library": "numpy", + "vectorized": True + } + else: + solver_args = { + "evaluation_mode": "dense_vectorized", + } static_dissipators = [t1_dissipator] else: - evaluation_mode = "dense" + if self._dynamics_ge_05: + solver_args = { + "array_library": "numpy", + } + else: + solver_args = { + "evaluation_mode": "dense", + } static_dissipators = None super().__init__( @@ -523,9 +541,9 @@ def __init__( rotating_frame=r_frame, rwa_cutoff_freq=1.9 * qubit_frequency, rwa_carrier_freqs=[qubit_frequency], - evaluation_mode=evaluation_mode, atol=atol, rtol=rtol, + **solver_args, **kwargs, ) @@ -614,3 +632,9 @@ def __init__( self._simulated_pulse_unitaries = { (schedule.name, (0,), ()): self.solve(schedule, (0,)) for schedule in default_schedules } + + @cached_property + def _dynamics_ge_05(self): + """True if installed version of qiskit-dynamics>=0.5.0.dev0""" + dyn_version = Version(importlib.metadata.distribution("qiskit-dynamics").version) + return dyn_version > Version("0.5.0.dev0") diff --git a/releasenotes/notes/dynamics-0.5-0da56d1ef7d93e77.yaml b/releasenotes/notes/dynamics-0.5-0da56d1ef7d93e77.yaml new file mode 100644 index 0000000000..527ce8f332 --- /dev/null +++ b/releasenotes/notes/dynamics-0.5-0da56d1ef7d93e77.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + :class:`.SingleTransmonTestBackend` was updated to be compatible with + :mod:`qiskit_dynamics` version 0.5.0. The updates accounted for changes in + the expected arguments to Dynamics API's and did not change behavior. See + `#1427 + `__.