{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Examples of tables and plots available from a `Workspace`\n", "\n", "PyGSTi's `Workspace` object is first a foremost a container and factory for plots and tables. At the most basic level, it can be used to generate nice output based on quantities (e.g. `Model`, `DataSet`, etc. objects) that you've computed or loaded within a notebook. For this, it's useful to call `init_notebook_mode` with `autodisplay=True` (see below) so that you don't have to `.display()` everything - `display()` gets called automatically when a plot or table is created.\n", "\n", "## Getting some results\n", "First, let's run Gate Set Tomography (GST) on the standard 1-qubit model to get some results to play with. We generate a few `DataSet` objects and then call `do_long_sequence_gst` to run GST, generating a `Results` object (essentially a container for `Model` objects). For more details, see the tutorials [GST overview tutorial](../algorithms/GST-Overview.ipynb), the [tutorial on GST functions](../algorithms/GST-Drivers.ipynb), and the [tutorial explaining the Results object](../objects/advanced/Results.ipynb). " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pygsti\n", "from pygsti.construction import std1Q_XYI" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#The usual GST setup: we're going to run GST on the standard XYI 1-qubit model\n", "target_model = std1Q_XYI.target_model()\n", "fiducials = std1Q_XYI.fiducials\n", "germs = std1Q_XYI.germs\n", "maxLengths = [1,2]\n", "listOfExperiments = pygsti.construction.make_lsgst_experiment_list(\n", " target_model.operations.keys(), fiducials, fiducials, germs, maxLengths)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#Create some datasets for analysis\n", "mdl_datagen1 = target_model.depolarize(op_noise=0.1, spam_noise=0.02)\n", "mdl_datagen2 = target_model.depolarize(op_noise=0.05, spam_noise=0.01).rotate(rotate=(0.01,0.01,0.01))\n", "\n", "ds1 = pygsti.construction.generate_fake_data(mdl_datagen1, listOfExperiments, nSamples=1000,\n", " sampleError=\"binomial\", seed=1234)\n", "ds2 = pygsti.construction.generate_fake_data(mdl_datagen2, listOfExperiments, nSamples=1000,\n", " sampleError=\"binomial\", seed=1234)\n", "ds3 = ds1.copy_nonstatic(); ds3.add_counts_from_dataset(ds2); ds3.done_adding_data()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#Run GST on all three datasets\n", "target_model.set_all_parameterizations(\"TP\")\n", "results1 = pygsti.do_long_sequence_gst(ds1, target_model, fiducials, fiducials, germs, maxLengths, verbosity=0)\n", "results2 = pygsti.do_long_sequence_gst(ds2, target_model, fiducials, fiducials, germs, maxLengths, verbosity=0)\n", "results3 = pygsti.do_long_sequence_gst(ds3, target_model, fiducials, fiducials, germs, maxLengths, verbosity=0)\n", "\n", "#make some shorthand variable names for later\n", "tgt = results1.estimates['default'].models['target']\n", "\n", "ds1 = results1.dataset\n", "ds2 = results2.dataset\n", "ds3 = results3.dataset\n", "\n", "mdl1 = results1.estimates['default'].models['go0']\n", "mdl2 = results2.estimates['default'].models['go0']\n", "mdl3 = results3.estimates['default'].models['go0']\n", "\n", "gss = results1.circuit_structs['final']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Gallery of `Workspace` plots and tables.\n", "Now that we have some results, let's create a `Workspace` and make some plots and tables.\n", "\n", "To get tables and plots to display properly, one must run `init_notebook_mode`. The `connected` argument indicates whether you want to rely on an active internet connection. If `True`, then resources will be loaded from the web (e.g. a CDN), and if you save a notebook as HTML the file size may be smaller. If `False`, then all the needed resources (except MathJax) are provided by pyGSTi, and an `offline` directory is automatically created in the same directory as your notebook. This directory contains all the necessary resources, and must \"tag along\" with the notebook and any saved-as-HTML versions of it in order for everything to work. The second argument, `autodisplay`, determines whether tables and plots are automatically displayed when they are created. If `autodisplay=False`, one must call the `display()` member function of a table or plot to display it. " ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
Gate | \">Entanglement Infidelity | Avg. Gate Infidelity | 1/2 Trace Distance | 1/2 Diamond-Dist | Non-unitary Ent. Infidelity | Non-unitary Avg. Gate Infidelity |
---|---|---|---|---|---|---|
Gi | 0.074748 | 0.049832 | 0.076617 | 0.07684 | 0.074477 | 0.049652 |
Gx | 0.077108 | 0.051405 | 0.077591 | 0.077595 | 0.077018 | 0.051345 |
Gy | 0.075148 | 0.050098 | 0.075248 | 0.075267 | 0.07511 | 0.050073 |
Prep/POVM | Infidelity | 1/2 Trace Distance | 1/2 Diamond-Dist |
---|---|---|---|
ρ0 | 0.042489 | 0.043884 | -- |
Mdefault | -0.04177 | 0.042625 | 0.043673 |
L | 2Δ(log L) | k | 2Δ(log L)-k | √2k | Nsigma | Ns | Np | Rating |
---|---|---|---|---|---|---|---|---|
1 | 110.8586 | 61 | 49.85861 | 11.04536 | 4.51 | 92 | 31 | |
2 | 166.8526 | 137 | 29.85256 | 16.55295 | 1.8 | 168 | 31 |
Model | 2Δ(log L) | k | 2Δ(log L)-k | √2k | Nsigma | Ns | Np | Rating |
---|---|---|---|---|---|---|---|---|
GS1 | 166.8526 | 137 | 29.85256 | 16.55295 | 1.8 | 168 | 31 | |
GS2 | 4088.064 | 137 | 3951.064 | 16.55295 | 2×102 | 168 | 31 | |
GS3 | 1006.891 | 137 | 869.8905 | 16.55295 | 52.6 | 168 | 31 |
Gate | Choi matrix (Pauli-Product basis basis) | Eigenvalue Magnitudes |
---|---|---|
Gi | $ \\begin{pmatrix}\n", "0.944851 & 0.010383e^{i0.450\\pi} & 0.007336e^{i0.464\\pi} & 0.001242e^{i0.710\\pi} \\\\ \n", "0.010383e^{-i0.450\\pi} & 0.015242 & 0.003872e^{i0.063\\pi} & 0.001952e^{i0.138\\pi} \\\\ \n", "0.007336e^{-i0.464\\pi} & 0.003872e^{-i0.063\\pi} & 0.020849 & 0.001798e^{-i0.639\\pi} \\\\ \n", "0.001242e^{-i0.710\\pi} & 0.001952e^{-i0.138\\pi} & 0.001798e^{i0.639\\pi} & 0.019058\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gx | $ \\begin{pmatrix}\n", "0.482477 & 0.462924e^{i0.501\\pi} & 0.00285e^{i0.508\\pi} & 0.000055e^{i0.786\\pi} \\\\ \n", "0.462924e^{-i0.501\\pi} & 0.480083 & 0.002985e^{i0.005\\pi} & 0.000079e^{-i0.643\\pi} \\\\ \n", "0.00285e^{-i0.508\\pi} & 0.002985e^{-i0.005\\pi} & 0.019276 & 0.001123e^{i0.486\\pi} \\\\ \n", "0.000055e^{-i0.786\\pi} & 0.000079e^{i0.643\\pi} & 0.001123e^{-i0.486\\pi} & 0.018164\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gy | $ \\begin{pmatrix}\n", "0.480739 & 0.002381e^{i0.514\\pi} & 0.463008e^{i0.500\\pi} & 0.00008e^{-i0.107\\pi} \\\\ \n", "0.002381e^{-i0.514\\pi} & 0.017701 & 0.003456e^{-i0.007\\pi} & 0.000538e^{-i0.531\\pi} \\\\ \n", "0.463008e^{-i0.500\\pi} & 0.003456e^{i0.007\\pi} & 0.484353 & 0.000107e^{i0.420\\pi} \\\\ \n", "0.00008e^{i0.107\\pi} & 0.000538e^{i0.531\\pi} & 0.000107e^{-i0.420\\pi} & 0.017208\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gate | Error Generator | Pauli Hamiltonian Projections | Pauli Stochastic Projections | Pauli Affine Projections |
---|---|---|---|---|
Gi | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gx | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gy | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gate | Eigenvalues ($E$) | Eigenvalues |
---|---|---|
Gi | $ \\begin{pmatrix}\n", "1 \\\\ \n", "0.955547 \\\\ \n", "0.94681e^{i0.008\\pi} \\\\ \n", "0.94681e^{-i0.008\\pi}\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gx | $ \\begin{pmatrix}\n", "1 \\\\ \n", "0.95118 \\\\ \n", "0.949197e^{i0.502\\pi} \\\\ \n", "0.949197e^{-i0.502\\pi}\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gy | $ \\begin{pmatrix}\n", "1 \\\\ \n", "0.957594 \\\\ \n", "0.948507e^{i0.502\\pi} \\\\ \n", "0.948507e^{-i0.502\\pi}\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gate | Ham. Evals. | Rotn. angle | Rotn. axis | Log Error | Axis angle w/Gi | Axis angle w/Gx | Axis angle w/Gy |
---|---|---|---|---|---|---|---|
Gi | $ \\begin{pmatrix}\n", "-0.006835 \\\\ \n", "0.006835\n", " \\end{pmatrix} $\n", "π | 0.009667π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | 0.285541π | 0.222932π | |
Gx | $ \\begin{pmatrix}\n", "-0.350316 \\\\ \n", "0.350316\n", " \\end{pmatrix} $\n", "π | 0.495421π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | 0.285541π | 0.496963π | |
Gy | $ \\begin{pmatrix}\n", "-0.353879 \\\\ \n", "0.353879\n", " \\end{pmatrix} $\n", "π | 0.500461π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | 0.222932π | 0.496963π |
Gate | Ham. Evals. | Rotn. angle | Rotn. axis | Log Error | Axis angle w/Gii | Axis angle w/Gix | Axis angle w/Giy | Axis angle w/Gxi | Axis angle w/Gyi | Axis angle w/Gxx | Axis angle w/Gyy | Axis angle w/Gxy | Axis angle w/Gyx |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gii | $ \\begin{pmatrix}\n", "0 \\\\ \n", "0 \\\\ \n", "0 \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | -- | -- | -- | -- | -- | -- | -- | -- | |
Gix | $ \\begin{pmatrix}\n", "0.25 \\\\ \n", "-0.25 \\\\ \n", "0.25 \\\\ \n", "-0.25\n", " \\end{pmatrix} $\n", "π | 0.5π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | -- | 0.5π | 0.5π | 0.5π | 0.25π | 0.499987π | 0.499985π | 0.25π | |
Giy | $ \\begin{pmatrix}\n", "0.25 \\\\ \n", "-0.25 \\\\ \n", "0.25 \\\\ \n", "-0.25\n", " \\end{pmatrix} $\n", "π | 0.5π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | -- | 0.5π | 0.5π | 0.5π | 0.499994π | 0.25π | 0.25π | 0.499987π | |
Gxi | $ \\begin{pmatrix}\n", "-0.25 \\\\ \n", "0.25 \\\\ \n", "-0.25 \\\\ \n", "0.25\n", " \\end{pmatrix} $\n", "π | 0.5π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | -- | 0.5π | 0.5π | 0.5π | 0.25π | 0.499987π | 0.25π | 0.500015π | |
Gyi | $ \\begin{pmatrix}\n", "0.25 \\\\ \n", "-0.25 \\\\ \n", "0.25 \\\\ \n", "-0.25\n", " \\end{pmatrix} $\n", "π | 0.5π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | -- | 0.5π | 0.5π | 0.5π | 0.499994π | 0.25π | 0.500016π | 0.25π | |
Gxx | $ \\begin{pmatrix}\n", "-0.500003 \\\\ \n", "0.500001 \\\\ \n", "0.000002 \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0.707109π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.005218 | -- | 0.25π | 0.499994π | 0.25π | 0.499994π | 0.499974π | 0.333316π | 0.333341π | |
Gyy | $ \\begin{pmatrix}\n", "-0.500008 \\\\ \n", "0.500009 \\\\ \n", "-5\\times 10^{-7} \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0.707119π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.005607 | -- | 0.499987π | 0.25π | 0.499987π | 0.25π | 0.499974π | 0.333336π | 0.333312π | |
Gxy | $ \\begin{pmatrix}\n", "0.5 \\\\ \n", "-0.499999 \\\\ \n", "0.000001 \\\\ \n", "-0.000001\n", " \\end{pmatrix} $\n", "π | 0.707106π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.008731 | -- | 0.499985π | 0.25π | 0.25π | 0.500016π | 0.333316π | 0.333336π | 0.500002π | |
Gyx | $ \\begin{pmatrix}\n", "0.500007 \\\\ \n", "-0.500005 \\\\ \n", "0 \\\\ \n", "-0.000001\n", " \\end{pmatrix} $\n", "π | 0.707115π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.005198 | -- | 0.25π | 0.499987π | 0.500015π | 0.25π | 0.333341π | 0.333312π | 0.500002π |
Gate | \">Entanglement Infidelity | Avg. Gate Infidelity | 1/2 Trace Distance | 1/2 Diamond-Dist | Non-unitary Ent. Infidelity | Non-unitary Avg. Gate Infidelity |
---|---|---|---|---|---|---|
Gi | 0.074748 | 0.049832 | 0.076617 | 0.07684 | 0.074477 | 0.049652 |
Gx | 0.077108 | 0.051405 | 0.077591 | 0.077595 | 0.077018 | 0.051345 |
Gy | 0.075148 | 0.050098 | 0.075248 | 0.075267 | 0.07511 | 0.050073 |