This tutorial shows you how to run gate set tomography using the older-style function-centric API. This can be useful in certain scenarios, but most of the time it's easier to use the newer, object-oriented approach outlined in the main GST overview tutorial. For more details and options for running GST, see the GST circuits tutorial and the tutorial covering the different pyGSTi functions for running GST.
To run GST, we need three inputs:
a "target model" which describes the desired, or ideal, operations we want our experimental hardware to perform. In the example below, we use one of pyGSTi's build-in "model packs" (see the tutorial on model packs) - which acts on a single qubit with the following operations:
a list of circuits tailored to the target model; essentially a list of what experiments we need to run. Using a standard model makes things especially straightforward here, since the building blocks, called germ and fiducial circuits, needed to make good GST circuits have already been computed (see the tutorial on GST circuits).
data, in the form of experimental outcome counts, for each of the required sequences. In this example we'll generate "fake" or "simulated" data from a depolarized version of our ideal model. For more information about DataSet
objects, see the tutorial on DataSets.
#Import the pygsti module (always do this) and the XYI model pack
import pygsti
from pygsti.modelpacks import smq1Q_XYI
# 1) get the target Model
target_model = smq1Q_XYI.target_model()
# 2) get the building blocks needed to specify which operation sequences are needed
prep_fiducials, meas_fiducials = smq1Q_XYI.prep_fiducials(), smq1Q_XYI.meas_fiducials()
germs = smq1Q_XYI.germs()
maxLengths = [1,2,4,8,16,32] # roughly gives the length of the sequences used by GST
# 3) generate "fake" data from a depolarized version of target_model
mdl_datagen = target_model.depolarize(op_noise=0.01, spam_noise=0.001)
listOfExperiments = pygsti.circuits.create_lsgst_circuits(
target_model, prep_fiducials, meas_fiducials, germs, maxLengths)
ds = pygsti.data.simulate_data(mdl_datagen, listOfExperiments, num_samples=1000,
sample_error="binomial", seed=1234)
#Note: from listOfExperiments we can also create an empty dataset file
# which has columns of zeros where actual data should go.
pygsti.io.write_empty_dataset("../tutorial_files/GettingStartedDataTemplate.txt", listOfExperiments,
"## Columns = 0 count, 1 count")
# After replacing the zeros with actual data, the data set can be
# loaded back into pyGSTi using the line below and used in the rest
# of this tutorial.
#ds = pygsti.io.load_dataset("tutorial_files/GettingStartedDataTemplate.txt")
Now that we have all of the inputs, we can run GST in a standard way using the run_stdpractice_gst
function. For more information about this and related functions, see the GST methods tutorial. This returns a pygsti.report.Results
object (see the Results tutorial), from which we can generate a report giving us a summary of the analysis.
#Run GST and create a report
results = pygsti.run_stdpractice_gst(ds, target_model, prep_fiducials, meas_fiducials,
germs, maxLengths, verbosity=3)
pygsti.report.construct_standard_report(
results, title="GST Overview Tutorial Example Report", verbosity=2
).write_html("../tutorial_files/gettingStartedReport", verbosity=2)
--- Circuit Creation --- 784 circuits created Dataset has 784 entries: 784 utilized, 0 requested circuits were missing -- Std Practice: Iter 1 of 3 (full TP) --: --- Iterative GST: Iter 1 of 6 92 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 80.4914 (92 data params - 43 (approx) model params = expected mean of 49; p-value = 0.00305059) Completed in 0.3s Iteration 1 took 0.3s --- Iterative GST: Iter 2 of 6 168 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 147.984 (168 data params - 43 (approx) model params = expected mean of 125; p-value = 0.0785975) Completed in 0.2s Iteration 2 took 0.3s --- Iterative GST: Iter 3 of 6 285 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 263.377 (285 data params - 43 (approx) model params = expected mean of 242; p-value = 0.16489) Completed in 0.3s Iteration 3 took 0.4s --- Iterative GST: Iter 4 of 6 448 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 402.715 (448 data params - 43 (approx) model params = expected mean of 405; p-value = 0.522733) Completed in 0.3s Iteration 4 took 0.5s --- Iterative GST: Iter 5 of 6 616 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 574.5 (616 data params - 43 (approx) model params = expected mean of 573; p-value = 0.474504) Completed in 0.4s Iteration 5 took 0.7s --- Iterative GST: Iter 6 of 6 784 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 731.437 (784 data params - 43 (approx) model params = expected mean of 741; p-value = 0.591788) Completed in 0.5s Iteration 6 took 0.9s Last iteration: --- dlogl GST --- 2*Delta(log(L)) = 733.924 (784 data params - 43 (approx) model params = expected mean of 741; p-value = 0.566338) Completed in 1.5s Final optimization took 1.6s Iterative GST Total Time: 4.7s -- Std Practice: Iter 2 of 3 (CPTP) --: --- Iterative GST: Iter 1 of 6 92 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 83.4926 (92 data params - 60 (approx) model params = expected mean of 32; p-value = 1.76926e-06) Completed in 7.2s Iteration 1 took 7.2s --- Iterative GST: Iter 2 of 6 168 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 148.066 (168 data params - 60 (approx) model params = expected mean of 108; p-value = 0.00636252) Completed in 6.1s Iteration 2 took 6.2s --- Iterative GST: Iter 3 of 6 285 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 263.563 (285 data params - 60 (approx) model params = expected mean of 225; p-value = 0.0396886) Completed in 3.0s Iteration 3 took 3.1s --- Iterative GST: Iter 4 of 6 448 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 405.54 (448 data params - 60 (approx) model params = expected mean of 388; p-value = 0.25971) Completed in 2.5s Iteration 4 took 2.7s --- Iterative GST: Iter 5 of 6 616 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 616.91 (616 data params - 60 (approx) model params = expected mean of 556; p-value = 0.0372415) Completed in 6.6s Iteration 5 took 6.8s --- Iterative GST: Iter 6 of 6 784 circuits ---: MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits (None,) *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors. *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups *** --- chi2 GST --- Sum of Chi^2 = 835.363 (784 data params - 60 (approx) model params = expected mean of 724; p-value = 0.00250815) Completed in 8.6s Iteration 6 took 8.8s Last iteration: --- dlogl GST --- 2*Delta(log(L)) = 837.281 (784 data params - 60 (approx) model params = expected mean of 724; p-value = 0.00217365) Completed in 1.1s Final optimization took 1.1s Iterative GST Total Time: 36.0s -- Std Practice: Iter 3 of 3 (Target) --: MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits () *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits () *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits () *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits () *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits () *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions. 1 atoms, parameter block size limits () *** Distributing 1 atoms to 1 atom-processing groups (1 cores) *** More atom-processors than hosts: each host gets ~1 atom-processors Running idle tomography Computing switchable properties Found standard clifford compilation from smq1Q_XYI Found standard clifford compilation from smq1Q_XYI Found standard clifford compilation from smq1Q_XYI
You can now open the file ../tutorial_files/gettingStartedReport/main.html in your browser (Firefox works best) to view the report. That's it! You've just run GST!
In the cell above, results
is a Results
object, which is used to generate a HTML report. For more information see the Results object tutorial and report generation tutorial.