{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to create an LGST-only report\n", "This example shows how you can create a HTML report from just the results of running *linear GST* (LGST). This can be useful when you want to get a rough estimate of your gates quickly, as LGST is takes substantially less data and computation time compared with long-sequence GST. This example is modeled after Tutorial 0." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Only 92 sequences are required!\n" ] } ], "source": [ "#Make print statements compatible with Python 2 and 3\n", "from __future__ import print_function\n", "\n", "#Import the pygsti module (always do this) and the standard XYI gate set\n", "import pygsti\n", "from pygsti.construction import std1Q_XYI\n", "\n", "# 1) get the target GateSet\n", "gs_target = std1Q_XYI.gs_target\n", "\n", "# 2) get the building blocks needed to specify which gate sequences are needed\n", "prep_fiducials, meas_fiducials = std1Q_XYI.prepStrs, std1Q_XYI.effectStrs\n", "\n", "# 3) generate \"fake\" data from a depolarized version of gs_target\n", "gs_datagen = gs_target.depolarize(gate_noise=0.1, spam_noise=0.001)\n", "listOfExperiments = pygsti.construction.list_lgst_gatestrings(\n", " prep_fiducials, meas_fiducials,gs_target)\n", "\n", "ds = pygsti.construction.generate_fake_data(gs_datagen, listOfExperiments, nSamples=1000,\n", " sampleError=\"binomial\", seed=1234)\n", "\n", "#Note: from listOfExperiments we can also create an empty dataset file\n", "# which has columns of zeros where actual data should go. \n", "pygsti.io.write_empty_dataset(\"example_files/LGSTReportDataTemplate.txt\", listOfExperiments,\n", " \"## Columns = 0 count, 1 count\")\n", "# After replacing the zeros with actual data, the data set can be \n", "# loaded back into pyGSTi using the line below and used in the rest\n", "# of this tutorial. \n", "#ds = pygsti.io.load_dataset(\"example_files/LGSTReportDataTemplate.txt\")\n", "\n", "print(\"Only %d sequences are required!\" % len(listOfExperiments))" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Gate Sequence Creation ---\n", " 92 sequences created\n", " Dataset has 92 entries: 92 utilized, 0 requested sequences were missing\n", "--- LGST ---\n", " Singular values of I_tilde (truncating to first 4 of 6) = \n", " 4.244089943192679\n", " 1.1594632778409208\n", " 0.9651516670737965\n", " 0.9297628363691268\n", " 0.049256811347238104\n", " 0.025150658372136828\n", " \n", " Singular values of target I_tilde (truncating to first 4 of 6) = \n", " 4.242640687119286\n", " 1.414213562373096\n", " 1.4142135623730956\n", " 1.4142135623730954\n", " 2.5038933168948026e-16\n", " 2.023452063009528e-16\n", " \n", " -- Adding Gauge Optimized (go0) --\n", "*** Creating workspace ***\n", "*** Generating switchboard ***\n", "Found standard clifford compilation from std1Q_XYI\n", "*** Generating tables ***\n", " targetSpamBriefTable took 1.235729 seconds\n", " targetGatesBoxTable took 0.369447 seconds\n", " datasetOverviewTable took 0.009562 seconds\n", " bestGatesetSpamParametersTable took 0.000647 seconds\n", " bestGatesetSpamBriefTable took 0.478263 seconds\n", " bestGatesetSpamVsTargetTable took 0.28063 seconds\n", " bestGatesetGaugeOptParamsTable took 0.000576 seconds\n", " bestGatesetGatesBoxTable took 0.968307 seconds\n", " bestGatesetChoiEvalTable took 0.956952 seconds\n", " bestGatesetDecompTable took 0.477914 seconds\n", " bestGatesetEvalTable took 0.006816 seconds\n", " bestGermsEvalTable took 0.008426 seconds\n", " bestGatesetVsTargetTable took 0.411192 seconds\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/enielse/research/pyGSTi/packages/pygsti/extras/rb/theory.py:200: UserWarning:\n", "\n", "Output may be unreliable because the gateset is not approximately trace-preserving.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " bestGatesVsTargetTable_gv took 0.545724 seconds\n", " bestGatesVsTargetTable_gvgerms took 0.037678 seconds\n", " bestGatesVsTargetTable_gi took 0.021132 seconds\n", " bestGatesVsTargetTable_gigerms took 0.005475 seconds\n", " bestGatesVsTargetTable_sum took 0.521537 seconds\n", " bestGatesetErrGenBoxTable took 2.61593 seconds\n", " metadataTable took 0.001756 seconds\n", " stdoutBlock took 0.000628 seconds\n", " profilerTable took 0.000634 seconds\n", " softwareEnvTable took 0.083706 seconds\n", " exampleTable took 0.191933 seconds\n", " singleMetricTable_gv took 0.921384 seconds\n", " singleMetricTable_gi took 0.0491 seconds\n", " fiducialListTable took 0.001246 seconds\n", " prepStrListTable took 0.000301 seconds\n", " effectStrListTable took 0.000274 seconds\n", " colorBoxPlotKeyPlot took 0.173564 seconds\n", " germList2ColTable took 0.000331 seconds\n", " progressTable took 0.098303 seconds\n", "*** Generating plots ***\n", " gramBarPlot took 0.204354 seconds\n", " progressBarPlot took 0.172358 seconds\n", " progressBarPlot_sum took 0.000888 seconds\n", " finalFitComparePlot took 0.124989 seconds\n", " bestEstimateColorBoxPlot took 0.891272 seconds\n", " bestEstimateTVDColorBoxPlot took 0.685392 seconds\n", " bestEstimateColorScatterPlot took 0.795307 seconds\n", " bestEstimateColorHistogram took 1.353478 seconds\n", " progressTable_scl took 0.000137 seconds\n", " progressBarPlot_scl took 0.000111 seconds\n", " bestEstimateColorBoxPlot_scl took 0.000151 seconds\n", " bestEstimateColorScatterPlot_scl took 0.000127 seconds\n", " bestEstimateColorHistogram_scl took 0.000129 seconds\n", " dataScalingColorBoxPlot took 0.000156 seconds\n", "*** Merging into template file ***\n", " Rendering topSwitchboard took 0.000182 seconds\n", " Rendering maxLSwitchboard1 took 0.000233 seconds\n", " Rendering targetSpamBriefTable took 0.015131 seconds\n", " Rendering targetGatesBoxTable took 0.014844 seconds\n", " Rendering datasetOverviewTable took 0.001006 seconds\n", " Rendering bestGatesetSpamParametersTable took 0.003498 seconds\n", " Rendering bestGatesetSpamBriefTable took 0.026899 seconds\n", " Rendering bestGatesetSpamVsTargetTable took 0.003483 seconds\n", " Rendering bestGatesetGaugeOptParamsTable took 0.001728 seconds\n", " Rendering bestGatesetGatesBoxTable took 0.020163 seconds\n", " Rendering bestGatesetChoiEvalTable took 0.021533 seconds\n", " Rendering bestGatesetDecompTable took 0.029696 seconds\n", " Rendering bestGatesetEvalTable took 0.039353 seconds\n", " Rendering bestGermsEvalTable took 0.027064 seconds\n", " Rendering bestGatesetVsTargetTable took 0.001184 seconds\n", " Rendering bestGatesVsTargetTable_gv took 0.007884 seconds\n", " Rendering bestGatesVsTargetTable_gvgerms took 0.005033 seconds\n", " Rendering bestGatesVsTargetTable_gi took 0.005641 seconds\n", " Rendering bestGatesVsTargetTable_gigerms took 0.00431 seconds\n", " Rendering bestGatesVsTargetTable_sum took 0.006771 seconds\n", " Rendering bestGatesetErrGenBoxTable took 0.036544 seconds\n", " Rendering metadataTable took 0.007158 seconds\n", " Rendering stdoutBlock took 0.000737 seconds\n", " Rendering profilerTable took 0.001603 seconds\n", " Rendering softwareEnvTable took 0.006575 seconds\n", " Rendering exampleTable took 0.006762 seconds\n", " Rendering metricSwitchboard_gv took 6.5e-05 seconds\n", " Rendering metricSwitchboard_gi took 6.2e-05 seconds\n", " Rendering singleMetricTable_gv took 0.018323 seconds\n", " Rendering singleMetricTable_gi took 0.008598 seconds\n", " Rendering fiducialListTable took 0.004732 seconds\n", " Rendering prepStrListTable took 0.002909 seconds\n", " Rendering effectStrListTable took 0.00277 seconds\n", " Rendering colorBoxPlotKeyPlot took 0.003855 seconds\n", " Rendering germList2ColTable took 0.003515 seconds\n", " Rendering progressTable took 0.002347 seconds\n", " Rendering gramBarPlot took 0.003344 seconds\n", " Rendering progressBarPlot took 0.002157 seconds\n", " Rendering progressBarPlot_sum took 0.002193 seconds\n", " Rendering finalFitComparePlot took 0.003555 seconds\n", " Rendering bestEstimateColorBoxPlot took 0.00608 seconds\n", " Rendering bestEstimateTVDColorBoxPlot took 0.009856 seconds\n", " Rendering bestEstimateColorScatterPlot took 0.005814 seconds\n", " Rendering bestEstimateColorHistogram took 0.005763 seconds\n", " Rendering progressTable_scl took 0.000789 seconds\n", " Rendering progressBarPlot_scl took 0.000805 seconds\n", " Rendering bestEstimateColorBoxPlot_scl took 0.000696 seconds\n", " Rendering bestEstimateColorScatterPlot_scl took 0.001393 seconds\n", " Rendering bestEstimateColorHistogram_scl took 0.001289 seconds\n", " Rendering dataScalingColorBoxPlot took 0.001362 seconds\n", "Output written to example_files/LGSTonlyReport directory\n", "*** Report Generation Complete! Total time 15.5439s ***\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Run LGST and create a report\n", "# You can also eliminate gauge optimization step by setting gaugeOptParams=False\n", "results = pygsti.do_linear_gst(ds, gs_target, prep_fiducials, meas_fiducials)\n", "\n", "pygsti.report.create_standard_report(results, filename=\"example_files/LGSTonlyReport\",\n", " title=\"LGST-only Example Report\", verbosity=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Click to open the file [example_files/LGSTonlyReport/main.html](example_files/LGSTonlyReport/main.html) in your browser to view the report." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" } }, "nbformat": 4, "nbformat_minor": 2 }