Example Q2: Save and Loading Channel Library Versions

This example notebook shows how one may save and load versions of the channel library.

© Raytheon BBN Technologies 2018

Saving Channel Library Versions

We initialize the channel library as shown in tutorial Q1:

[2]:
from QGL import *

cl = ChannelLibrary(":memory:")
q1 = cl.new_qubit("q1")
aps2_1 = cl.new_APS2("BBNAPS1", address="192.168.5.101")
aps2_2 = cl.new_APS2("BBNAPS2", address="192.168.5.102")
dig_1  = cl.new_X6("X6_1", address=0)
h1 = cl.new_source("Holz1", "HolzworthHS9000", "HS9004A-009-1", power=-30)
h2 = cl.new_source("Holz2", "HolzworthHS9000", "HS9004A-009-2", power=-30)
cl.set_control(q1, aps2_1, generator=h1)
cl.set_measure(q1, aps2_2, dig_1.ch(1), generator=h2)
cl.set_master(aps2_1, aps2_1.ch("m2"))
cl["q1"].measure_chan.frequency = 0e6
cl.commit()
A database item with the name q1 already exists. Updating parameters of this existing item instead.
A database item with the name BBNAPS1 already exists. Updating parameters of this existing item instead.
A database item with the name BBNAPS2 already exists. Updating parameters of this existing item instead.
A database item with the name X6_1 already exists. Updating parameters of this existing item instead.
A database item with the name Holz1 already exists. Updating parameters of this existing item instead.
A database item with the name Holz2 already exists. Updating parameters of this existing item instead.

Let us save this channel library for posterity:

[3]:
cl.save_as("NoSidebanding")

Now we adjust some parameters and save another version of the channel library

[4]:
cl["q1"].measure_chan.frequency = 50e6
cl.commit()
cl.save_as("50MHz-Sidebanding")

Maybe we forgot to change something. No worries! We can just update the parameter and create a new copy.

[5]:
cl["q1"].pulse_params['length'] = 400e-9
cl.commit()
cl.save_as("50MHz-Sidebanding")
cl.ls()
idYearDateTimeName
12019Apr. 1811:25:20 AMworking
22019Apr. 1811:25:37 AMNoSidebanding
32019Apr. 1811:25:38 AM50MHz-Sidebanding
42019Apr. 1811:25:39 AM50MHz-Sidebanding

We see the various versions of the channel library here. Note that the user is always modifying the working version of the database: all other versions are archival, but they can be restored to the current working version as shown below.

Loading Channel Library Versions

Let us load a previous version of the channel library, noting that the former value of our parameter is restored in the working copy. CRUCIAL POINT: do not use the old reference q1, which is no longer pointing to the database since the working db has been replaced with the saved version. Instead use dictionary access cl["q1"] on the channel library to return the first qubit:

[6]:
cl.load("NoSidebanding")
cl["q1"].measure_chan.frequency
[6]:
0.0

Now let’s load the second oldest version of the 50MHz-sidebanding library:

[7]:
cl.load("50MHz-Sidebanding", -1)
cl["q1"].pulse_params['length'], cl["q1"].measure_chan.frequency
[7]:
(2e-08, 50000000.0)
[8]:
# q1 = QubitFactory("q1")
plot_pulse_files(RabiAmp(cl["q1"], np.linspace(-1, 1, 11)), time=True)
Compiled 11 sequences.

Screen%20Shot%202019-03-13%20at%2012.28.08%20PM.png

[9]:
cl.ls()
idYearDateTimeName
22019Apr. 1811:25:37 AMNoSidebanding
32019Apr. 1811:25:38 AM50MHz-Sidebanding
42019Apr. 1811:25:39 AM50MHz-Sidebanding
52019Apr. 1811:25:38 AMworking
[10]:
cl.rm("NoSidebanding")
[11]:
cl.ls()
idYearDateTimeName
32019Apr. 1811:25:38 AM50MHz-Sidebanding
42019Apr. 1811:25:39 AM50MHz-Sidebanding
52019Apr. 1811:25:38 AMworking
[12]:
cl.rm("50MHz-Sidebanding")
[13]:
cl.ls()
idYearDateTimeName
52019Apr. 1811:25:38 AMworking