{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "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": { "collapsed": false, "deletable": true, "editable": true }, "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": { "collapsed": false, "deletable": true, "editable": true }, "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.16906 seconds\n", " targetGatesBoxTable took 0.378116 seconds\n", " datasetOverviewTable took 0.009703 seconds\n", " bestGatesetSpamParametersTable took 0.001446 seconds\n", " bestGatesetSpamBriefTable took 0.391437 seconds\n", " bestGatesetSpamVsTargetTable took 0.298641 seconds\n", " bestGatesetGaugeOptParamsTable took 0.00076 seconds\n", " bestGatesetGatesBoxTable took 0.651035 seconds\n", " bestGatesetChoiEvalTable took 0.637294 seconds\n", " bestGatesetDecompTable took 0.475811 seconds\n", " bestGatesetEvalTable took 0.005724 seconds\n", " bestGermsEvalTable took 0.006934 seconds\n", " bestGatesetVsTargetTable took 0.330447 seconds\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Volumes/Research/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 1.139149 seconds\n", " bestGatesVsTargetTable_gvgerms took 0.038396 seconds\n", " bestGatesVsTargetTable_gi took 0.021412 seconds\n", " bestGatesVsTargetTable_gigerms took 0.005911 seconds\n", " bestGatesVsTargetTable_sum took 0.865002 seconds\n", " bestGatesetErrGenBoxTable took 1.31918 seconds\n", " metadataTable took 0.002657 seconds\n", " stdoutBlock took 0.000723 seconds\n", " profilerTable took 0.000535 seconds\n", " softwareEnvTable took 0.075571 seconds\n", " exampleTable took 0.161638 seconds\n", " singleMetricTable_gv took 1.121862 seconds\n", " singleMetricTable_gi took 0.02478 seconds\n", " fiducialListTable took 0.001239 seconds\n", " prepStrListTable took 0.000663 seconds\n", " effectStrListTable took 0.000368 seconds\n", " colorBoxPlotKeyPlot took 0.151012 seconds\n", " germList2ColTable took 0.000362 seconds\n", " progressTable took 0.087719 seconds\n", "*** Generating plots ***\n", " gramBarPlot took 0.15781 seconds\n", " progressBarPlot took 0.144284 seconds\n", " progressBarPlot_sum took 0.000357 seconds\n", " finalFitComparePlot took 0.138099 seconds\n", " bestEstimateColorBoxPlot took 0.465903 seconds\n", " bestEstimateTVDColorBoxPlot took 0.356895 seconds\n", " bestEstimateColorScatterPlot took 0.546223 seconds\n", " bestEstimateColorHistogram took 0.978086 seconds\n", " progressTable_scl took 0.000152 seconds\n", " progressBarPlot_scl took 0.000132 seconds\n", " bestEstimateColorBoxPlot_scl took 0.000175 seconds\n", " bestEstimateColorScatterPlot_scl took 0.000206 seconds\n", " bestEstimateColorHistogram_scl took 0.000174 seconds\n", " dataScalingColorBoxPlot took 0.000165 seconds\n", "*** Merging into template file ***\n", " Rendering topSwitchboard took 0.000218 seconds\n", " Rendering maxLSwitchboard1 took 0.000184 seconds\n", " Rendering targetSpamBriefTable took 0.025499 seconds\n", " Rendering targetGatesBoxTable took 0.016187 seconds\n", " Rendering datasetOverviewTable took 0.001928 seconds\n", " Rendering bestGatesetSpamParametersTable took 0.003243 seconds\n", " Rendering bestGatesetSpamBriefTable took 0.035978 seconds\n", " Rendering bestGatesetSpamVsTargetTable took 0.004375 seconds\n", " Rendering bestGatesetGaugeOptParamsTable took 0.002171 seconds\n", " Rendering bestGatesetGatesBoxTable took 0.031922 seconds\n", " Rendering bestGatesetChoiEvalTable took 0.025492 seconds\n", " Rendering bestGatesetDecompTable took 0.026406 seconds\n", " Rendering bestGatesetEvalTable took 0.035808 seconds\n", " Rendering bestGermsEvalTable took 0.034988 seconds\n", " Rendering bestGatesetVsTargetTable took 0.002644 seconds\n", " Rendering bestGatesVsTargetTable_gv took 0.009397 seconds\n", " Rendering bestGatesVsTargetTable_gvgerms took 0.006992 seconds\n", " Rendering bestGatesVsTargetTable_gi took 0.007429 seconds\n", " Rendering bestGatesVsTargetTable_gigerms took 0.004088 seconds\n", " Rendering bestGatesVsTargetTable_sum took 0.00798 seconds\n", " Rendering bestGatesetErrGenBoxTable took 0.058684 seconds\n", " Rendering metadataTable took 0.009093 seconds\n", " Rendering stdoutBlock took 0.001951 seconds\n", " Rendering profilerTable took 0.002488 seconds\n", " Rendering softwareEnvTable took 0.007481 seconds\n", " Rendering exampleTable took 0.006364 seconds\n", " Rendering metricSwitchboard_gv took 7.9e-05 seconds\n", " Rendering metricSwitchboard_gi took 7.8e-05 seconds\n", " Rendering singleMetricTable_gv took 0.017789 seconds\n", " Rendering singleMetricTable_gi took 0.012233 seconds\n", " Rendering fiducialListTable took 0.006326 seconds\n", " Rendering prepStrListTable took 0.004404 seconds\n", " Rendering effectStrListTable took 0.004182 seconds\n", " Rendering colorBoxPlotKeyPlot took 0.007115 seconds\n", " Rendering germList2ColTable took 0.004818 seconds\n", " Rendering progressTable took 0.003876 seconds\n", " Rendering gramBarPlot took 0.00626 seconds\n", " Rendering progressBarPlot took 0.005394 seconds\n", " Rendering progressBarPlot_sum took 0.003729 seconds\n", " Rendering finalFitComparePlot took 0.004651 seconds\n", " Rendering bestEstimateColorBoxPlot took 0.009858 seconds\n", " Rendering bestEstimateTVDColorBoxPlot took 0.010796 seconds\n", " Rendering bestEstimateColorScatterPlot took 0.008902 seconds\n", " Rendering bestEstimateColorHistogram took 0.010397 seconds\n", " Rendering progressTable_scl took 0.001036 seconds\n", " Rendering progressBarPlot_scl took 0.001325 seconds\n", " Rendering bestEstimateColorBoxPlot_scl took 0.000995 seconds\n", " Rendering bestEstimateColorScatterPlot_scl took 0.001867 seconds\n", " Rendering bestEstimateColorHistogram_scl took 0.001584 seconds\n", " Rendering dataScalingColorBoxPlot took 0.002184 seconds\n", "Output written to example_files/LGSTonlyReport directory\n", "*** Report Generation Complete! Total time 12.9927s ***\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": { "deletable": true, "editable": true }, "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": { "collapsed": true, "deletable": true, "editable": true }, "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.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }