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.99328613, 0.02185059],
        [0.00671387, 0.9781494 ]], dtype=float32),
 None,
 array([[0.9869385 , 0.01940918],
        [0.01306152, 0.9805908 ]], dtype=float32),
 None,
 array([[0.9926758 , 0.03161621],
        [0.00732422, 0.9683838 ]], 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.9925537 , 0.02258301],
        [0.00744629, 0.977417  ]], dtype=float32),
 None,
 array([[0.9836426 , 0.01403809],
        [0.01635742, 0.9859619 ]], dtype=float32),
 None,
 array([[0.9925537 , 0.03076172],
        [0.00744629, 0.9692383 ]], dtype=float32),
 None]