# An example of how to run GST on a 2-qubit system¶

This tutorial gives an overview of the typical steps used to perform an end-to-end (i.e. experimental-data-to-report) Gate Set Tomography analysis on a 2-qubit system. The steps are very similar to the single-qubit case; the main differences are:

• the use of more general syntax when constructing 2-qubit gate sets
• the increased number of fiducial and germ gate sequences
• the increased run time required to compute GST estimates
• a different report style
In [1]:
from __future__ import print_function
import matplotlib
matplotlib.use('Agg')

In [2]:
import pygsti


### Step 1: Construct the desired 2-qubit gateset¶

There are several ways to do this, as outlined by the comments in the cell below.

In [3]:
# via build_gateset:
#   [4] = a 4-dimensional Hilbert (state) space
#   [('Q0','Q1')] = interpret this 4-d space as that of two qubits 'Q0', and 'Q1' (note these labels *must* begin with 'Q'!)
#   "Gix" = gate label; can be anything that begins with 'G' and is followed by lowercase letters
#   "X(pi/2,Q1)" = pi/2 single-qubit x-rotation gate on the qubit labeled Q1
#   "CX(pi,Q0,Q1)" = controlled pi x-rotation using qubits Q0 (control) and Q1 (target)
#   "rho0" = prep label; can be anything that begins with "rho"
#   "E1" = effect label; can be anything that begins with "E"
#   "2" = a prep or effect expression indicating a projection/preparation of the 3rd (b/c 0-based) computational basis element
#   'dnup': ('rho0','E2') = designate the SPAM label "dnup" to mean preparation using "rho0" (a prep label) and measuring the outcome "E2" (an effect label)
#   "pp" = create all of these gate & SPAM operators in the Pauli-product basis.
gs_target = pygsti.construction.build_gateset(
[4], [('Q0','Q1')],['Gix','Giy','Gxi','Gyi','Gcnot'],
[ "X(pi/2,Q1)", "Y(pi/2,Q1)", "X(pi/2,Q0)", "Y(pi/2,Q0)", "CX(pi,Q0,Q1)" ],
prepLabels=['rho0'], prepExpressions=["0"],
effectLabels=['E0','E1','E2'], effectExpressions=["0","1","2"],
spamdefs={'upup': ('rho0','E0'), 'updn': ('rho0','E1'),
'dnup': ('rho0','E2'), 'dndn': ('rho0','remainder') }, basis="pp")

# Note that you can also explicity add identity operations, e.g. "I(Q0)" to get the same gate set,
#  and that this same syntax could be used for non-entangling 2-qubit gates, e.g. "X(pi/2,Q0):X(pi/2,Q1)".
gs_targetB = pygsti.construction.build_gateset(
[4], [('Q0','Q1')],['Gix','Giy','Gxi','Gyi','Gcnot'],
[ "I(Q0):X(pi/2,Q1)", "I(Q0):Y(pi/2,Q1)", "X(pi/2,Q0):I(Q1)", "Y(pi/2,Q0):I(Q1)", "CX(pi,Q0,Q1)" ],
prepLabels=['rho0'], prepExpressions=["0"],
effectLabels=['E0','E1','E2'], effectExpressions=["0","1","2"],
spamdefs={'upup': ('rho0','E0'), 'updn': ('rho0','E1'),
'dnup': ('rho0','E2'), 'dndn': ('rho0','remainder') }, basis="pp")

# If you're lucky and your gateset is one of pyGSTi's "standard" gate sets, you can just import it.
from pygsti.construction import std2Q_XYCNOT
gs_targetC = std2Q_XYCNOT.gs_target

#check that these are all the same
assert(abs(gs_target.frobeniusdist(gs_targetB)) < 1e-6)
assert(abs(gs_target.frobeniusdist(gs_targetC)) < 1e-6)


### Step 2: Obtain lists of fiducial and germ gate sequences¶

These are the building blocks of the gate sequences performed in the experiment. Typically, these lists are either given to you by the folks at Sandia National Labs (email [email protected]), provided by pyGSTi because you're using a "standard" gate set, or computed using "fiducial selection" and "germ selection" algorithms (which are a part of pyGSTi, but not covered in this tutorial).

In [4]:
#If you know the fiducial strings you can create a list manually.  Note
# that in general there can be different "preparation" and "measurement"
# (or "effect") fiducials.
prep_fiducials = pygsti.construction.gatestring_list( \
[ (), ('Gix',), ('Giy',), ('Gix','Gix'),
('Gxi',), ('Gxi','Gix'), ('Gxi','Giy'), ('Gxi','Gix','Gix'),
('Gyi',), ('Gyi','Gix'), ('Gyi','Giy'), ('Gyi','Gix','Gix'),
('Gxi','Gxi'), ('Gxi','Gxi','Gix'), ('Gxi','Gxi','Giy'), ('Gxi','Gxi','Gix','Gix') ] )

effect_fiducials = pygsti.construction.gatestring_list( \
[(), ('Gix',), ('Giy',),
('Gix','Gix'), ('Gxi',),
('Gyi',), ('Gxi','Gxi'),
('Gxi','Gix'), ('Gxi','Giy'),
('Gyi','Gix'), ('Gyi','Giy')] )

#Or, if you're lucky, you can just import them
prep_fiducialsB = std2Q_XYCNOT.prepStrs
effect_fiducialsB = std2Q_XYCNOT.effectStrs

#check that these are the same
assert(prep_fiducials == prep_fiducialsB)
assert(effect_fiducials == effect_fiducialsB)

#Use fiducial sequences to create a "spam specifiers" object, telling
# GST which preparation and measurement fiducials to follow and precede which
# state preparation and effect operators, respectively.
specs = pygsti.construction.build_spam_specs(
prepStrs=prep_fiducials,
effectStrs=effect_fiducials,
prep_labels=gs_target.get_prep_labels(),
effect_labels=gs_target.get_effect_labels() )

#Alternatively, if you're lucky, you can grab the specs directly:
specsB = std2Q_XYCNOT.specs
assert(specs[0] == specsB[0])

In [5]:
#germ lists can be specified in the same way.  In this case, there are
# 71 germs required to do honest GST.  Since this would crowd this tutorial
# notebook, we create some smaller lists of germs manually and import the
# full 71-germ list from std2Q_XYCNOT
germs4 = pygsti.construction.gatestring_list(
[ ('Gix',), ('Giy',), ('Gxi',), ('Gyi',) ] )

germs11 = pygsti.construction.gatestring_list(
[ ('Gix',), ('Giy',), ('Gxi',), ('Gyi',), ('Gcnot',), ('Gxi','Gyi'), ('Gix','Giy'),
('Gix','Gcnot'), ('Gxi','Gcnot'), ('Giy','Gcnot'), ('Gyi','Gcnot') ] )

germs71 = std2Q_XYCNOT.germs


### Step 3: Data generation¶

Now that fiducial and germ strings have been found, we can generate the list of experiments needed to run GST, just like in the 1-qubit case. As an additional input we'll need a list of lengths indicating the maximum length strings to use on each successive GST iteration.

In [6]:
#A list of maximum lengths for each GST iteration
maxLengths = [1,2,4]

#Create a list of GST experiments for this gateset, with
#the specified fiducials, germs, and maximum lengths.  We use
#"germs4" here so that the tutorial runs quickly; really, you'd
#want to use germs71!
listOfExperiments = pygsti.construction.make_lsgst_experiment_list(gs_target.gates.keys(), prep_fiducials,
effect_fiducials, germs4, maxLengths)

#Create an empty dataset file, which stores the list of experiments
# and zerod-out columns where data should be inserted.  Note the use of the SPAM
# labels in the "Columns" header line.
pygsti.io.write_empty_dataset("tutorial_files/My2QDataTemplate.txt", listOfExperiments,
"## Columns = upup count, updn count, dnup count, dndn count")

In [7]:
#Generate some "fake" (simulated) data based on a depolarized version of the target gateset
gs_datagen = gs_target.depolarize(gate_noise=0.1, spam_noise=0.001)
ds = pygsti.construction.generate_fake_data(gs_datagen, listOfExperiments, nSamples=1000,
sampleError="multinomial", seed=2016)

#if you have a dataset file with real data in it, load it using something like:


### Step 4: Run GST using do_long_sequence_gst¶

Just like for 1-qubit GST, we call the driver routine do_long_sequence_gst to compute the GST estimates. Usually for two qubits this could take a long time (hours) based on the number of gate sequences used. However, since we chose an incomplete set of only 4 germs and set our maximum max-length to 4, this will run fairly quickly (~20min).

Some notes about the options/arguments to do_long_sequence_gst that are particularly relevant to 2-qubit GST:

• mxBasis indicates which basis the target gateset matrices are in -- this should be the same as that used to create the gateset. Here 'pp' denotes the Pauli-product basis.
• advancedOptions expects a dictionary of with option names as the keys. Relevant options are:
• memoryLimitInBytes gives an estimate of how much memory is available to use on your system (in bytes). This is currently not a hard limit, and pyGSTi may require 50-100% more memory than this "limit". So you'll need to be conservative in the value you place here: if your machine has 10GB of RAM, set this to 3 or 5 GB initially and increase it as you see how much memory is actually used using a separate OS performance monitor tool.
• depolarizeLGST gives an amount (in [0,1]) to depolarize the initial LGST estimate that is used as the initial guess for long-sequence GST. In practice, we find that in the larger 2-qubit Hilbert space, the LGST estimate may be so poor as to adversely affect the subsequent long-sequence GST (e.g. very slow convergence). Depolarizing the LGST estimate remedies this. If you're unsure what to put here, either don't specify depolarizeLGST at all (the same as using 0.0), or just use 0.1.
• verbosity tells the routine how much detail to print to stdout. If you don't mind waiting a while without getting any output, you can leave this at its default value (2). If you can't standing wondering whether GST is still running or has locked up, set this to 3.
In [8]:
import time
start = time.time()
results = pygsti.do_long_sequence_gst(ds, gs_target, prep_fiducials, effect_fiducials, germs4,
maxLengths, gaugeOptParams={'itemWeights': {'spam':0.1,'gates': 1.0}},
advancedOptions={ 'depolarizeStart' : 0.1 }, memLimit=3*(1024)**3,
verbosity=3 )
end = time.time()
print("Total time=%f hours" % ((end - start) / 3600.0))

#If you wanted to, you could pickle the results for later analysis:
#pickle.dump(results, open("MySavedResults.pkl", "w"))

--- LGST ---
Singular values of I_tilde (truncating to first 16 of 16) =
6.74761341289
2.34801058571
2.30618437979
1.24095704293
1.21875500467
1.19236743148
0.885151794781
0.820186469499
0.531857424077
0.513447431382
0.38887030472
0.372790668863
0.313243294171
0.237656955269
0.225848759754
0.170428615627

Singular values of target I_tilde (truncating to first 16 of 16) =
6.86802764151
3.20253744687
3.20253744687
1.76923693223
1.76923693223
1.73205080757
1.23400485863
1.22474487139
0.707106781187
0.707106781187
0.5
0.493714392513
0.493714392513
0.346122344917
0.346122344917
0.239642075572

Resulting gate set:

rho0 =    0.5000        0        0   0.5000        0        0        0        0        0        0        0        0   0.5000        0        0   0.5000

E0 =    0.5905  -0.0295   0.0465   0.4625  -0.0445  -0.0525  -0.0065  -0.0445   0.0255   0.0375  -0.0585   0.0395   0.4535  -0.0305   0.0495   0.4895

E1 =    0.4945   0.0475  -0.0555  -0.4415  -0.0285   0.0305  -0.0245   0.0195   0.0245   0.0775  -0.0275  -0.0115   0.3525   0.0275  -0.0475  -0.4055

E2 =    0.5015  -0.0435   0.0745   0.3435   0.0485  -0.0065  -0.0065   0.0565  -0.0245  -0.0375   0.0705  -0.0525  -0.4375   0.0175  -0.0545  -0.4055

Gix =
0.9998        0  -0.0002   0.0002   0.0003  -0.0003   0.0003  -0.0003        0        0        0        0        0  -0.0001        0        0
0.0338   0.8427   0.0338  -0.0338  -0.0048   0.0214  -0.0048   0.0048   0.0081  -0.0125   0.0081  -0.0081  -0.0247   0.0104  -0.0247   0.0247
-0.0780   0.0682  -0.0780  -0.9220  -0.0563   0.0865  -0.0563   0.0563   0.0331  -0.0429   0.0331  -0.0331  -0.0061  -0.0226  -0.0061   0.0061
-0.0872   0.0506   0.9128   0.0872  -0.0350   0.0637  -0.0350   0.0350  -0.0074  -0.0427  -0.0074   0.0074   0.0266  -0.0310   0.0266  -0.0266
0.0159  -0.0322   0.0159  -0.0159   0.9020  -0.0334  -0.0980   0.0980   0.0179  -0.0392   0.0179  -0.0179  -0.0031   0.0339  -0.0031   0.0031
0.0164  -0.0582   0.0164  -0.0164  -0.0222   0.8757  -0.0222   0.0222   0.0648  -0.0887   0.0648  -0.0648   0.0106   0.0160   0.0106  -0.0106
-0.0224   0.0222  -0.0224   0.0224  -0.0873   0.0338  -0.0873  -0.9127   0.0118  -0.0320   0.0118  -0.0118  -0.0005  -0.0116  -0.0005   0.0005
0.0039  -0.0506   0.0039  -0.0039  -0.1036   0.0987   0.8964   0.1036   0.0007  -0.1495   0.0007  -0.0007   0.0104  -0.0428   0.0104  -0.0104
0.0045  -0.0105   0.0045  -0.0045   0.0101  -0.0205   0.0101  -0.0101   0.9269  -0.0464  -0.0731   0.0731   0.0277  -0.0374   0.0277  -0.0277
-0.0104   0.0177  -0.0104   0.0104   0.0219  -0.0527   0.0219  -0.0219   0.0540   0.7558   0.0540  -0.0540   0.0453  -0.0460   0.0453  -0.0453
-0.0344   0.0488  -0.0344   0.0344   0.0912  -0.1458   0.0912  -0.0912  -0.1625   0.1341  -0.1625  -0.8375   0.0111   0.0705   0.0111  -0.0111
0.0078  -0.0357   0.0078  -0.0078  -0.0474  -0.0302  -0.0474   0.0474  -0.1102   0.0575   0.8898   0.1102   0.0445  -0.0574   0.0445  -0.0445
-0.0186   0.0026  -0.0186   0.0186   0.0135   0.0012   0.0135  -0.0135  -0.0295  -0.0076  -0.0295   0.0295   0.9136  -0.0199  -0.0864   0.0864
-0.0232   0.0068  -0.0232   0.0232   0.0207   0.0054   0.0207  -0.0207  -0.0514  -0.0661  -0.0514   0.0514  -0.0031   0.8811  -0.0031   0.0031
-0.0473   0.1032  -0.0473   0.0473   0.0419  -0.0607   0.0419  -0.0419  -0.0994   0.1200  -0.0994   0.0994  -0.0967   0.0269  -0.0967  -0.9033
0.0172  -0.0304   0.0172  -0.0172  -0.0246   0.0880  -0.0246   0.0246   0.0382  -0.0134   0.0382  -0.0382  -0.0838   0.0402   0.9162   0.0838

Giy =
0.9996   0.0002  -0.0005   0.0004   0.0005        0   0.0006  -0.0005  -0.0003   0.0002  -0.0003   0.0003        0   0.0001   0.0002        0
0.1359  -0.0765   0.1776   0.8641  -0.0332   0.0081  -0.0551   0.0332   0.0255  -0.0142   0.0619  -0.0255  -0.0267  -0.0376  -0.0303   0.0267
0.0087  -0.0196   0.9370  -0.0087  -0.0279   0.0411  -0.0583   0.0279   0.0197   0.0185   0.0712  -0.0197  -0.0124  -0.0075  -0.0007   0.0124
-0.0924  -0.8894  -0.0734   0.0924  -0.0228   0.0018  -0.0426   0.0228        0  -0.0020   0.0067        0  -0.0189   0.0097   0.0105   0.0189
0.0197  -0.0517  -0.0054  -0.0197   0.8602   0.1212  -0.0114   0.1398   0.0128  -0.0144  -0.0374  -0.0128   0.0093   0.0383   0.0164  -0.0093
0.0067  -0.0609   0.0504  -0.0067   0.1326  -0.0479   0.1422   0.8674  -0.0021  -0.1106   0.1850   0.0021  -0.0095  -0.0554   0.0270   0.0095
-0.0081  -0.0114   0.0526   0.0081  -0.0062  -0.0080   0.7457   0.0062   0.0373   0.0443   0.1540  -0.0373  -0.0039   0.0064   0.0017   0.0039
-0.0005  -0.0242   0.0385   0.0005  -0.0480  -0.8089  -0.1164   0.0480   0.0114  -0.1649   0.0999  -0.0114  -0.0404  -0.0401  -0.0276   0.0404
0.0244   0.0420   0.0519  -0.0244  -0.0323  -0.0107  -0.0810   0.0323   0.9344   0.0954   0.0964   0.0656   0.0062   0.0126   0.0494  -0.0062
-0.0027   0.0007  -0.0494   0.0027   0.0420   0.0469   0.0721  -0.0420   0.1639  -0.1615   0.1370   0.8361   0.0445  -0.0360   0.0338  -0.0445
-0.0128   0.0148   0.0250   0.0128   0.0613   0.0930   0.0162  -0.0613  -0.0338   0.0316   0.8384   0.0338   0.0236  -0.0212   0.0210  -0.0236
-0.0313  -0.0579  -0.0055   0.0313   0.0343   0.0400  -0.0127  -0.0343  -0.0900  -0.9696  -0.0570   0.0900   0.0153  -0.0360   0.0771  -0.0153
-0.0125   0.0013  -0.0086   0.0125   0.0206  -0.0298   0.0539  -0.0206   0.0096   0.0606  -0.0240  -0.0096   0.9153   0.1099   0.0061   0.0847
-0.0148  -0.0826   0.0167   0.0148  -0.0369   0.1061   0.0188   0.0369  -0.0262  -0.1056   0.0675   0.0262   0.1224  -0.0974   0.1939   0.8776
-0.0521   0.1111  -0.1107   0.0521   0.0949  -0.2175   0.0250  -0.0949  -0.0295  -0.0016  -0.0705   0.0295  -0.0240  -0.0130   0.8990   0.0240
-0.0152   0.0031  -0.0021   0.0152  -0.0182   0.0744  -0.0063   0.0182  -0.0429  -0.0660   0.0269   0.0429  -0.0679  -0.9327  -0.1044   0.0679

Gxi =
0.9997   0.0003  -0.0005   0.0001   0.0004  -0.0006   0.0006  -0.0002        0        0  -0.0002  -0.0002   0.0002  -0.0003  -0.0003        0
0.0216   0.8796   0.0299  -0.0084  -0.0263   0.0350  -0.0103  -0.0061   0.0088  -0.1089   0.0289   0.0043   0.0059   0.1026  -0.0008  -0.0191
-0.0061  -0.0066   0.9336   0.0153  -0.0008  -0.0048  -0.0253  -0.0208   0.0004  -0.0331  -0.0708   0.0087  -0.0184   0.0423   0.0595   0.0092
-0.0048  -0.0030  -0.0144   0.9138  -0.0144   0.0154   0.0167  -0.0255  -0.0166   0.0516  -0.0471  -0.0744  -0.0014   0.0156  -0.0276   0.0925
0.0021  -0.0224   0.0058   0.0345   0.8540   0.0731  -0.0427  -0.0595   0.0027   0.0118  -0.0260   0.0339   0.0021  -0.0086   0.0081  -0.0387
-0.0095   0.0373  -0.0030   0.0352   0.0310   0.7594   0.0349  -0.0106   0.0023   0.0152   0.0055   0.0235   0.0241  -0.0352  -0.0079  -0.0498
0.0212   0.0045   0.0176   0.0058  -0.0369  -0.0253   0.7738   0.0003   0.0593  -0.1162   0.1717  -0.0323  -0.0384  -0.0018  -0.0636   0.0114
0.0133  -0.0709  -0.0328  -0.0280  -0.0043  -0.0305   0.0137   0.8919   0.0366   0.0137   0.0508  -0.0513   0.0286   0.0411   0.0119  -0.0140
-0.0570  -0.0469   0.0060  -0.0211   0.0520   0.0259  -0.0143   0.0142  -0.0832  -0.0467   0.0189   0.0051  -0.9196  -0.0080   0.0156  -0.0023
0.0466  -0.1352   0.0057   0.0381  -0.0921   0.2145  -0.1808  -0.0575   0.0499  -0.1763   0.0102   0.0348  -0.0586  -0.7886  -0.0635  -0.0261
0.0106  -0.0056  -0.0507   0.0045   0.0193  -0.0720   0.1464   0.0076   0.0131   0.1024  -0.0387   0.0020   0.0337  -0.0101  -0.7903  -0.0488
-0.0170   0.0500  -0.0200  -0.0884  -0.0656   0.0240  -0.0765   0.1034  -0.0137  -0.0597   0.0479  -0.0918   0.0290  -0.0223   0.0152  -0.9235
-0.1233   0.0191  -0.0028   0.0153   0.1246  -0.0429   0.0122  -0.0146   0.8815   0.0358  -0.0087   0.0104   0.0867   0.0403  -0.0338   0.0214
-0.0346  -0.0633  -0.0197  -0.0134  -0.0268   0.1296   0.0449   0.0187  -0.0106   0.9295  -0.0335  -0.0374   0.0492   0.1055   0.0389  -0.0012
0.0126   0.0449  -0.1439  -0.0278  -0.0819   0.0242  -0.0612   0.0629   0.0084  -0.0378   0.9179  -0.0236   0.0110  -0.0486   0.0868   0.0042
0.0138  -0.0276  -0.0178  -0.0892  -0.0116   0.0566   0.0298   0.0806   0.0461  -0.0686   0.0068   0.8784   0.0349  -0.0019  -0.0221   0.0405

Gyi =
0.9997   0.0004  -0.0003        0        0   0.0004        0   0.0002  -0.0004   0.0006  -0.0003        0   0.0005  -0.0003   0.0006  -0.0001
0.0238   0.8771   0.0143   0.0137   0.0126   0.0826   0.0224  -0.0423   0.0002  -0.0170  -0.0662  -0.0044  -0.0238   0.1211  -0.0271  -0.0137
0.0202  -0.0332   0.9192   0.0362   0.0108   0.0166   0.1554  -0.0167   0.0082   0.0122  -0.0071   0.0149  -0.0415   0.0744   0.0369  -0.0149
-0.0069  -0.0085        0   0.8934   0.0285  -0.0191   0.0466   0.1013   0.0019  -0.0192  -0.0208  -0.0137   0.0048  -0.0043   0.0010   0.1086
0.1132  -0.0309   0.0024   0.0110  -0.1285   0.0088  -0.0183   0.0095   0.1039  -0.0615   0.0217   0.0513   0.8902   0.0434   0.0254  -0.0144
0.0024   0.0882   0.0501   0.0379  -0.0388  -0.1382  -0.0098  -0.0256  -0.0181   0.1843  -0.0014  -0.0018   0.0283   0.8787  -0.0121  -0.0686
-0.0296   0.0479   0.1228   0.0132   0.0079   0.0700  -0.1671  -0.0337   0.0122   0.0078   0.1470  -0.0186   0.0104   0.0126   0.8215   0.0060
0.0138  -0.0725   0.0110   0.1069   0.0328  -0.0175  -0.0167  -0.0913  -0.0054  -0.0319   0.0261   0.0695   0.0313  -0.0445  -0.0002   0.8481
0.0274  -0.0237   0.0394   0.0023   0.0003   0.0230  -0.0469  -0.0302   0.9053   0.0084   0.0400   0.0465  -0.0411   0.0115   0.0172   0.0113
0.0039   0.0137  -0.0978   0.0283  -0.0119   0.0072   0.0163   0.0171   0.0700   0.7489  -0.0082   0.0039   0.0127  -0.0518  -0.0241  -0.0449
0.0075  -0.0606  -0.0247  -0.0146  -0.0264   0.1137   0.0600  -0.0017  -0.0656   0.1038   0.7263   0.0426   0.0895  -0.0532   0.0867  -0.0824
-0.0406   0.0475  -0.0355   0.0047   0.0309  -0.0134  -0.0688   0.0443   0.0048   0.0012  -0.0129   0.9116   0.0675  -0.0984   0.0809  -0.0316
-0.0862  -0.0322  -0.0029  -0.0072  -0.9270   0.0510   0.0009   0.0011  -0.0562  -0.0924   0.0006  -0.0177   0.1015  -0.0512   0.0042  -0.0081
-0.0366  -0.0917  -0.0126   0.0561  -0.0413  -0.8153  -0.0262  -0.0602  -0.0885  -0.0505  -0.0443   0.0699  -0.0167   0.0934   0.0794  -0.0028
-0.0421   0.0789  -0.1315  -0.0008   0.0182  -0.0203  -0.9726  -0.0790   0.0280  -0.0527   0.0035  -0.0179   0.0288  -0.1490   0.1132   0.0141
-0.0129   0.0056  -0.0237  -0.0305  -0.0163   0.0129  -0.0038  -0.9416  -0.0486   0.0542  -0.0017   0.0240  -0.0278   0.0800  -0.0298   0.0712

Gcnot =
0.9997   0.0002   0.0001  -0.0003  -0.0002   0.0002        0  -0.0003  -0.0003   0.0002   0.0001  -0.0002        0  -0.0002  -0.0001        0
0.0333   0.8508   0.0031   0.0096  -0.0220   0.0244  -0.0636   0.0398   0.0477  -0.0561   0.0697  -0.0106   0.0002  -0.0163   0.0586  -0.0006
-0.0150  -0.0232  -0.0228   0.0023   0.0446  -0.0219  -0.0204   0.0396  -0.0073   0.0053   0.0905  -0.0071   0.0106   0.0032   0.9347   0.0290
-0.1044   0.0643   0.0337   0.0056  -0.0048   0.0089  -0.0058  -0.1010   0.0494  -0.0573   0.0633   0.0867   0.0968  -0.0709   0.0114   0.9078
0.0035  -0.0343  -0.0237  -0.0208  -0.0280   0.0461  -0.1241   0.0002  -0.0051   0.8874  -0.0502   0.0164   0.0106  -0.0052  -0.0277   0.0166
0.0525  -0.1321   0.0649   0.0307  -0.1134   0.1125   0.0023  -0.1081   0.9547  -0.0763   0.0615   0.0801   0.0366  -0.0906   0.0017   0.0786
-0.0200  -0.0170   0.0317  -0.0093  -0.0468   0.0929  -0.0978  -0.7667  -0.0490  -0.0425  -0.0034  -0.0812   0.0091  -0.0556   0.0130  -0.0015
0.0058  -0.0126   0.0340   0.0092   0.1195  -0.0307   0.9206   0.1247   0.0856  -0.0503   0.0692  -0.0449  -0.0257   0.0915   0.0381   0.0206
0.0541  -0.0499   0.0969   0.0177   0.0121  -0.9367   0.0335   0.0146   0.0223  -0.0398  -0.0315   0.0203   0.0036   0.0101   0.0112   0.0043
-0.0150   0.0245   0.0800  -0.0286  -0.7647  -0.1021  -0.0606  -0.0715  -0.0824   0.0636   0.0453  -0.0900   0.0364  -0.0960   0.0156   0.0176
-0.0379  -0.0327  -0.0286   0.0543  -0.0367   0.1006  -0.0617  -0.1445  -0.2509   0.1968  -0.0696  -0.7658   0.0525  -0.0658  -0.0114   0.0260
-0.0439   0.0715   0.0662  -0.0258  -0.1056   0.0349  -0.0036  -0.0138  -0.0698  -0.0654   0.9349   0.0811  -0.0122  -0.0379  -0.0089  -0.0092
-0.0371   0.0036  -0.0379  -0.0862  -0.0276   0.0709   0.0380   0.0145   0.0460   0.0815  -0.0489   0.0139   0.9290  -0.0193   0.0161   0.0882
-0.0187   0.0536   0.0015   0.0054  -0.0021  -0.0080   0.0373  -0.0380   0.1421   0.0805   0.0358   0.1456   0.0675   0.7863  -0.0286   0.0244
0.0099   0.0744   0.9298   0.0103  -0.0418  -0.0459   0.0073  -0.0456  -0.1020   0.0255  -0.0163   0.0039  -0.0238   0.0166  -0.0291  -0.0153
0.0969  -0.0956   0.0229   0.9026  -0.0354   0.0737   0.0627   0.0332   0.0538  -0.0123  -0.0077   0.0013  -0.0798   0.0327   0.0320  -0.0083

--- Iterative MLGST: Iter 1 of 3  731 gate strings ---:
--- Minimum Chi^2 GST ---
Memory limit = 3.00GB
Cur, Persist, Gather = 0.08, 0.03, 0.30 GB
Evaltree generation (deriv) w/mem limit = 2.59GB
bulk_evaltree: created initial tree (731 strs) in 0s
bulk_evaltree: split tree (1 subtrees) in 0s
mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 1.88GB (2.44GB fc)
Created evaluation tree with 1 subtrees.  Will divide 1 procs into 1 (subtree-processing)
groups of ~1 procs each, to distribute over 1344 params (taken as 1 param groups of ~1344 params).
Memory estimate = 1.88GB (cache=731, wrtLen1=1344, wrtLen2=1344, subsPerProc=1).
--- Outer Iter 0: norm_f = 32916.8, mu=0
--- Outer Iter 1: norm_f = 29180.6, mu=2.83248e+06
--- Outer Iter 2: norm_f = 24098.5, mu=944158
--- Outer Iter 3: norm_f = 15729.7, mu=314719
--- Outer Iter 4: norm_f = 8154.44, mu=104906
--- Outer Iter 5: norm_f = 4442.94, mu=34968.8
--- Outer Iter 6: norm_f = 2782.22, mu=11656.3
--- Outer Iter 7: norm_f = 1933.34, mu=3885.43
--- Outer Iter 8: norm_f = 1469.88, mu=1295.14
--- Outer Iter 9: norm_f = 1244.05, mu=431.714
--- Outer Iter 10: norm_f = 1152.3, mu=143.905
--- Outer Iter 11: norm_f = 1118.86, mu=47.9682
--- Outer Iter 12: norm_f = 1108.89, mu=15.9894
--- Outer Iter 13: norm_f = 1107.1, mu=5.3298
--- Outer Iter 14: norm_f = 1106.96, mu=1.7766
--- Outer Iter 15: norm_f = 1106.95, mu=0.5922
Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06
Sum of Chi^2 = 1106.95 (2193 data params - 1088 model params = expected mean of 1105; p-value = 0.477827)
Completed in 561.9s
2*Delta(log(L)) = 1109.03
Iteration 1 took 562.0s

--- Iterative MLGST: Iter 2 of 3  1141 gate strings ---:
--- Minimum Chi^2 GST ---
Memory limit = 3.00GB
Cur, Persist, Gather = 0.12, 0.05, 0.30 GB
Evaltree generation (deriv) w/mem limit = 2.54GB
bulk_evaltree: created initial tree (1141 strs) in 0s
bulk_evaltree: split tree (1 subtrees) in 0s
mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 2.93GB (3.81GB fc)
Created evaluation tree with 1 subtrees.  Will divide 1 procs into 1 (subtree-processing)
groups of ~1 procs each, to distribute over 1344 params (taken as 2 param groups of ~672 params).
Memory estimate = 1.47GB (cache=1141, wrtLen1=672, wrtLen2=1344, subsPerProc=1).
--- Outer Iter 0: norm_f = 3828.54, mu=0
--- Outer Iter 1: norm_f = 2883.48, mu=3129.75
--- Outer Iter 2: norm_f = 2567.76, mu=1043.25
--- Outer Iter 3: norm_f = 2431.23, mu=347.75
--- Outer Iter 4: norm_f = 2386.94, mu=115.917
--- Outer Iter 5: norm_f = 2379.08, mu=38.6389
--- Outer Iter 6: norm_f = 2378.44, mu=12.8796
--- Outer Iter 7: norm_f = 2378.41, mu=4.29321
Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06
Sum of Chi^2 = 2378.41 (3423 data params - 1088 model params = expected mean of 2335; p-value = 0.26072)
Completed in 225.4s
2*Delta(log(L)) = 2384.85
Iteration 2 took 225.4s

--- Iterative MLGST: Iter 3 of 3  1735 gate strings ---:
--- Minimum Chi^2 GST ---
Memory limit = 3.00GB
Cur, Persist, Gather = 0.13, 0.07, 0.29 GB
Evaltree generation (deriv) w/mem limit = 2.51GB
bulk_evaltree: created initial tree (1735 strs) in 0s
bulk_evaltree: split tree (1 subtrees) in 0s
mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 4.45GB (5.79GB fc)
Created evaluation tree with 1 subtrees.  Will divide 1 procs into 1 (subtree-processing)
groups of ~1 procs each, to distribute over 1344 params (taken as 2 param groups of ~672 params).
Memory estimate = 2.23GB (cache=1735, wrtLen1=672, wrtLen2=1344, subsPerProc=1).
--- Outer Iter 0: norm_f = 5002.2, mu=0
--- Outer Iter 1: norm_f = 4393.33, mu=4065.3
--- Outer Iter 2: norm_f = 4258.91, mu=1355.1
--- Outer Iter 3: norm_f = 4206.65, mu=451.699
--- Outer Iter 4: norm_f = 4192.11, mu=150.566
--- Outer Iter 5: norm_f = 4189.62, mu=50.1888
--- Outer Iter 6: norm_f = 4189.32, mu=16.7296
--- Outer Iter 7: norm_f = 4189.3, mu=5.57654
Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06
Sum of Chi^2 = 4189.3 (5205 data params - 1088 model params = expected mean of 4117; p-value = 0.212011)
Completed in 330.3s
2*Delta(log(L)) = 4201.93
Iteration 3 took 330.4s

Switching to ML objective (last iteration)
--- MLGST ---
Memory: limit = 3.00GB(cur, persist, gthr = 0.17, 0.07, 0.29 GB)
Evaltree generation (deriv) w/mem limit = 2.47GB
bulk_evaltree: created initial tree (1735 strs) in 0s
bulk_evaltree: split tree (1 subtrees) in 0s
mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 4.45GB (5.79GB fc)
Created evaluation tree with 1 subtrees.  Will divide 1 procs into 1 (subtree-processing)
groups of ~1 procs each, to distribute over 1344 params (taken as 2 param groups of ~672 params).
Memory estimate = 2.23GB (cache=1735, wrtLen1=672, wrtLen2=1344, subsPerProc=1).
--- Outer Iter 0: norm_f = 2100.96, mu=0
--- Outer Iter 1: norm_f = 2098.59, mu=2036.38
--- Outer Iter 2: norm_f = 2098.43, mu=1692.54
Least squares message = Relative change in |x| is at most 1e-06
Maximum log(L) = 2098.43 below upper bound of -3.93421e+06
2*Delta(log(L)) = 4196.86 (5205 data params - 1344 model params = expected mean of 3861; p-value = 9.8035e-05)
Completed in 124.4s
2*Delta(log(L)) = 4196.86
Final MLGST took 124.4s

Iterative MLGST Total Time: 1242.2s

WARNING: Could not obtain number of *non-gauge* parameters - using total params instead

Total time=0.359374 hours


### Step 5: Create report(s) using the returned Results object¶

The Results object returned from do_long_sequence_gst is able to generate several different types of reports. Most of these are designed to display single-qubit results (for historical reasons). The "general"-type report was designed with 2-qubit data presentation in mind, so creating reports with create_general_report will be the most useful.

In [9]:
results.gatesets['final estimate'].set_basis("pp", [4])
print(results.gatesets['final estimate'].get_basis_name())
print(results.gatesets['final estimate'].get_basis_dimension())

pp
[4]

In [10]:
results.create_general_report_pdf(filename="tutorial_files/easy_2q_general.pdf",verbosity=2)

*** Generating tables *** (0.0s elapsed)
Generating table: targetSpamBriefTable  [0.0s]
Generating table: bestGatesetSpamBriefTable  [0.0s]
Generating table: bestGatesetSpamParametersTable  [0.0s]
Generating table: bestGatesetVsTargetTable  [6.4s]
Generating table: bestGatesetSpamVsTargetTable  [0.0s]
Generating table: bestGatesetGaugeOptParamsTable  [0.0s]
Generating table: bestGatesetChoiEvalTable  [5.1s]
Generating table: datasetOverviewTable  [0.1s]
Generating table: bestGatesetEvalTable  [1.4s]
Generating table: bestGatesetRelEvalTable  [1.1s]
Generating table: targetGatesBoxTable  [6.7s]
Generating table: bestGatesetGatesBoxTable  [13.3s]
Generating table: bestGatesetErrGenBoxTable  [11.3s]
Generating table: softwareEnvTable  [0.2s]
Generating table: fiducialListTable  [0.0s]
Generating table: prepStrListTable  [0.0s]
Generating table: effectStrListTable  [0.0s]
Generating table: germList2ColTable  [0.0s]
Generating table: progressTable  [13.2s]
*** Generating plots *** (79.4s elapsed)
-- LogL plots:  Iter 1 of 3 :   Generating figure: colorBoxPlotKeyPlot  [2.0s]
Iter 2 of 3 :   Generating figure: bestEstimateSummedColorBoxPlot  [0.6s]
Iter 3 of 3 :   Generating special: bestEstimateColorBoxPlotPages  [10.2s]

*** Merging into template file *** (97.4s elapsed)
Latex file(s) successfully generated.  Attempting to compile with pdflatex...
Initial output PDF tutorial_files/easy_2q_general.pdf successfully generated.
Final output PDF tutorial_files/easy_2q_general.pdf successfully generated. Cleaning up .aux and .log files.
Report generation complete! [total time 99s]


Now open tutorial_files/easy_2q_general.pdf to see the results. You've run 2-qubit GST!

In [11]:
import pickle
with open("tutorial_files/easy_2q_results.pkl","wb") as pklfile:
pickle.dump(results, pklfile)

In [ ]: