Circuit Saving/Loading

import os
import trueq as tq

Make SRB CircuitCollection on qubit 1, and populate it with results from a simulator.

circuits = tq.make_srb(1, [4, 32, 64])
tq.Simulator().add_overrotation(0.05).run(circuits, n_shots=1024)

Save the circuit collection with all metadata, cycles, and results to disk:

filename = tq.utils.temporary_file_name() + ".tq"
print("Saving circuits to {} ...".format(filename))
circuits.save(filename)

Out:

Saving circuits to x2felkiq.tq ...

Load from file into new instance, and then analyze/print.

circuits_new = tq.load(filename)
circuits_new.fit()
SRB on [1]
Name
Estimate
95% CI
 
Description
r
3.033
[2.217,3.849]
e-03
Average gate infidelity of the error map
A
1.001
[0.989,1.012]
SPAM of the exponential decay A * p ** m
p
0.994
[0.992,0.996]
Decay rate of the exponential decay A * p ** m


circuits_new.plot.raw()
../../_images/sphx_glr_saving_loading_001.png
# Cleanup the files.
os.remove(filename)

Total running time of the script: ( 0 minutes 0.245 seconds)

Gallery generated by Sphinx-Gallery