{ "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 model\n", "import pygsti\n", "from pygsti.construction import std1Q_XYI\n", "\n", "# 1) get the target Model\n", "target_model = std1Q_XYI.target_model()\n", "\n", "# 2) get the building blocks needed to specify which operation 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 target_model\n", "mdl_datagen = target_model.depolarize(op_noise=0.1, spam_noise=0.001)\n", "listOfExperiments = pygsti.construction.list_lgst_circuits(\n", " prep_fiducials, meas_fiducials,target_model)\n", "\n", "ds = pygsti.construction.generate_fake_data(mdl_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": [ "--- Circuit 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" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/enielse/research/pyGSTi/packages/pygsti/report/factory.py:785: UserWarning:\n", "\n", "Idle tomography failed:\n", "Label{layers}\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " targetSpamBriefTable took 0.439511 seconds\n", " targetGatesBoxTable took 0.105407 seconds\n", " datasetOverviewTable took 0.002656 seconds\n", " bestGatesetSpamParametersTable took 0.000306 seconds\n", " bestGatesetSpamBriefTable took 0.11465 seconds\n", " bestGatesetSpamVsTargetTable took 0.054331 seconds\n", " bestGatesetGaugeOptParamsTable took 0.000295 seconds\n", " bestGatesetGatesBoxTable took 0.16459 seconds\n", " bestGatesetChoiEvalTable took 0.25505 seconds\n", " bestGatesetDecompTable took 0.121263 seconds\n", " bestGatesetEvalTable took 0.002692 seconds\n", " bestGermsEvalTable took 0.00223 seconds\n", " bestGatesetVsTargetTable took 0.026768 seconds\n", " bestGatesVsTargetTable_gv took 0.154202 seconds\n", " bestGatesVsTargetTable_gvgerms took 0.019521 seconds\n", " bestGatesVsTargetTable_gi took 0.006878 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 model is not approximately trace-preserving.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " bestGatesVsTargetTable_gigerms took 0.002548 seconds\n", " bestGatesVsTargetTable_sum took 0.150735 seconds\n", " bestGatesetErrGenBoxTable took 0.49217 seconds\n", " metadataTable took 0.000681 seconds\n", " stdoutBlock took 0.000232 seconds\n", " profilerTable took 0.00023 seconds\n", " softwareEnvTable took 0.025497 seconds\n", " exampleTable took 0.136048 seconds\n", " singleMetricTable_gv took 0.148717 seconds\n", " singleMetricTable_gi took 0.008322 seconds\n", " fiducialListTable took 0.000492 seconds\n", " prepStrListTable took 0.000114 seconds\n", " effectStrListTable took 0.000117 seconds\n", " colorBoxPlotKeyPlot took 0.039629 seconds\n", " germList2ColTable took 0.000154 seconds\n", " progressTable took 0.043507 seconds\n", "*** Generating plots ***\n", " gramBarPlot took 0.062528 seconds\n", " progressBarPlot took 0.031082 seconds\n", " progressBarPlot_sum took 0.00023 seconds\n", " finalFitComparePlot took 0.031786 seconds\n", " bestEstimateColorBoxPlot took 0.251136 seconds\n", " bestEstimateTVDColorBoxPlot took 0.237004 seconds\n", " bestEstimateColorScatterPlot took 0.312536 seconds\n", " bestEstimateColorHistogram took 0.395233 seconds\n", " progressTable_scl took 7.4e-05 seconds\n", " progressBarPlot_scl took 6.1e-05 seconds\n", " bestEstimateColorBoxPlot_scl took 6.2e-05 seconds\n", " bestEstimateColorScatterPlot_scl took 7.1e-05 seconds\n", " bestEstimateColorHistogram_scl took 5.5e-05 seconds\n", " dataScalingColorBoxPlot took 5e-05 seconds\n", "*** Merging into template file ***\n", " Rendering topSwitchboard took 0.000175 seconds\n", " Rendering maxLSwitchboard1 took 8.8e-05 seconds\n", " Rendering targetSpamBriefTable took 0.143707 seconds\n", " Rendering targetGatesBoxTable took 0.053667 seconds\n", " Rendering datasetOverviewTable took 0.001131 seconds\n", " Rendering bestGatesetSpamParametersTable took 0.001393 seconds\n", " Rendering bestGatesetSpamBriefTable took 0.120301 seconds\n", " Rendering bestGatesetSpamVsTargetTable took 0.00193 seconds\n", " Rendering bestGatesetGaugeOptParamsTable took 0.001109 seconds\n", " Rendering bestGatesetGatesBoxTable took 0.106561 seconds\n", " Rendering bestGatesetChoiEvalTable took 0.104323 seconds\n", " Rendering bestGatesetDecompTable took 0.065894 seconds\n", " Rendering bestGatesetEvalTable took 0.012923 seconds\n", " Rendering bestGermsEvalTable took 0.012595 seconds\n", " Rendering bestGatesetVsTargetTable took 0.001274 seconds\n", " Rendering bestGatesVsTargetTable_gv took 0.002533 seconds\n", " Rendering bestGatesVsTargetTable_gvgerms took 0.001634 seconds\n", " Rendering bestGatesVsTargetTable_gi took 0.002631 seconds\n", " Rendering bestGatesVsTargetTable_gigerms took 0.001513 seconds\n", " Rendering bestGatesVsTargetTable_sum took 0.002331 seconds\n", " Rendering bestGatesetErrGenBoxTable took 0.234166 seconds\n", " Rendering metadataTable took 0.002701 seconds\n", " Rendering stdoutBlock took 0.001029 seconds\n", " Rendering profilerTable took 0.001149 seconds\n", " Rendering softwareEnvTable took 0.002281 seconds\n", " Rendering exampleTable took 0.023044 seconds\n", " Rendering metricSwitchboard_gv took 4.2e-05 seconds\n", " Rendering metricSwitchboard_gi took 3.2e-05 seconds\n", " Rendering singleMetricTable_gv took 0.00629 seconds\n", " Rendering singleMetricTable_gi took 0.004054 seconds\n", " Rendering fiducialListTable took 0.002669 seconds\n", " Rendering prepStrListTable took 0.001891 seconds\n", " Rendering effectStrListTable took 0.001914 seconds\n", " Rendering colorBoxPlotKeyPlot took 0.026063 seconds\n", " Rendering germList2ColTable took 0.002152 seconds\n", " Rendering progressTable took 0.001472 seconds\n", " Rendering gramBarPlot took 0.026079 seconds\n", " Rendering progressBarPlot took 0.019741 seconds\n", " Rendering progressBarPlot_sum took 0.02079 seconds\n", " Rendering finalFitComparePlot took 0.018475 seconds\n", " Rendering bestEstimateColorBoxPlot took 0.018792 seconds\n", " Rendering bestEstimateTVDColorBoxPlot took 0.020015 seconds\n", " Rendering bestEstimateColorScatterPlot took 0.021861 seconds\n", " Rendering bestEstimateColorHistogram took 0.025072 seconds\n", " Rendering progressTable_scl took 0.000975 seconds\n", " Rendering progressBarPlot_scl took 0.000883 seconds\n", " Rendering bestEstimateColorBoxPlot_scl took 0.000881 seconds\n", " Rendering bestEstimateColorScatterPlot_scl took 0.000816 seconds\n", " Rendering bestEstimateColorHistogram_scl took 0.000689 seconds\n", " Rendering dataScalingColorBoxPlot took 0.000534 seconds\n", "Output written to example_files/LGSTonlyReport directory\n", "*** Report Generation Complete! Total time 5.17539s ***\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, target_model, 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 }