Example for qutrit GST¶

This notebook demonstrates how to construct the gate sequences and perform the analysis for qutrit GST when the gate set consists of symmetric $\pi/2$-rotations on each single qubit separately, X, Y and a 2-qubit Molmer-Sorenson gate which rotates around the XX axis by $\pi/2$.

In [1]:
import pygsti
import pygsti.construction as pc
from pygsti.construction import qutrit

from numpy import pi, array
import pickle

import numpy as np


First, we construct the target gate set. This functionality is built into pyGSTi, so we just need to specify the single-qubit and M-S angles.

In [2]:
gs_target = qutrit.make_qutrit_gateset(errorScale=0, Xangle=pi/2, Yangle=pi/2, MSglobal=pi/2, MSlocal=0, basis="qt")
#print(gs_target)


Now construct the gate sequences needed by GST. These fiducials and germs have been computed ahead of time and the results are used to construct the gate string lists below. Then we construct an empty dataset containing all of the necessary experimental sequences which can serve as a template for the actual experimental results.

In [3]:
fiducialPrep = pc.gatestring_list(
[(),('Gy',),('Gx',),('Gm',),
('Gx','Gx'), ('Gm','Gy'),('Gm','Gx'),
('Gy','Gy','Gy'),('Gx','Gx','Gx')])

fiducialMeasure = pc.gatestring_list(
[(),('Gy',),('Gx',),('Gm',),
('Gy','Gm'),('Gx','Gm')])

maxLengths = [1,2,4]

germs = pygsti.construction.gatestring_list(
[('Gi',),
('Gy',),
('Gx',),
('Gm',),
('Gi', 'Gy'),
('Gi', 'Gx'),
('Gi', 'Gm'),
('Gy', 'Gx'),
('Gy', 'Gm'),
('Gx', 'Gm'),
('Gi', 'Gi', 'Gy'),
('Gi', 'Gi', 'Gx'),
('Gi', 'Gi', 'Gm'),
('Gi', 'Gy', 'Gy'),
('Gi', 'Gy', 'Gx'),
('Gi', 'Gy', 'Gm'),
('Gi', 'Gx', 'Gy'),
('Gi', 'Gx', 'Gx'),
('Gi', 'Gx', 'Gm'),
('Gi', 'Gm', 'Gy'),
('Gi', 'Gm', 'Gx'),
('Gi', 'Gm', 'Gm'),
('Gy', 'Gy', 'Gx'),
('Gy', 'Gy', 'Gm'),
('Gy', 'Gx', 'Gx'),
('Gy', 'Gx', 'Gm'),
('Gy', 'Gm', 'Gx'),
('Gy', 'Gm', 'Gm'),
('Gx', 'Gx', 'Gm'),
('Gx', 'Gm', 'Gm')])

In [4]:
#Note above construction is now a "standard" qutrit gateset
from pygsti.construction import stdQT_XYIMS
gs_target = stdQT_XYIMS.gs_target
fiducialPrep = stdQT_XYIMS.prepStrs
fiducialMeasure = stdQT_XYIMS.effectStrs
germs = stdQT_XYIMS.germs_lite
maxLengths = [1,2,4]

In [5]:
print("%d prep fiducials" % len(fiducialPrep))
print("%d meas fiducials" % len(fiducialMeasure))
print("%d germs" % len(germs))

9 prep fiducials
7 meas fiducials
31 germs

In [6]:
#generate data template
expList = pygsti.construction.make_lsgst_experiment_list(gs_target.gates.keys(), fiducialPrep, fiducialMeasure, germs,  maxLengths)
pygsti.io.write_empty_dataset("example_files/dataTemplate_qutrit_maxL=4.txt", expList, "## Columns = 0bright count, 1bright count, 2bright count")


At this point STOP and create/fill a dataset file using the template written in the above cell. Then proceed with the lines below to run GST on the data and create (hopefully useful) reports telling you about your gates.

In [7]:
gs_datagen = gs_target.depolarize(gate_noise=0.05)
DS = pygsti.construction.generate_fake_data(gs_datagen, expList, 500, sampleError='multinomial', seed=2018)

In [8]:
#DS = pygsti.io.load_dataset('PATH_TO_YOUR_DATASET',cache=True) # (cache=True speeds up future loads)

In [9]:
#Run qutrit GST... which could take a while on a single CPU.  Please adjust memLimit to machine specs
# (now 3GB; usually set to slightly less than the total machine memory)
result = pygsti.do_stdpractice_gst(DS,gs_target,fiducialPrep,fiducialMeasure,germs,maxLengths,
verbosity=2, comm=None, memLimit=3*(1024)**3, modes="TP,CPTP")

-- Std Practice:  Iter 1 of 2  (TP) --:
--- Gate Sequence Creation ---
--- LGST ---
--- Iterative MLGST: [##################################################] 100.0%  2017 gate strings ---
Iterative MLGST Total Time: 52.6s
-- Performing 'single' gauge optimization on TP estimate --
-- Std Practice:  Iter 2 of 2  (CPTP) --:
--- Gate Sequence Creation ---
--- Iterative MLGST: [##################################################] 100.0%  2017 gate strings ---
Iterative MLGST Total Time: 209.4s
-- Performing 'single' gauge optimization on CPTP estimate --

In [10]:
#Create a report
ws = pygsti.report.create_standard_report(result, "example_files/sampleQutritReport",
"Example Qutrit Report", verbosity=3, auto_open=True)

*** Creating workspace ***
*** Generating switchboard ***
*** Generating tables ***
targetSpamBriefTable                          took 0.051113 seconds
targetGatesBoxTable                           took 0.099037 seconds
datasetOverviewTable                          took 0.044839 seconds
bestGatesetSpamParametersTable                took 0.001072 seconds
bestGatesetSpamBriefTable                     took 0.101726 seconds
bestGatesetSpamVsTargetTable                  took 0.336967 seconds
bestGatesetGaugeOptParamsTable                took 0.000825 seconds
bestGatesetGatesBoxTable                      took 0.108126 seconds
bestGatesetChoiEvalTable                      took 0.184795 seconds
bestGatesetDecompTable                        took 20.279342 seconds
bestGatesetEvalTable                          took 0.07094 seconds
bestGermsEvalTable                            took 0.077745 seconds
bestGatesetVsTargetTable                      took 0.467335 seconds
bestGatesVsTargetTable_gv                     took 1.326749 seconds
bestGatesVsTargetTable_gvgerms                took 0.222231 seconds
bestGatesVsTargetTable_gi                     took 0.062404 seconds
bestGatesVsTargetTable_gigerms                took 0.123825 seconds
bestGatesVsTargetTable_sum                    took 1.356266 seconds
bestGatesetErrGenBoxTable                     took 0.482524 seconds
stdoutBlock                                   took 0.000201 seconds
profilerTable                                 took 0.001419 seconds
softwareEnvTable                              took 0.029033 seconds
exampleTable                                  took 0.009125 seconds
singleMetricTable_gv                          took 1.361638 seconds
singleMetricTable_gi                          took 0.058894 seconds
fiducialListTable                             took 0.000553 seconds
prepStrListTable                              took 0.000164 seconds
effectStrListTable                            took 0.000308 seconds
colorBoxPlotKeyPlot                           took 0.009852 seconds
germList2ColTable                             took 0.00058 seconds
progressTable                                 took 1.695682 seconds
*** Generating plots ***
gramBarPlot                                   took 0.102804 seconds
progressBarPlot                               took 0.369781 seconds
progressBarPlot_sum                           took 0.000466 seconds
finalFitComparePlot                           took 0.206067 seconds
bestEstimateColorBoxPlot                      took 15.789486 seconds
bestEstimateTVDColorBoxPlot                   took 15.341477 seconds
bestEstimateColorScatterPlot                  took 16.784239 seconds
bestEstimateColorHistogram                    took 15.062554 seconds
progressTable_scl                             took 9e-05 seconds
progressBarPlot_scl                           took 7.6e-05 seconds
bestEstimateColorBoxPlot_scl                  took 0.000138 seconds
bestEstimateColorScatterPlot_scl              took 0.000158 seconds
bestEstimateColorHistogram_scl                took 0.000148 seconds
dataScalingColorBoxPlot                       took 7.5e-05 seconds
*** Merging into template file ***
Rendering bestGatesetGaugeOptParamsTable      took 0.001492 seconds
Rendering maxLSwitchboard1                    took 0.000218 seconds
Rendering metricSwitchboard_gv                took 7e-05 seconds
Rendering fiducialListTable                   took 0.004093 seconds
Rendering stdoutBlock                         took 0.001403 seconds
Rendering topSwitchboard                      took 0.000101 seconds
Rendering prepStrListTable                    took 0.002382 seconds
Rendering effectStrListTable                  took 0.001865 seconds
Rendering bestGatesVsTargetTable_gigerms      took 0.014631 seconds
Rendering bestGatesetEvalTable                took 0.051873 seconds
Rendering bestGatesVsTargetTable_gv           took 0.006198 seconds
Rendering bestGatesVsTargetTable_gvgerms      took 0.017579 seconds
Rendering bestEstimateColorHistogram_scl      took 0.000785 seconds
Rendering bestGatesetSpamVsTargetTable        took 0.003716 seconds
Rendering metricSwitchboard_gi                took 8.4e-05 seconds
Rendering softwareEnvTable                    took 0.002476 seconds
Rendering bestGatesetSpamBriefTable           took 0.098382 seconds
Rendering bestGermsEvalTable                  took 0.456921 seconds
Rendering singleMetricTable_gv                took 0.007724 seconds
Rendering bestGatesVsTargetTable_sum          took 0.004839 seconds
Rendering progressTable_scl                   took 0.000688 seconds
Rendering profilerTable                       took 0.002918 seconds
Rendering bestGatesVsTargetTable_gi           took 0.006179 seconds
Rendering finalFitComparePlot                 took 0.00246 seconds
Rendering gramBarPlot                         took 0.004367 seconds
Rendering progressBarPlot                     took 0.004613 seconds
Rendering targetGatesBoxTable                 took 0.050087 seconds
Rendering bestGatesetSpamParametersTable      took 0.003062 seconds
Rendering bestGatesetVsTargetTable            took 0.001351 seconds
Rendering bestGatesetDecompTable              took 0.059512 seconds
Rendering bestGatesetErrGenBoxTable           took 0.193599 seconds
Rendering datasetOverviewTable                took 0.000664 seconds
Rendering progressBarPlot_sum                 took 0.004154 seconds
Rendering bestEstimateColorBoxPlot            took 0.073808 seconds
Rendering bestGatesetChoiEvalTable            took 0.084138 seconds
Rendering bestGatesetGatesBoxTable            took 0.108834 seconds
Rendering targetSpamBriefTable                took 0.049526 seconds
Rendering germList2ColTable                   took 0.004814 seconds
Rendering bestEstimateColorBoxPlot_scl        took 0.00075 seconds
Rendering bestEstimateColorHistogram          took 0.031759 seconds
Rendering progressTable                       took 0.005158 seconds
Rendering dataScalingColorBoxPlot             took 0.000763 seconds
Rendering singleMetricTable_gi                took 0.006588 seconds
Rendering bestEstimateColorScatterPlot_scl    took 0.000652 seconds
Rendering colorBoxPlotKeyPlot                 took 0.006283 seconds
Rendering progressBarPlot_scl                 took 0.001271 seconds
Rendering bestEstimateColorScatterPlot        took 0.037859 seconds
Rendering bestEstimateTVDColorBoxPlot         took 0.055111 seconds
Rendering exampleTable                        took 0.004192 seconds
Output written to example_files/sampleQutritReport directory
Opening example_files/sampleQutritReport/main.html...
*** Report Generation Complete!  Total time 94.9789s ***

In [ ]: