Skip to content

Commit 6817445

Browse files
authored
Update SingleTransmonTestBackend for Qiskit Dynamics 0.5.0 (#1427)
Dynamics 0.5.0 changed the arguments it expects for Solver and underlying models. In particular, instead of `evaluation_mode`, `array_library` and `vectorized` are expected. See https://qiskit-extensions.github.io/qiskit-dynamics/release_notes.html#release-notes-0-5-0
1 parent 428c9bc commit 6817445

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

qiskit_experiments/test/pulse_backend.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
"""A Pulse simulation backend based on Qiskit-Dynamics"""
1414

1515
import datetime
16+
import importlib.metadata
17+
from functools import cached_property
1618
from itertools import chain
1719
from typing import Any, Dict, List, Optional, Tuple, Union
1820

1921
import numpy as np
22+
from packaging.version import Version
2023

2124
from qiskit import QuantumCircuit
2225
from qiskit.circuit import CircuitInstruction
@@ -510,10 +513,25 @@ def __init__(
510513
self.rabi_rate_12 = 6.876
511514

512515
if noise is True:
513-
evaluation_mode = "dense_vectorized"
516+
if self._dynamics_ge_05:
517+
solver_args = {
518+
"array_library": "numpy",
519+
"vectorized": True,
520+
}
521+
else:
522+
solver_args = {
523+
"evaluation_mode": "dense_vectorized",
524+
}
514525
static_dissipators = [t1_dissipator]
515526
else:
516-
evaluation_mode = "dense"
527+
if self._dynamics_ge_05:
528+
solver_args = {
529+
"array_library": "numpy",
530+
}
531+
else:
532+
solver_args = {
533+
"evaluation_mode": "dense",
534+
}
517535
static_dissipators = None
518536

519537
super().__init__(
@@ -523,9 +541,9 @@ def __init__(
523541
rotating_frame=r_frame,
524542
rwa_cutoff_freq=1.9 * qubit_frequency,
525543
rwa_carrier_freqs=[qubit_frequency],
526-
evaluation_mode=evaluation_mode,
527544
atol=atol,
528545
rtol=rtol,
546+
**solver_args,
529547
**kwargs,
530548
)
531549

@@ -614,3 +632,9 @@ def __init__(
614632
self._simulated_pulse_unitaries = {
615633
(schedule.name, (0,), ()): self.solve(schedule, (0,)) for schedule in default_schedules
616634
}
635+
636+
@cached_property
637+
def _dynamics_ge_05(self):
638+
"""True if installed version of qiskit-dynamics>=0.5.0.dev0"""
639+
dyn_version = Version(importlib.metadata.distribution("qiskit-dynamics").version)
640+
return dyn_version > Version("0.5.0.dev0")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
:class:`.SingleTransmonTestBackend` was updated to be compatible with
5+
:mod:`qiskit_dynamics` version 0.5.0. The updates accounted for changes in
6+
the expected arguments to Dynamics API's and did not change behavior. See
7+
`#1427
8+
<https://github.com/Qiskit-Extensions/qiskit-experiments/pull/1427>`__.

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ uncertainties
77
lmfit
88
rustworkx
99
pandas>=1.1.5
10+
packaging

0 commit comments

Comments
 (0)