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 3canwezg.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
2.596
[1.767,3.425]
e-03
Average gate infidelity of the error map
A
1.005
[0.996,1.014]
SPAM of the exponential decay A * p ** m
p
0.995
[0.993,0.996]
Decay rate of the exponential decay A * p ** m


circuits_new.plot.raw()
SRB on [1]
# Cleanup the files.
os.remove(filename)

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

Gallery generated by Sphinx-Gallery