Skip to content

Saving and loading calibration data with json format loses does not fully restore non-schedule parameters #1355

@wshanks

Description

@wshanks

Informations

  • Qiskit Experiments version: 79e0a69
  • Python version: 3.11
  • Operating system: Fedora Linux 39

What is the current behavior?

When you run Calibrations.save("json"), if the Calibrations object holds parameters not associated with a schedule (such as drive_freq which gets added when using the FixedFrequencyTransmon gate library), those parameters are not fully reloaded.

Steps to reproduce the problem

from qiskit_experiments.calibration_management import Calibrations, FixedFrequencyTransmon
from qiskit.providers.fake_provider import FakeArmonkV2


library = FixedFrequencyTransmon()
backend = FakeArmonkV2()
cals = Calibrations.from_backend(backend, libraries=[library])

cals.save(file_type="json", overwrite=True, file_prefix="tmp")

loaded = Calibrations.load("tmp.json")

# Works because schedules were reloaded and their parameters were stored
loaded.get_parameter_value("amp", (0,), "x")
# Does not work because nothing stored this schedule-free parameter
loaded.get_parameter_value("drive_freq", (0,))

What is the expected behavior?

Both get_parameter_value calls succeed. Instead the second one produces:

CalibrationError: 'No parameter for drive_freq and schedule None and qubits (0,). No default value exists.'

Suggested solutions

The first get_parameter_value call succeeds because the schedules were also saved and reloaded and reloading them populates their parameter objects in the Calibrations._parameter_map dictionary. Perhaps the load function should loop through the parameters and add any parameters with schedule of None to the parameter map so that they can be properly loaded.

This issue was first noticed in #1351 when trying to convert the save/load tests from csv to json to reduce deprecation warnings in the tests.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions