Saving and loading calibration data¶

It is possible to save calibration data and, optionally, re-load it at a later time. Let us generate some calibration data and save it.

from qiskit_ibm_runtime.fake_provider import FakeCasablancaV2
import mthree

backend = FakeCasablancaV2()

mit = mthree.M3Mitigation(backend)
mit.cals_from_system([1, 3, 5], cals_file='my_cals.json')
mit.single_qubit_cals
[None,
 array([[0.9925537 , 0.01989746],
        [0.00744629, 0.98010254]], dtype=float32),
 None,
 array([[0.98706055, 0.01696777],
        [0.01293945, 0.9830322 ]], dtype=float32),
 None,
 array([[0.99243164, 0.0291748 ],
        [0.00756836, 0.9708252 ]], dtype=float32),
 None]

or,

mit = mthree.M3Mitigation(backend)
mit.cals_from_system([1, 3, 5])
mit.cals_to_file('my_cals.json')

We can then load this data at a later point in time using:

import mthree

mit2 = mthree.M3Mitigation()
mit2.cals_from_file('my_cals.json')
mit2.single_qubit_cals
[None,
 array([[0.99401855, 0.02368164],
        [0.00598145, 0.97631836]], dtype=float32),
 None,
 array([[0.9868164 , 0.01696777],
        [0.01318359, 0.9830322 ]], dtype=float32),
 None,
 array([[0.99279785, 0.03186035],
        [0.00720215, 0.96813965]], dtype=float32),
 None]