Skip to content

Commit

Permalink
Update SingleTransmonTestBackend for Qiskit Dynamics 0.5.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wshanks committed Mar 21, 2024
1 parent 428c9bc commit a4ffcfb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
30 changes: 27 additions & 3 deletions qiskit_experiments/test/pulse_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__(
Expand All @@ -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,
)

Expand Down Expand Up @@ -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")
8 changes: 8 additions & 0 deletions releasenotes/notes/dynamics-0.5-0da56d1ef7d93e77.yaml
Original file line number Diff line number Diff line change
@@ -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
<https://github.com/Qiskit-Extensions/qiskit-experiments/pull/1427>`__.

0 comments on commit a4ffcfb

Please sign in to comment.