{ "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.074335 | 0.049557 | 0.076094 | 0.07636 | 0.074098 | 0.049398 |
Gx | 0.076404 | 0.050936 | 0.076851 | 0.076926 | 0.076341 | 0.050894 |
Gy | 0.075533 | 0.050356 | 0.075764 | 0.075785 | 0.0755 | 0.050334 |
Prep/POVM | Infidelity | 1/2 Trace Distance | 1/2 Diamond-Dist |
---|---|---|---|
ρ0 | 0.042312 | 0.043714 | -- |
Mdefault | -0.04156 | 0.042419 | 0.043467 |
L | 2Δ(log L) | k | 2Δ(log L)-k | √2k | Nsigma | Ns | Np | Rating |
---|---|---|---|---|---|---|---|---|
1 | 81.29383 | 61 | 20.29383 | 11.04536 | 1.84 | 92 | 31 | |
2 | 168.6496 | 137 | 31.6496 | 16.55295 | 1.91 | 168 | 31 |
Model | 2Δ(log L) | k | 2Δ(log L)-k | √2k | Nsigma | Ns | Np | Rating |
---|---|---|---|---|---|---|---|---|
GS1 | 168.6496 | 137 | 31.6496 | 16.55295 | 1.91 | 168 | 31 | |
GS2 | 4061.611 | 137 | 3924.611 | 16.55295 | 2×102 | 168 | 31 | |
GS3 | 1002.246 | 137 | 865.2464 | 16.55295 | 52.3 | 168 | 31 |
Gate | Choi matrix (Pauli-Product basis basis) | Eigenvalue Magnitudes |
---|---|---|
Gi | $ \\begin{pmatrix}\n", "0.945004 & 0.009417e^{i0.444\\pi} & 0.006951e^{i0.454\\pi} & 0.001022e^{-i0.776\\pi} \\\\ \n", "0.009417e^{-i0.444\\pi} & 0.015282 & 0.003276e^{i0.076\\pi} & 0.002139e^{i0.155\\pi} \\\\ \n", "0.006951e^{-i0.454\\pi} & 0.003276e^{-i0.076\\pi} & 0.020808 & 0.001819e^{-i0.644\\pi} \\\\ \n", "0.001022e^{i0.776\\pi} & 0.002139e^{-i0.155\\pi} & 0.001819e^{i0.644\\pi} & 0.018906\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gx | $ \\begin{pmatrix}\n", "0.482049 & 0.462895e^{i0.501\\pi} & 0.002898e^{i0.512\\pi} & 0.000548e^{-i0.538\\pi} \\\\ \n", "0.462895e^{-i0.501\\pi} & 0.481094 & 0.004182e^{i0.005\\pi} & 0.000556e^{-i0.065\\pi} \\\\ \n", "0.002898e^{-i0.512\\pi} & 0.004182e^{-i0.005\\pi} & 0.018149 & 0.00183e^{i0.502\\pi} \\\\ \n", "0.000548e^{i0.538\\pi} & 0.000556e^{i0.065\\pi} & 0.00183e^{-i0.502\\pi} & 0.018709\n", " \\end{pmatrix} $\n", " | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" |
Gy | $ \\begin{pmatrix}\n", "0.481416 & 0.003826e^{i0.509\\pi} & 0.462881e^{i0.500\\pi} & 0.00059e^{-i0.430\\pi} \\\\ \n", "0.003826e^{-i0.509\\pi} & 0.018169 & 0.003254e^{-i0.013\\pi} & 0.000502e^{-i0.573\\pi} \\\\ \n", "0.462881e^{-i0.500\\pi} & 0.003254e^{i0.013\\pi} & 0.483841 & 0.000585e^{i0.057\\pi} \\\\ \n", "0.00059e^{i0.430\\pi} & 0.000502e^{i0.573\\pi} & 0.000585e^{-i0.057\\pi} & 0.016574\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.006533 \\\\ \n", "0.006533\n", " \\end{pmatrix} $\n", "π | 0.00924π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | 0.331649π | 0.242237π | |
Gx | $ \\begin{pmatrix}\n", "-0.351156 \\\\ \n", "0.351156\n", " \\end{pmatrix} $\n", "π | 0.496609π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | 0.331649π | 0.495319π | |
Gy | $ \\begin{pmatrix}\n", "-0.353186 \\\\ \n", "0.353186\n", " \\end{pmatrix} $\n", "π | 0.49948π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | 0.242237π | 0.495319π |
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.5π | 0.500009π | 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.499987π | 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.5π | 0.25π | 0.500008π | |
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.499987π | 0.25π | 0.500008π | 0.25π | |
Gxx | $ \\begin{pmatrix}\n", "-0.500005 \\\\ \n", "0.500006 \\\\ \n", "-4\\times 10^{-7} \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0.707114π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.003505 | -- | 0.25π | 0.499987π | 0.25π | 0.499987π | 0.499982π | 0.33333π | 0.33333π | |
Gyy | $ \\begin{pmatrix}\n", "-0.500557 \\\\ \n", "0.500557 \\\\ \n", "0 \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0.707895π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0 | -- | 0.5π | 0.25π | 0.5π | 0.25π | 0.499982π | 0.33334π | 0.333323π | |
Gxy | $ \\begin{pmatrix}\n", "-0.500007 \\\\ \n", "0.500006 \\\\ \n", "0.000001 \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0.707116π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.00368 | -- | 0.500009π | 0.25π | 0.25π | 0.500008π | 0.33333π | 0.33334π | 0.500009π | |
Gyx | $ \\begin{pmatrix}\n", "0.499981 \\\\ \n", "-0.49998 \\\\ \n", "-0.000002 \\\\ \n", "0\n", " \\end{pmatrix} $\n", "π | 0.707079π | \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" | 0.003891 | -- | 0.25π | 0.499987π | 0.500008π | 0.25π | 0.33333π | 0.333323π | 0.500009π |
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.074335 | 0.049557 | 0.076094 | 0.07636 | 0.074098 | 0.049398 |
Gx | 0.076404 | 0.050936 | 0.076851 | 0.076926 | 0.076341 | 0.050894 |
Gy | 0.075533 | 0.050356 | 0.075764 | 0.075785 | 0.0755 | 0.050334 |