{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pygsti" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "#Construct a target gateset\n", "gs_target = pygsti.construction.build_gateset(\n", " [2],[('Q0',)], \n", " ['Gi','Gx','Gy'], [ \"I(Q0)\",\"X(pi/2,Q0)\", \"Y(pi/2,Q0)\"],\n", " ['rho'], [\"0\"], ['E'], [\"1\"], \n", " spamdefs={'plus': ('rho','E'), 'minus': ('rho','remainder') } )" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "#Create gate string lists\n", "fiducials = pygsti.construction.gatestring_list( \n", " [ (), ('Gx',), ('Gy',), ('Gx','Gx'), ('Gx','Gx','Gx'), ('Gy','Gy','Gy') ])\n", "\n", "germs = pygsti.construction.gatestring_list(\n", " [('Gx',), ('Gy',), ('Gi',), ('Gx', 'Gy',),\n", " ('Gx', 'Gy', 'Gi',), ('Gx', 'Gi', 'Gy',), ('Gx', 'Gi', 'Gi',), ('Gy', 'Gi', 'Gi',),\n", " ('Gx', 'Gx', 'Gi', 'Gy',), ('Gx', 'Gy', 'Gy', 'Gi',),\n", " ('Gx', 'Gx', 'Gy', 'Gx', 'Gy', 'Gy',)] )\n", "\n", "maxLengths = [0,1,2,4,8,16,32,64,128,256]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading data_fig2a-b.txt: 100%\n", "LGST: Singular values of I_tilde (truncating to first 4 of 6) = \n", "[ 4.24586359 1.30508754 1.2879726 1.20334079 0.1367596 0.04881866]\n", "\n", "--- LGST ---\n", "\n", "--- Gauge Optimization to TP (L-BFGS-B) ---\n", " 3s 0.0000053422\n", " 3s 0.0000050820\n", " 3s 0.0000050150\n", " 3s 0.0000049605\n", " 3s 0.0000049265\n", " 3s 0.0000049245\n", "The resulting TP penalty is: 4.92453e-06\n", "The gauge matrix found (B^-1) is:\n", "[[ 1.00084963e+00 6.58121924e-04 9.96163862e-05 -2.12656490e-04]\n", " [ -4.81593908e-06 9.99994881e-01 -2.01770872e-06 -5.24774897e-07]\n", " [ 3.05672731e-06 -2.08333085e-06 9.99988550e-01 -2.23119406e-06]\n", " [ 1.02460071e-06 -4.56830666e-07 -2.20199169e-06 9.99999103e-01]]\n", "\n", "The gauge-corrected gates are:\n", "rho = 0.7071 -0.0162 -0.0205 0.7207\n", "\n", "\n", "E = 0.7124 -0.1110 0.0855 -0.6365\n", "\n", "\n", "Gi = \n", " 0.9995 -0.0002 -0.0005 0\n", " 0.0252 0.9350 -0.0068 0.0251\n", " 0.0039 0.0438 0.9507 0.0502\n", " -0.0163 -0.0393 -0.0116 0.8124\n", "\n", "\n", "Gx = \n", " 0.9991 -0.0010 0 -0.0001\n", " 0.0135 0.9679 -0.0171 0.0011\n", " 0.0607 -0.0616 0.1131 -1.0001\n", " 0.0166 -0.1043 1.0074 -0.0017\n", "\n", "\n", "Gy = \n", " 0.9993 0.0002 0.0014 0.0002\n", " -0.0237 0.2515 -0.0826 0.9562\n", " 0.0149 -0.0694 0.8567 0.1207\n", " 0.0161 -0.9981 0.1257 0.0020\n", "\n", "\n", "\n", "\n", "--- Iterative MLEGST: Beginning iter 1 of 10 : 92 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 92.9039 (92 data params - 31 model params = expected mean of 61; p-value = 0.00528702)\n", " 2*Delta(log(L)) = 96.593\n", "\n", "--- Iterative MLEGST: Beginning iter 2 of 10 : 92 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 92.9039 (92 data params - 31 model params = expected mean of 61; p-value = 0.00528703)\n", " 2*Delta(log(L)) = 96.591\n", "\n", "--- Iterative MLEGST: Beginning iter 3 of 10 : 168 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 417.941 (168 data params - 31 model params = expected mean of 137; p-value = 0)\n", " 2*Delta(log(L)) = 437.644\n", "\n", "--- Iterative MLEGST: Beginning iter 4 of 10 : 441 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 1051.29 (441 data params - 31 model params = expected mean of 410; p-value = 0)\n", " 2*Delta(log(L)) = 1042.8\n", "\n", "--- Iterative MLEGST: Beginning iter 5 of 10 : 817 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 1910.36 (817 data params - 31 model params = expected mean of 786; p-value = 0)\n", " 2*Delta(log(L)) = 1872.16\n", "\n", "--- Iterative MLEGST: Beginning iter 6 of 10 : 1201 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 3467.2 (1201 data params - 31 model params = expected mean of 1170; p-value = 0)\n", " 2*Delta(log(L)) = 3371.9\n", "\n", "--- Iterative MLEGST: Beginning iter 7 of 10 : 1585 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 5023.43 (1585 data params - 31 model params = expected mean of 1554; p-value = 0)\n", " 2*Delta(log(L)) = 4924.16\n", "\n", "--- Iterative MLEGST: Beginning iter 8 of 10 : 1969 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 7890.69 (1969 data params - 31 model params = expected mean of 1938; p-value = 0)\n", " 2*Delta(log(L)) = 7873.46\n", "\n", "--- Iterative MLEGST: Beginning iter 9 of 10 : 2353 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 12056.1 (2353 data params - 31 model params = expected mean of 2322; p-value = 0)\n", " 2*Delta(log(L)) = 12310.7\n", "\n", "--- Iterative MLEGST: Beginning iter 10 of 10 : 2737 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 17374.6 (2737 data params - 31 model params = expected mean of 2706; p-value = 0)\n", " 2*Delta(log(L)) = 17985.9\n", "--- Last Iteration: switching to MLE objective ---\n", "--- MLEGST ---\n", " Maximum log(L) = 8737.66 below upper bound of -425300\n", " 2*Delta(log(L)) = 17475.3 (2737 data params - 31 model params = expected mean of 2706; p-value = 0)\n", " 2*Delta(log(L)) = 17475.3\n" ] } ], "source": [ "# results for figure 2 panes a and b\n", "results_fig2ab = pygsti.do_long_sequence_gst(\"data_fig2a-b.txt\", gs_target, \n", " fiducials, fiducials, germs, maxLengths,\n", " gaugeOptRatio=1e-3)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading data_fig2c-d.txt: 100%\n", "LGST: Singular values of I_tilde (truncating to first 4 of 6) = \n", "[ 4.25161905 1.20765431 1.16758021 1.06053321 0.1816105 0.01870529]\n", "\n", "--- LGST ---\n", "\n", "--- Gauge Optimization to TP (L-BFGS-B) ---\n", " 47s 0.0000484570\n", " 47s 0.0000476395\n", " 47s 0.0000468257\n", " 47s 0.0000465566\n", " 47s 0.0000464047\n", " 47s 0.0000463985\n", "The resulting TP penalty is: 4.63985e-05\n", "The gauge matrix found (B^-1) is:\n", "[[ 1.00176521e+00 -3.96648348e-04 9.84125986e-04 -1.32499087e-03]\n", " [ 2.40342311e-05 9.99991010e-01 -2.72573808e-05 1.36951510e-07]\n", " [ 1.10608365e-04 -2.73229992e-05 9.99849864e-01 -4.58545453e-06]\n", " [ -4.50385826e-08 -4.07557971e-08 -4.14817370e-06 9.99997147e-01]]\n", "\n", "The gauge-corrected gates are:\n", "rho = 0.7071 -0.0449 -0.0039 0.7156\n", "\n", "\n", "E = 0.7036 -0.0303 0.0352 -0.5866\n", "\n", "\n", "Gi = \n", " 0.9963 0.0009 0.0051 0.0002\n", " -0.0418 1.1015 0.2361 0.0179\n", " 0.1102 0.1978 1.0495 0.0176\n", " 0.0033 -0.0907 -0.1550 1.0122\n", "\n", "\n", "Gx = \n", " 0.9991 -0.0003 0.0004 -0.0004\n", " -0.0225 1.1079 0.0005 0.0007\n", " 0.0102 -0.1553 0.0250 -0.9993\n", " 0.0618 -0.0336 1.0086 -0.0107\n", "\n", "\n", "Gy = \n", " 0.9982 0.0006 0.0006 -0.0007\n", " 0.0146 -0.1303 -0.0629 1.0440\n", " -0.0026 -0.0241 0.9926 0.0098\n", " -0.0128 -1.0127 0.0312 -0.1211\n", "\n", "\n", "\n", "\n", "--- Iterative MLEGST: Beginning iter 1 of 10 : 92 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 97.5681 (92 data params - 31 model params = expected mean of 61; p-value = 0.00204134)\n", " 2*Delta(log(L)) = 104.929\n", "\n", "--- Iterative MLEGST: Beginning iter 2 of 10 : 92 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 97.5681 (92 data params - 31 model params = expected mean of 61; p-value = 0.00204134)\n", " 2*Delta(log(L)) = 104.918\n", "\n", "--- Iterative MLEGST: Beginning iter 3 of 10 : 168 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 337.618 (168 data params - 31 model params = expected mean of 137; p-value = 0)\n", " 2*Delta(log(L)) = 362.15\n", "\n", "--- Iterative MLEGST: Beginning iter 4 of 10 : 441 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 1171.8 (441 data params - 31 model params = expected mean of 410; p-value = 0)\n", " 2*Delta(log(L)) = 1240.18\n", "\n", "--- Iterative MLEGST: Beginning iter 5 of 10 : 817 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 2648.07 (817 data params - 31 model params = expected mean of 786; p-value = 0)\n", " 2*Delta(log(L)) = 2760.76\n", "\n", "--- Iterative MLEGST: Beginning iter 6 of 10 : 1201 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 4733 (1201 data params - 31 model params = expected mean of 1170; p-value = 0)\n", " 2*Delta(log(L)) = 4878.05\n", "\n", "--- Iterative MLEGST: Beginning iter 7 of 10 : 1585 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 8145.73 (1585 data params - 31 model params = expected mean of 1554; p-value = 0)\n", " 2*Delta(log(L)) = 8384.23\n", "\n", "--- Iterative MLEGST: Beginning iter 8 of 10 : 1969 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 12512.8 (1969 data params - 31 model params = expected mean of 1938; p-value = 0)\n", " 2*Delta(log(L)) = 13042.9\n", "\n", "--- Iterative MLEGST: Beginning iter 9 of 10 : 2353 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 16715.3 (2353 data params - 31 model params = expected mean of 2322; p-value = 0)\n", " 2*Delta(log(L)) = 17508.3\n", "\n", "--- Iterative MLEGST: Beginning iter 10 of 10 : 2737 gate strings ---\n", "--- Least Squares GST ---\n", " Sum of Chi^2 = 20852.1 (2737 data params - 31 model params = expected mean of 2706; p-value = 0)\n", " 2*Delta(log(L)) = 21817.2\n", "--- Last Iteration: switching to MLE objective ---\n", "--- MLEGST ---\n", " Maximum log(L) = 10640.9 below upper bound of -427470\n", " 2*Delta(log(L)) = 21281.8 (2737 data params - 31 model params = expected mean of 2706; p-value = 0)\n", " 2*Delta(log(L)) = 21281.8\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/enielse/research/pyGSTi/packages/pygsti/drivers/longsequence.py:191: UserWarning: Could not gauge optimize to TP (penalty=4.63985e-05), so contracted LGST gateset to TP\n", " _warnings.warn(\"Could not gauge optimize to TP (penalty=%g), so contracted LGST gateset to TP\" % minPenalty)\n" ] } ], "source": [ "# results for figure 2 panes c and d\n", "results_fig2cd = pygsti.do_long_sequence_gst(\"data_fig2c-d.txt\", gs_target, \n", " fiducials, fiducials, germs, maxLengths,\n", " gaugeOptRatio=1e-3)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "*** Generating tables ***\n", "Generating targetSpamTable table...\n", "Generating targetGatesTable table...\n", "Generating datasetOverviewTable table...\n", "Generating bestGatesetSpamTable table...\n", "Generating bestGatesetSpamParametersTable table...\n", "Generating bestGatesetGatesTable table...\n", "Generating bestGatesetChoiTable table...\n", "Generating bestGatesetDecompTable table...\n", "Generating bestGatesetRotnAxisTable table...\n", "Generating bestGatesetClosestUnitaryTable table...\n", "Generating bestGatesetVsTargetTable table...\n", "Generating bestGatesetErrorGenTable table...\n", "Generating fiducialListTable table...\n", "Generating prepStrListTable table...\n", "Generating effectStrListTable table...\n", "Generating germListTable table...\n", "Generating logLProgressTable table...\n", "*** Generating plots ***\n", " -- LogL plots (2): 1 Generating bestEstimateColorBoxPlot figure...\n", "2 Generating invertedBestEstimateColorBoxPlot figure...\n", "\n", "*** Merging into template file ***\n", "Latex file(s) successfully generated. Attempting to compile with pdflatex...\n", "Initial output PDF results_fig2ab.pdf successfully generated.\n", "Final output PDF results_fig2ab.pdf successfully generated. Cleaning up .aux and .log files.\n" ] } ], "source": [ "results_fig2ab.create_full_report_pdf(filename=\"results_fig2ab.pdf\", verbosity=2)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "*** Generating tables ***\n", "Generating targetSpamTable table...\n", "Generating targetGatesTable table...\n", "Generating datasetOverviewTable table...\n", "Generating bestGatesetSpamTable table...\n", "Generating bestGatesetSpamParametersTable table...\n", "Generating bestGatesetGatesTable table...\n", "Generating bestGatesetChoiTable table...\n", "Generating bestGatesetDecompTable table...\n", "Generating bestGatesetRotnAxisTable table...\n", "Generating bestGatesetClosestUnitaryTable table...\n", "Generating bestGatesetVsTargetTable table...\n", "Generating bestGatesetErrorGenTable table...\n", "Generating fiducialListTable table...\n", "Generating prepStrListTable table...\n", "Generating effectStrListTable table...\n", "Generating germListTable table...\n", "Generating logLProgressTable table...\n", "*** Generating plots ***\n", " -- LogL plots (2): 1 Generating bestEstimateColorBoxPlot figure...\n", "2 Generating invertedBestEstimateColorBoxPlot figure...\n", "\n", "*** Merging into template file ***\n", "Latex file(s) successfully generated. Attempting to compile with pdflatex...\n", "Initial output PDF results_fig2cd.pdf successfully generated.\n", "Final output PDF results_fig2cd.pdf successfully generated. Cleaning up .aux and .log files.\n" ] } ], "source": [ "results_fig2cd.create_full_report_pdf(filename=\"results_fig2cd.pdf\", verbosity=2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.3" } }, "nbformat": 4, "nbformat_minor": 0 }