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.9908447 , 0.02368164],
        [0.00915527, 0.97631836]], dtype=float32),
 None,
 array([[0.9869385 , 0.01928711],
        [0.01306152, 0.9807129 ]], dtype=float32),
 None,
 array([[0.9937744 , 0.02526855],
        [0.00622559, 0.97473145]], 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.9909668 , 0.02038574],
        [0.0090332 , 0.97961426]], dtype=float32),
 None,
 array([[0.9857178 , 0.01831055],
        [0.01428223, 0.98168945]], dtype=float32),
 None,
 array([[0.99279785, 0.02880859],
        [0.00720215, 0.9711914 ]], dtype=float32),
 None]