Skip to content

Commit

Permalink
Add tolerance to pulsebackend
Browse files Browse the repository at this point in the history
  • Loading branch information
coruscating committed Oct 16, 2023
1 parent 741de5b commit c913718
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions qiskit_experiments/test/pulse_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def __init__(
dt: float = 0.1 * 1e-9,
solver_method="RK23",
seed: int = 0,
atol: float = None,
rtol: float = None,
**kwargs,
):
"""Initialize a backend with model information.
Expand All @@ -85,6 +87,8 @@ def __init__(
methods. Defaults to "RK23".
seed: An optional seed given to the random number generator. If this argument is not
set then the seed defaults to 0.
atol: Absolute tolerance during solving.
rtol: Relative tolerance during solving.
"""
from qiskit_dynamics import Solver

Expand All @@ -109,6 +113,12 @@ def __init__(

self.solver_method = solver_method

self.solve_kwargs = {}
if atol:
self.solve_kwargs["atol"] = atol
if rtol:
self.solve_kwargs["rtol"] = rtol

self.static_hamiltonian = static_hamiltonian
self.hamiltonian_operators = hamiltonian_operators
self.static_dissipators = static_dissipators
Expand Down Expand Up @@ -339,6 +349,7 @@ def solve(self, schedule: Union[ScheduleBlock, Schedule], qubits: Tuple[int]) ->
t_eval=[time_f],
signals=signal,
method=self.solver_method,
**self.solve_kwargs,
).y[0]

return unitary
Expand Down Expand Up @@ -454,6 +465,8 @@ def __init__(
lambda_2: float = 0.8e9,
gamma_1: float = 1e4,
noise: bool = True,
atol: float = None,
rtol: float = None,
**kwargs,
):
"""Initialise backend with hamiltonian parameters
Expand All @@ -466,6 +479,8 @@ def __init__(
gamma_1: Relaxation rate (1/T1) for 1-0. Defaults to 1e4.
noise: Defaults to True. If True then T1 dissipation is included in the pulse-simulation.
The strength is given by ``gamma_1``.
atol: Absolute tolerance during solving.
rtol: Relative tolerance during solving.
"""
from qiskit_dynamics.pulse import InstructionToSignals

Expand Down Expand Up @@ -509,6 +524,8 @@ def __init__(
rwa_cutoff_freq=1.9 * qubit_frequency,
rwa_carrier_freqs=[qubit_frequency],
evaluation_mode=evaluation_mode,
atol=atol,
rtol=rtol,
**kwargs,
)

Expand Down
4 changes: 2 additions & 2 deletions test/library/calibration/test_rough_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):
super().setUp()
library = FixedFrequencyTransmon()

self.backend = SingleTransmonTestBackend(noise=False)
self.backend = SingleTransmonTestBackend(noise=False, atol=1e-3)
self.cals = Calibrations.from_backend(self.backend, libraries=[library])

def test_circuits(self):
Expand Down Expand Up @@ -107,7 +107,7 @@ def setUpClass(cls):

library = FixedFrequencyTransmon()

cls.backend = SingleTransmonTestBackend(noise=False)
cls.backend = SingleTransmonTestBackend(noise=False, atol=1e-3)
cls.cals = Calibrations.from_backend(cls.backend, libraries=[library])

# Add some pulses on the 1-2 transition.
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ commands = stestr run {posargs}
envdir = .tox/lint
commands =
black --check {posargs} qiskit_experiments test tools setup.py
pylint -rn -j 1 --rcfile={toxinidir}/.pylintrc qiskit_experiments/ test/ tools/
pylint -rn --rcfile={toxinidir}/.pylintrc qiskit_experiments/ test/ tools/
python {toxinidir}/tools/verify_headers.py

[testenv:lint-incr]
Expand Down

0 comments on commit c913718

Please sign in to comment.