{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# An example of how to run GST on a 2-qubit system\n", "This example gives an overview of the typical steps used to perform an end-to-end (i.e. experimental-data-to-report) Gate Set Tomography analysis on a 2-qubit system. The steps are very similar to the single-qubit case described in the tutorials, but we thought 2Q-GST is an important enough topic to deserve a separate example. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "from __future__ import print_function\n", "import pygsti" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Step 1: Construct the desired 2-qubit gateset\n", "Since the purpose of this example is to show how to *run* 2Q-GST, we'll just use a built-in \"standard\" 2-qubit gate set. (Another example covers how to create a custom 2-qubit gate set.)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "from pygsti.construction import std2Q_XYICNOT\n", "gs_target = std2Q_XYICNOT.gs_target.copy() #copying is good practice so we don't inadvertetly mess up std2Q_XYCNOT.gs_target" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Step 2: Obtain lists of fiducial and germ gate sequences\n", "These are the building blocks of the gate sequences performed in the experiment. Typically, these lists are either provided by pyGSTi because you're using a \"standard\" gate set (as we are here), or computed using the \"fiducial selection\" and \"germ selection\" algorithms which are a part of pyGSTi and covered in the tutorials. Since 2Q-GST with the 71 germs of the complete set would take a while, we'll also create a couple of small germ sets to demonstrate 2Q-GST more quickly (because we know you have important stuff to do)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "prep_fiducials = std2Q_XYICNOT.prepStrs\n", "effect_fiducials = std2Q_XYICNOT.effectStrs" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "germs4 = pygsti.construction.gatestring_list(\n", " [ ('Gix',), ('Giy',), ('Gxi',), ('Gyi',) ] )\n", "\n", "germs11 = pygsti.construction.gatestring_list(\n", " [ ('Gix',), ('Giy',), ('Gxi',), ('Gyi',), ('Gcnot',), ('Gxi','Gyi'), ('Gix','Giy'),\n", " ('Gix','Gcnot'), ('Gxi','Gcnot'), ('Giy','Gcnot'), ('Gyi','Gcnot') ] )\n", "\n", "germs71 = std2Q_XYICNOT.germs" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Step 3: Data generation\n", "Now that fiducial and germ strings have been found, we can generate the list of experiments needed to run GST, just like in the 1-qubit case. As an additional input we'll need a list of lengths indicating the maximum length strings to use on each successive GST iteration." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "#A list of maximum lengths for each GST iteration - typically powers of 2 up to\n", "# the longest experiment you can glean information from. Here we just pick 2 so things run quickly.\n", "maxLengths = [1,2] # 4,16,32...\n", "\n", "#Create a list of GST experiments for this gateset, with\n", "#the specified fiducials, germs, and maximum lengths. We use\n", "#\"germs4\" here so that the tutorial runs quickly; really, you'd\n", "#want to use germs71!\n", "listOfExperiments = pygsti.construction.make_lsgst_experiment_list(gs_target.gates.keys(), prep_fiducials,\n", " effect_fiducials, germs4, maxLengths)\n", "\n", "#Create an empty dataset file, which stores the list of experiments\n", "# and zerod-out columns where data should be inserted. Note the use of the SPAM\n", "# labels in the \"Columns\" header line.\n", "pygsti.io.write_empty_dataset(\"example_files/My2QDataTemplate.txt\", listOfExperiments,\n", " \"## Columns = 00 count, 01 count, 10 count, 11 count\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "#Generate some \"fake\" (simulated) data based on a depolarized version of the target gateset\n", "gs_datagen = gs_target.depolarize(gate_noise=0.1, spam_noise=0.001)\n", "ds = pygsti.construction.generate_fake_data(gs_datagen, listOfExperiments, nSamples=1000,\n", " sampleError=\"multinomial\", seed=2016)\n", "\n", "#if you have a dataset file with real data in it, load it using something like:\n", "#ds = pygsti.io.load_dataset(\"mydir/My2QDataset.txt\")" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Step 4: Run GST using `do_long_sequence_gst`\n", "Just like for 1-qubit GST, we call the driver routine `do_long_sequence_gst` to compute the GST estimates. Usually for two qubits this could take a long time (hours on a single cpu) based on the number of gate sequences used, and running on multiple processors is a good idea (see the MPI example). However, since we chose an incomplete set of only 4 germs and set our maximum max-length to 2, this will run fairly quickly (~10min).\n", "\n", "Some notes about the options/arguments to `do_long_sequence_gst` that are particularly relevant to 2-qubit GST:\n", " - `memoryLimit` gives an estimate of how much memory is available to use on your system (in bytes). This is currently *not* a hard limit, and pyGSTi may require slightly more memory than this \"limit\". So you'll need to be conservative in the value you place here: if your machine has 10GB of RAM, set this to 6 or 8 GB initially and increase it as you see how much memory is actually used using a separate OS performance monitor tool. If you're running on multiple processors, this should be the memory available *per processor*.\n", " - `verbosity` tells the routine how much detail to print to stdout. If you don't mind waiting a while without getting any output, you can leave this at its default value (2). If you can't standing wondering whether GST is still running or has locked up, set this to 3.\n", " - `advancedOptions` is a dictionary that accepts various \"advanced\" settings that aren't typically needed. While we don't require its use below, the `depolarizeStart` key of this dictionary may be useful in certain cases: it gives an amount (in [0,1]) to depolarize the (LGST) estimate that is used as the initial guess for long-sequence GST. In practice, we find that, sometime, in the larger 2-qubit Hilbert space, the LGST estimate may be so poor as to adversely affect the subsequent long-sequence GST (e.g. very slow convergence). Depolarizing the LGST estimate can remedy this. If you're unsure what to put here, either don't specify `depolarizeLGST` at all (the same as using 0.0), or just use 0.1, i.e. `advancedOptions={ 'depolarizeStart' : 0.1 }`." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false, "deletable": true, "editable": true, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Gate Sequence Creation ---\n", " 1317 sequences created\n", " Dataset has 1317 entries: 1317 utilized, 0 requested sequences were missing\n", "--- LGST ---\n", " Singular values of I_tilde (truncating to first 16 of 16) = \n", " 6.743595023533244\n", " 2.3759607376543403\n", " 2.2982626315194534\n", " 1.2234016894214428\n", " 1.2092603631138166\n", " 1.197845596409007\n", " 0.8630521970477671\n", " 0.8250150242519823\n", " 0.5374035064345984\n", " 0.5034187331962282\n", " 0.38984451013936156\n", " 0.3295915366884566\n", " 0.3260352451471631\n", " 0.25392875853124547\n", " 0.21973006881050175\n", " 0.1740975572752712\n", " \n", " Singular values of target I_tilde (truncating to first 16 of 16) = \n", " 6.868027641505519\n", " 3.2025374468732157\n", " 3.2025374468732126\n", " 1.769236932225032\n", " 1.7692369322250316\n", " 1.7320508075688772\n", " 1.234004858633701\n", " 1.2247448713915885\n", " 0.7071067811865479\n", " 0.7071067811865478\n", " 0.5000000000000001\n", " 0.49371439251332727\n", " 0.49371439251332716\n", " 0.3461223449171738\n", " 0.34612234491717375\n", " 0.23964207557230052\n", " \n", " Resulting gate set:\n", " \n", " rho0 = 0.5000 0 0 0.5000 0 0 0 0 0 0 0 0 0.5000 0 0 0.5000\n", " \n", " \n", " Mdefault = Unconstrained POVM with effect vectors:\n", " 00:\n", " 0.59\n", " -0.03\n", " 0.01\n", " 0.46\n", " -0.03\n", " -0.06\n", " 0.05\n", " -0.05\n", " 0.04\n", " 0.05\n", " 0.01\n", " 0.04\n", " 0.45\n", " -0.04\n", " 0.03\n", " 0.50\n", " \n", " 01:\n", " 0.50\n", " 0.05\n", " -0.02\n", " -0.46\n", " -0.02\n", " 0\n", " 0.04\n", " 0.04\n", " 0.06\n", " -0.02\n", " 0.03\n", " -0.06\n", " 0.37\n", " 0.03\n", " 0\n", " -0.41\n", " \n", " 10:\n", " 0.50\n", " -0.04\n", " 0.04\n", " 0.36\n", " 0.03\n", " 0.02\n", " -0.06\n", " 0.02\n", " -0.03\n", " -0.05\n", " -0.05\n", " -0.04\n", " -0.45\n", " 0.03\n", " -0.04\n", " -0.40\n", " \n", " 11:\n", " 0.42\n", " 0.01\n", " -0.03\n", " -0.36\n", " 0.02\n", " 0.05\n", " -0.03\n", " -0.02\n", " -0.07\n", " 0.01\n", " 0\n", " 0.06\n", " -0.37\n", " -0.02\n", " 0.02\n", " 0.32\n", " \n", " \n", " \n", " Gii = \n", " 0.9996 0.0003 -0.0002 0 0.0002 -0.0006 -0.0001 0.0002 -0.0006 0.0007 -0.0003 0 0 -0.0001 0 -0.0003\n", " -0.0048 0.9257 0.0147 0.0038 0.0225 -0.0062 -0.0108 -0.0394 -0.0295 -0.0317 -0.0185 -0.0020 -0.0118 -0.0373 -0.0238 -0.0132\n", " -0.0399 0.0249 0.9162 -0.0211 0.0112 -0.0080 -0.0321 0.0154 -0.0495 0.1117 0.0542 -0.0052 -0.0042 0.0482 -0.0041 -0.0023\n", " 0.0014 -0.0224 0.0212 0.9035 -0.0097 0.0360 -0.0386 -0.0037 -0.0032 -0.0398 0.0042 0.0110 -0.0004 -0.0092 -0.0035 -0.0152\n", " -0.0083 0.0105 -0.0232 -0.0187 0.9061 -0.0023 0.0279 -0.0225 -0.0278 0.0897 0.0487 -0.0157 -0.0354 -0.0091 -0.0474 0.0007\n", " 0.0062 0.0417 0.0210 0.0267 -0.0043 0.8167 -0.0645 -0.0964 0.0286 0.1223 0.1680 0.0363 0.0347 -0.0829 0.0041 -0.0028\n", " 0.0009 0.0241 0.0286 -0.0013 -0.0708 -0.0232 0.6969 0.0190 0.0133 0.1107 -0.0810 -0.0079 -0.0732 0.0708 -0.0228 -0.0057\n", " 0.0046 -0.0431 0.0010 0.0016 -0.0307 0.0741 -0.1133 0.8958 0.0414 -0.0799 0.0916 -0.0764 0.0577 -0.0941 -0.0009 -0.0328\n", " -0.0004 0.0079 -0.0660 0.0116 -0.0114 0.0572 0.0624 0.0203 0.8947 0.0427 -0.0190 0.0461 -0.0026 -0.0155 -0.0398 -0.0176\n", " -0.0338 0.0356 0.0099 -0.0156 0.0442 0.0062 -0.0452 -0.0110 0.0222 0.8270 0.1952 0.0239 -0.0482 -0.0227 -0.0144 0.0193\n", " -0.0404 0.0207 -0.0054 -0.0188 0.0332 -0.0375 -0.0071 0.0385 -0.0354 0.1087 0.9074 -0.0624 -0.0223 0.0534 0.0325 -0.0242\n", " -0.0341 0.0390 0.0803 -0.0218 0.0921 -0.1228 -0.0003 -0.0001 -0.0275 0.1906 0.1431 0.9022 -0.0456 0.0777 -0.0907 0.0017\n", " -0.0191 -0.0188 -0.0055 -0.0073 0.0330 -0.0134 -0.0447 0.0046 0.0147 -0.0496 0.0183 0.0112 0.8935 0.0254 0.0217 0.0019\n", " 0.0012 -0.0884 -0.0733 -0.0065 -0.0865 0.0761 0.0732 0.0331 -0.0101 0.0295 -0.1972 0.0287 0.0046 0.9147 0.0343 0.0075\n", " 0.0095 0.0667 -0.0310 -0.0595 -0.0058 -0.1015 0.0661 0.0609 0.0122 0.1237 -0.1213 -0.0094 -0.0464 0.0778 0.7875 -0.0221\n", " -0.0063 0.0045 -0.0261 0.0056 -0.0215 0.0057 -0.0093 -0.0019 0.0032 -0.0362 -0.0051 0.0006 0.0312 -0.0759 0.0348 0.8809\n", " \n", " \n", " Gix = \n", " 0.9998 0 -0.0002 0.0002 0 -0.0004 0 0 -0.0002 -0.0003 -0.0002 0.0002 0 -0.0003 0 0\n", " 0.0193 0.8775 0.0193 -0.0193 -0.0190 0.0732 -0.0190 0.0190 -0.0316 -0.0171 -0.0316 0.0316 -0.0141 0.0212 -0.0141 0.0141\n", " -0.1004 0.1249 -0.1004 -0.8996 0.0313 -0.0927 0.0313 -0.0313 -0.0038 0.0041 -0.0038 0.0038 -0.0074 0.0212 -0.0074 0.0074\n", " -0.0781 0.0486 0.9219 0.0781 -0.0250 0.0809 -0.0250 0.0250 0.0101 -0.0464 0.0101 -0.0101 -0.0098 0.0024 -0.0098 0.0098\n", " 0.0205 -0.0208 0.0205 -0.0205 0.9093 0.0287 -0.0907 0.0907 0.0538 -0.0249 0.0538 -0.0538 -0.0230 -0.0266 -0.0230 0.0230\n", " -0.0123 0.0536 -0.0123 0.0123 0.0185 0.8309 0.0185 -0.0185 0.0142 0.0741 0.0142 -0.0142 -0.0344 -0.0425 -0.0344 0.0344\n", " 0.0007 -0.0650 0.0007 -0.0007 -0.1471 0.0788 -0.1471 -0.8529 0.0335 0.0787 0.0335 -0.0335 -0.0160 0.0526 -0.0160 0.0160\n", " 0.0225 -0.0449 0.0225 -0.0225 -0.1325 0.2155 0.8675 0.1325 -0.0057 -0.0588 -0.0057 0.0057 0.0534 -0.0657 0.0534 -0.0534\n", " -0.0184 0.0257 -0.0184 0.0184 0.0108 -0.0099 0.0108 -0.0108 0.8994 0.0213 -0.1006 0.1006 -0.0156 0.0018 -0.0156 0.0156\n", " 0.0119 -0.0183 0.0119 -0.0119 0.0031 0.0651 0.0031 -0.0031 0.0903 0.7949 0.0903 -0.0903 -0.0265 0.0004 -0.0265 0.0265\n", " 0.0200 -0.0937 0.0200 -0.0200 -0.0415 0.1396 -0.0415 0.0415 -0.1057 0.0572 -0.1057 -0.8943 -0.0041 -0.0212 -0.0041 0.0041\n", " 0.0246 -0.0446 0.0246 -0.0246 0.0305 -0.0112 0.0305 -0.0305 -0.0068 0.0050 0.9932 0.0068 -0.0532 0.0782 -0.0532 0.0532\n", " -0.0123 0.0061 -0.0123 0.0123 -0.0030 -0.0178 -0.0030 0.0030 -0.0069 0.0085 -0.0069 0.0069 0.9094 -0.0158 -0.0906 0.0906\n", " -0.0525 0.0395 -0.0525 0.0525 -0.0129 -0.0762 -0.0129 0.0129 -0.0321 -0.0120 -0.0321 0.0321 0.0102 0.8793 0.0102 -0.0102\n", " -0.0110 0.0218 -0.0110 0.0110 -0.0251 -0.0081 -0.0251 0.0251 0.0350 0.0876 0.0350 -0.0350 -0.1074 0.1215 -0.1074 -0.8926\n", " -0.0198 0.0010 -0.0198 0.0198 0.0103 -0.0113 0.0103 -0.0103 -0.0442 -0.0595 -0.0442 0.0442 -0.0635 0.0169 0.9365 0.0635\n", " \n", " \n", " Giy = \n", " 0.9997 -0.0002 -0.0003 0.0003 0.0006 0 0.0005 -0.0006 -0.0003 -0.0002 0.0001 0.0003 0.0001 0.0003 -0.0003 -0.0001\n", " 0.0890 -0.0800 0.0942 0.9110 0.0180 -0.0251 0.0093 -0.0180 -0.0391 -0.0302 -0.0966 0.0391 0.0034 -0.0158 0.0165 -0.0034\n", " -0.0089 -0.0115 0.9199 0.0089 0.0109 0.0548 0.0036 -0.0109 -0.0293 0.0351 0.0451 0.0293 -0.0114 -0.0103 -0.0241 0.0114\n", " -0.0946 -0.8946 -0.0848 0.0946 -0.0153 0.0028 0.0144 0.0153 -0.0199 -0.0144 -0.0277 0.0199 0.0027 0.0019 0.0204 -0.0027\n", " 0.0096 0.0166 0.0174 -0.0096 0.8866 0.0896 -0.0173 0.1134 0.0045 0.0023 0.0710 -0.0045 0.0114 -0.0150 0.0110 -0.0114\n", " -0.0275 -0.0171 0.0091 0.0275 0.1901 -0.1209 0.1408 0.8099 -0.0292 -0.0119 -0.0429 0.0292 -0.0136 -0.0057 0.0216 0.0136\n", " -0.0168 0.0183 0.0693 0.0168 0.0427 0.0050 0.8340 -0.0427 -0.0374 0.0873 -0.0645 0.0374 -0.0118 -0.0716 0.0158 0.0118\n", " 0.0081 -0.0600 -0.0240 -0.0081 -0.0947 -0.8106 -0.1233 0.0947 0.0352 -0.1141 0.0811 -0.0352 0.0364 0.0174 0.0568 -0.0364\n", " -0.0182 0.0213 -0.0699 0.0182 0.0066 -0.0603 0.0520 -0.0066 0.8776 0.0559 -0.0304 0.1224 0.0077 -0.0078 -0.0448 -0.0077\n", " 0.0415 0.0364 0.0468 -0.0415 -0.0392 -0.0869 -0.0964 0.0392 0.1947 -0.0919 0.3022 0.8053 -0.0113 -0.0109 -0.0113 0.0113\n", " -0.0113 0.0182 0.0295 0.0113 -0.0040 -0.0093 -0.1352 0.0040 -0.0532 0.0651 0.8236 0.0532 0.0319 -0.0097 0.0614 -0.0319\n", " -0.0036 -0.0020 -0.0119 0.0036 -0.0060 0.1400 0.0482 0.0060 -0.0979 -0.8117 -0.0450 0.0979 -0.0350 -0.0132 -0.0687 0.0350\n", " -0.0025 0.0263 0.0031 0.0025 -0.0118 0.0458 -0.0107 0.0118 0.0238 -0.0153 0.0221 -0.0238 0.9106 0.0858 0.0035 0.0894\n", " -0.0038 -0.0401 -0.0064 0.0038 -0.0562 0.0524 0.0264 0.0562 0.0057 -0.0270 0.0267 -0.0057 0.0913 -0.1212 0.0976 0.9087\n", " -0.0041 0.0698 -0.0421 0.0041 -0.0077 -0.1376 0.0688 0.0077 0.0308 0.0928 -0.1033 -0.0308 -0.0257 0.0155 0.8578 0.0257\n", " -0.0115 -0.0352 0.0063 0.0115 0.0069 0.0171 -0.0124 -0.0069 0.0035 -0.0384 -0.0154 -0.0035 -0.0670 -0.9119 -0.0448 0.0670\n", " \n", " \n", " Gxi = \n", " 0.9997 0.0001 -0.0002 0 0.0002 -0.0004 -0.0003 0 0 -0.0002 0 -0.0003 0.0005 -0.0004 0.0003 -0.0001\n", " -0.0007 0.9450 0.0272 -0.0254 0.0029 -0.0376 -0.0537 -0.0131 0.0181 -0.1137 0.0322 -0.0442 0.0110 0.0520 0.0129 0.0151\n", " -0.0082 0.0222 0.8836 -0.0062 0.0066 -0.0648 0.0614 -0.0161 -0.0189 0.0545 -0.1609 0.0045 0.0200 -0.0147 0.0695 -0.0056\n", " -0.0056 0.0064 0.0128 0.9200 0.0060 0.0066 -0.0066 -0.0304 0.0066 0.0179 0.0107 -0.0922 0.0204 -0.0093 0.0110 0.0653\n", " -0.0006 -0.0176 -0.0140 -0.0123 0.9047 0.0493 -0.0492 0.0151 -0.0396 -0.0384 -0.0760 0.0267 -0.0108 -0.0540 -0.0786 0.0237\n", " 0.0256 -0.0051 0.0422 -0.0011 -0.0353 0.9314 -0.0586 -0.0750 0.0377 -0.1391 0.1306 -0.0132 0.0268 -0.0627 -0.0410 -0.0513\n", " -0.0285 -0.0833 -0.0006 -0.0103 0.0350 0.0123 0.8895 -0.0677 -0.0619 0.0301 -0.0759 0.0231 0.0337 -0.0768 0.0273 0.0050\n", " -0.0039 0.0036 0.0025 -0.0019 0.0216 0.0715 -0.0075 0.8950 0.0329 -0.0233 0.0884 -0.0387 0.0239 0.0699 0.0155 -0.0181\n", " -0.0915 -0.0061 -0.0335 0.0060 0.0641 0.0416 0.0323 -0.0174 -0.0805 -0.0271 -0.0214 -0.0050 -0.9001 -0.0117 -0.0054 -0.0145\n", " 0.0323 -0.1148 0.0353 -0.0186 -0.0514 0.1892 -0.0845 -0.0698 -0.0199 -0.1027 0.0732 0.0336 -0.0820 -0.7782 -0.1075 0.0683\n", " -0.0191 -0.0271 -0.1063 -0.0303 0.0121 -0.0043 0.0746 -0.0477 -0.0406 0.0211 -0.1984 -0.0089 0.0335 -0.0850 -0.9004 0.0159\n", " 0.0005 0.0080 -0.0129 -0.0874 0.0303 -0.0497 0.0448 0.0709 -0.0348 -0.0224 -0.0873 -0.0521 -0.0367 -0.0723 -0.0878 -0.8764\n", " -0.1002 0.0103 0.0091 -0.0087 0.1154 -0.0489 -0.0462 0.0018 0.9026 -0.0002 0.0029 -0.0115 0.1012 0.0203 0.0276 0.0077\n", " -0.0155 -0.1251 -0.0482 0.0362 -0.0746 0.1443 0.0575 0.0413 -0.0330 0.9311 -0.1024 0.0536 0.0514 0.1079 0.0527 -0.0721\n", " 0.0183 0.0101 -0.1050 0.0072 -0.0494 0.0320 0.0515 0.0221 0.0111 -0.0558 0.8932 0.0144 -0.0670 0.0087 0.0788 0.0414\n", " 0.0005 0.0001 -0.0130 -0.0919 -0.0081 0.0091 -0.0045 0.0996 -0.0097 -0.0408 -0.0038 0.9183 0.0174 0.0494 0.0275 0.0740\n", " \n", " \n", " Gyi = \n", " 0.9997 0.0002 -0.0003 0.0001 0 0.0002 0.0002 0 -0.0003 0.0003 -0.0001 0.0002 0.0002 -0.0003 0 0\n", " 0.0104 0.8918 -0.0006 0.0014 0.0060 0.1377 0.0883 -0.0031 -0.0420 0.0399 -0.0895 0.0288 0.0024 0.1049 -0.0441 -0.0142\n", " -0.0168 0.0065 0.9198 -0.0059 -0.0045 -0.0060 0.0605 -0.0129 -0.0043 0.0087 0.0548 -0.0028 0.0425 -0.0459 0.1452 -0.0198\n", " -0.0057 0.0001 0.0218 0.9044 0.0047 -0.0316 -0.0041 0.1146 0.0011 0.0070 0.0372 0.0096 0.0061 0.0242 -0.0108 0.0952\n", " 0.1066 -0.0059 0.0048 -0.0009 -0.1240 0.0615 0.0095 -0.0004 0.0997 0.0576 0.0360 0.0369 0.8867 0.0715 -0.0332 0.0076\n", " -0.0098 0.1806 -0.0120 0.0268 0.0301 -0.1137 0.0105 -0.0125 0.0142 0.1733 0.0009 -0.0184 0.0011 0.8724 -0.0800 -0.0182\n", " 0.0024 -0.0407 0.1075 0.0145 0.0397 -0.0083 -0.0715 -0.0047 0.0360 0.0382 0.0596 -0.0479 -0.0312 0.0307 0.8425 0.0142\n", " -0.0203 0.0158 -0.0372 0.1199 0.0570 -0.0266 0.0499 -0.0992 -0.0502 -0.0611 -0.0690 0.0545 0.0235 0.0238 0.0182 0.8769\n", " 0.0017 0.0181 -0.0373 0.0104 0.0108 -0.0075 0.0721 0.0258 0.8768 0.0789 -0.0515 0.0341 -0.0153 0.0089 -0.0091 0.0032\n", " 0.0413 -0.0496 0.0313 -0.0387 0.0119 -0.0078 0.0415 -0.0082 0.0607 0.8477 0.1502 -0.0357 -0.0283 0.0468 -0.0540 0.0257\n", " -0.0372 0.0396 -0.0883 -0.0140 0.0203 -0.0208 0.1195 0 -0.1290 0.2770 0.7109 -0.0394 0.0275 -0.0622 -0.0062 0.0237\n", " 0.0111 -0.0014 0.1165 0.0140 0.0476 0.0283 -0.0163 0.0116 0.0176 0.0271 0.2363 0.8845 0.0038 0.0110 -0.0505 -0.0289\n", " -0.0951 0.0069 0.0028 -0.0232 -0.9171 -0.0071 -0.0181 0.0055 -0.0759 0.0003 0.0258 -0.0080 0.1075 -0.0313 -0.0223 0.0108\n", " -0.0275 -0.0650 -0.0145 0.0399 0.0092 -0.9129 -0.0564 -0.0262 0.0322 -0.1391 0.0377 0.1077 -0.0554 0.0542 -0.0219 0.0431\n", " -0.0024 -0.0127 -0.1113 -0.0176 0.0370 -0.0629 -0.8938 0.0309 0.0906 0.0503 -0.0707 -0.0279 -0.0512 0.0278 0.0370 0.0711\n", " -0.0146 0.0142 0.0049 -0.0830 -0.0223 0.0933 -0.0665 -0.9298 -0.0502 -0.0645 -0.0332 -0.0832 0.0148 -0.0164 -0.0359 0.0828\n", " \n", " \n", " Gcnot = \n", " 0.9995 0.0004 -0.0004 -0.0002 -0.0005 0.0003 0.0005 0 0.0002 0.0001 -0.0003 0.0003 0.0002 -0.0004 -0.0004 0\n", " 0.0337 0.9065 0.0294 0.0131 -0.0162 0.0219 -0.0315 -0.0123 0.0717 -0.0476 0.0485 -0.0178 -0.0233 -0.0053 0.0410 0.0012\n", " -0.0098 0.0044 -0.0326 -0.0022 -0.0573 0.0034 -0.1470 -0.0609 0.0243 -0.0514 0.1217 0.0523 -0.0145 0.0366 0.9041 -0.0210\n", " -0.1026 0.0966 0.0254 0.0055 0.0132 0.0643 -0.0125 -0.1047 0.0163 -0.0659 0.0084 0.0966 0.0982 -0.0761 0.0271 0.8956\n", " 0.0145 0.0042 -0.0403 0.0073 0.0023 0.8457 -0.0463 -0.0721 -0.0084 0.0587 0.0514 -0.0271 -0.0284 -0.0341 0.0043 -0.0018\n", " 0.0110 0.0601 0.0422 0.0236 0.7039 0.1137 -0.1391 0.0315 0.0604 -0.0110 0.0295 0.0182 -0.0089 -0.0923 0.0056 0.0061\n", " 0.0018 -0.0098 0.0983 0.0022 -0.0107 -0.0769 -0.0675 -0.0017 0.1230 -0.1009 0.1883 0.8479 -0.0220 0.0227 0.0196 -0.0034\n", " -0.0189 -0.0128 0.0048 -0.0317 0.1103 0.0151 0.0028 0.1148 0.0364 -0.1882 -0.8111 -0.1351 0.0088 0.0291 -0.0148 -0.0127\n", " 0.0190 0.0307 -0.0124 -0.0142 -0.0146 -0.0649 -0.0531 0.0110 0.0465 0.9253 0.0143 -0.0003 0.0021 -0.0255 -0.0544 0.0063\n", " 0.0453 0.0083 0.0777 0.0381 -0.0170 0.0101 -0.1446 -0.1655 0.8040 0.1364 0.0468 0.0727 -0.0394 -0.0333 0.0443 -0.0606\n", " -0.0124 0.0233 0.0027 0.0323 -0.0684 0.0836 -0.1032 -0.9645 0.1057 -0.0423 0.0729 0.0374 -0.0432 -0.0283 -0.0328 -0.0377\n", " 0.0108 0.0110 -0.0281 0.0086 0.0069 0.0253 0.8744 0.0054 0.0981 -0.0434 0.0548 0.0419 -0.0187 0.0281 0.1188 -0.0099\n", " -0.0134 -0.0240 0.0010 -0.0887 -0.1285 0.1703 -0.0234 -0.0045 0.0724 -0.0968 0.0048 -0.0340 0.9160 -0.0007 0.0044 0.0837\n", " -0.0365 -0.0044 -0.0429 -0.0267 0.1225 -0.0652 0.0535 0.1307 -0.1267 0.1578 -0.0302 -0.0492 0.0275 0.8799 -0.0465 0.0144\n", " 0.0077 0.0174 0.8946 -0.0678 0.0149 -0.0054 -0.0483 0.1416 -0.0202 0.1528 -0.1108 -0.0135 -0.0275 -0.0088 -0.0984 -0.0409\n", " 0.0732 -0.0848 0.0023 0.8993 0.0297 -0.0345 -0.0570 0.0309 -0.0613 0.0200 -0.1042 -0.0460 -0.0830 0.0533 -0.0093 0.0040\n", " \n", " \n", " \n", " \n", "--- Iterative MLGST: Iter 1 of 2 907 gate strings ---: \n", " --- Minimum Chi^2 GST ---\n", " Memory limit = 3.00GB\n", " Cur, Persist, Gather = 0.12, 0.04, 0.30 GB\n", " Evaltree generation (default) w/mem limit = 2.54GB\n", " mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 2.80GB (2.80GB fc)\n", " Created evaluation tree with 1 subtrees. Will divide 1 procs into 1 (subtree-processing)\n", " groups of ~1 procs each, to distribute over 1616 params (taken as 2 param groups of ~808 params).\n", " Memory estimate = 1.40GB (cache=907, wrtLen1=808, wrtLen2=1616, subsPerProc=1).\n", " --- Outer Iter 0: norm_f = 5353.31, mu=0, |J|=10846.6\n", " --- Outer Iter 1: norm_f = 1889.81, mu=2766.39, |J|=10923.8\n", " --- Outer Iter 2: norm_f = 1574.84, mu=922.13, |J|=10686.3\n", " --- Outer Iter 3: norm_f = 1472.63, mu=307.377, |J|=10638.1\n", " --- Outer Iter 4: norm_f = 1429.17, mu=102.459, |J|=10634.4\n", " --- Outer Iter 5: norm_f = 1413.85, mu=34.153, |J|=10644.7\n", " --- Outer Iter 6: norm_f = 1410.26, mu=11.3843, |J|=10653.5\n", " --- Outer Iter 7: norm_f = 1409.73, mu=3.79477, |J|=10656.6\n", " --- Outer Iter 8: norm_f = 1409.69, mu=1.26492, |J|=10657.4\n", " --- Outer Iter 9: norm_f = 1409.69, mu=0.421641, |J|=10657.6\n", " Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06\n", " Finding num_nongauge_params is too expensive: using total params.\n", " Sum of Chi^2 = 1409.69 (2721 data params - 1616 model params = expected mean of 1105; p-value = 1.11522e-09)\n", " Completed in 478.4s\n", " 2*Delta(log(L)) = 1414.05\n", " Iteration 1 took 479.0s\n", " \n", "--- Iterative MLGST: Iter 2 of 2 1317 gate strings ---: \n", " --- Minimum Chi^2 GST ---\n", " Memory limit = 3.00GB\n", " Cur, Persist, Gather = 0.22, 0.06, 0.29 GB\n", " Evaltree generation (default) w/mem limit = 2.43GB\n", " mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 4.06GB (4.06GB fc)\n", " Created evaluation tree with 1 subtrees. Will divide 1 procs into 1 (subtree-processing)\n", " groups of ~1 procs each, to distribute over 1616 params (taken as 2 param groups of ~808 params).\n", " Memory estimate = 2.03GB (cache=1317, wrtLen1=808, wrtLen2=1616, subsPerProc=1).\n", " --- Outer Iter 0: norm_f = 4313.99, mu=0, |J|=12584.2\n", " --- Outer Iter 1: norm_f = 3338.97, mu=3409.33, |J|=12505.4\n", " --- Outer Iter 2: norm_f = 2986.93, mu=1136.44, |J|=12509\n", " --- Outer Iter 3: norm_f = 2822.63, mu=378.815, |J|=12509.9\n", " --- Outer Iter 4: norm_f = 2761.56, mu=126.272, |J|=12511.9\n", " --- Outer Iter 5: norm_f = 2746.35, mu=42.0905, |J|=12513.1\n", " --- Outer Iter 6: norm_f = 2744.04, mu=14.0302, |J|=12512.7\n", " --- Outer Iter 7: norm_f = 2743.83, mu=4.67672, |J|=12512.6\n", " --- Outer Iter 8: norm_f = 2743.82, mu=1.55891, |J|=12512.6\n", " Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06\n", " Finding num_nongauge_params is too expensive: using total params.\n", " Sum of Chi^2 = 2743.82 (3951 data params - 1616 model params = expected mean of 2335; p-value = 6.94799e-09)\n", " Completed in 394.4s\n", " 2*Delta(log(L)) = 2754.12\n", " Iteration 2 took 395.5s\n", " \n", " Switching to ML objective (last iteration)\n", " --- MLGST ---\n", " Memory: limit = 3.00GB(cur, persist, gthr = 0.24, 0.06, 0.29 GB)\n", " Evaltree generation (default) w/mem limit = 2.40GB\n", " mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 4.06GB (4.06GB fc)\n", " Created evaluation tree with 1 subtrees. Will divide 1 procs into 1 (subtree-processing)\n", " groups of ~1 procs each, to distribute over 1616 params (taken as 2 param groups of ~808 params).\n", " Memory estimate = 2.03GB (cache=1317, wrtLen1=808, wrtLen2=1616, subsPerProc=1).\n", " --- Outer Iter 0: norm_f = 1377.06, mu=0, |J|=8329.12\n", " --- Outer Iter 1: norm_f = 1375.55, mu=1349.19, |J|=8599.91\n", " --- Outer Iter 2: norm_f = 1375.53, mu=1.70203e+06, |J|=9321.33\n", " --- Outer Iter 3: norm_f = 1375.48, mu=1.69568e+06, |J|=8337.01\n", " --- Outer Iter 4: norm_f = 1375.48, mu=1.36906e+07, |J|=8336.91\n", " Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06\n", " Finding num_nongauge_params is too expensive: using total params.\n", " Maximum log(L) = 1375.48 below upper bound of -2.95533e+06\n", " 2*Delta(log(L)) = 2750.95 (3951 data params - 1616 model params = expected mean of 2335; p-value = 4.00106e-09)\n", " Completed in 208.6s\n", " 2*Delta(log(L)) = 2750.95\n", " Final MLGST took 208.6s\n", " \n", "Iterative MLGST Total Time: 1083.1s\n", " -- Adding Gauge Optimized (go0) --\n", "--- Re-optimizing logl after robust data scaling ---\n", " --- MLGST ---\n", " Memory: limit = 3.00GB(cur, persist, gthr = 0.25, 0.06, 0.29 GB)\n", " Evaltree generation (default) w/mem limit = 2.40GB\n", " mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 4.06GB (4.06GB fc)\n", " Created evaluation tree with 1 subtrees. Will divide 1 procs into 1 (subtree-processing)\n", " groups of ~1 procs each, to distribute over 1616 params (taken as 2 param groups of ~808 params).\n", " Memory estimate = 2.03GB (cache=1317, wrtLen1=808, wrtLen2=1616, subsPerProc=1).\n", " --- Outer Iter 0: norm_f = 1375.48, mu=0, |J|=8336.91\n", " Least squares message = Both actual and predicted relative reductions in the sum of squares are at most 1e-06\n", " Finding num_nongauge_params is too expensive: using total params.\n", " Maximum log(L) = 1375.48 below upper bound of -2.95533e+06\n", " 2*Delta(log(L)) = 2750.95 (3951 data params - 1616 model params = expected mean of 2335; p-value = 4.00106e-09)\n", " Completed in 41.6s\n", " -- Adding Gauge Optimized (go0) --\n", "Total time=0.314203 hours\n" ] } ], "source": [ "import time\n", "start = time.time()\n", "results = pygsti.do_long_sequence_gst(ds, gs_target, prep_fiducials, effect_fiducials, germs4,\n", " maxLengths, gaugeOptParams={'itemWeights': {'spam':0.1,'gates': 1.0}},\n", " memLimit=3*(1024)**3, verbosity=3 )\n", "end = time.time()\n", "print(\"Total time=%f hours\" % ((end - start) / 3600.0))" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Step 5: Create report(s) using the returned `Results` object\n", "The `Results` object returned from `do_long_sequence_gst` can be used to generate a \"general\" HTML report, just as in the 1-qubit case:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "*** Creating workspace ***\n", "*** Generating switchboard ***\n", "*** Generating tables ***\n", " targetSpamBriefTable took 0.069756 seconds\n", " targetGatesBoxTable took 0.113729 seconds\n", " datasetOverviewTable took 0.02392 seconds\n", " bestGatesetSpamParametersTable took 0.000469 seconds\n", " bestGatesetSpamBriefTable took 0.077722 seconds\n", " bestGatesetSpamVsTargetTable took 1.355508 seconds\n", " bestGatesetGaugeOptParamsTable took 0.000297 seconds\n", " bestGatesetGatesBoxTable took 0.111316 seconds\n", " bestGatesetChoiEvalTable took 0.295349 seconds\n", " bestGatesetDecompTable took 6.385372 seconds\n", " bestGatesetEvalTable took 0.014843 seconds\n", " bestGermsEvalTable took 0.009861 seconds\n", " bestGatesetVsTargetTable took 0.469874 seconds\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/enielse/research/pyGSTi/packages/pygsti/extras/rb/rbutils.py:382: UserWarning:\n", "\n", "Predicted RB decay parameter / error rate may be unreliable:\n", "Gateset is not (approximately) trace-preserving.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " bestGatesVsTargetTable_gv took 6.990236 seconds\n", " bestGatesVsTargetTable_gvgerms took 0.184236 seconds\n", " bestGatesVsTargetTable_gi took 0.073512 seconds\n", " bestGatesVsTargetTable_gigerms took 0.009031 seconds\n", " bestGatesVsTargetTable_sum took 6.856213 seconds\n", " bestGatesetErrGenBoxTable took 0.508674 seconds\n", " metadataTable took 0.001133 seconds\n", " stdoutBlock took 0.001183 seconds\n", " profilerTable took 0.00072 seconds\n", " softwareEnvTable took 0.022966 seconds\n", " exampleTable took 0.00817 seconds\n", " singleMetricTable_gv took 7.01703 seconds\n", " singleMetricTable_gi took 0.074872 seconds\n", " fiducialListTable took 0.000667 seconds\n", " prepStrListTable took 0.000309 seconds\n", " effectStrListTable took 0.000205 seconds\n", " colorBoxPlotKeyPlot took 0.013986 seconds\n", " germList2ColTable took 0.000202 seconds\n", " progressTable took 2.681229 seconds\n", "*** Generating plots ***\n", " gramBarPlot took 0.147281 seconds\n", " progressBarPlot took 2.002607 seconds\n", " progressBarPlot_sum took 0.000216 seconds\n", " finalFitComparePlot took 1.020939 seconds\n", " bestEstimateColorBoxPlot took 4.73809 seconds\n", " bestEstimateTVDColorBoxPlot took 4.683939 seconds\n", " bestEstimateColorScatterPlot took 4.991277 seconds\n", " bestEstimateColorHistogram took 4.712245 seconds\n", " progressTable_scl took 7.8e-05 seconds\n", " progressBarPlot_scl took 5.8e-05 seconds\n", " bestEstimateColorBoxPlot_scl took 8.8e-05 seconds\n", " bestEstimateColorScatterPlot_scl took 9.9e-05 seconds\n", " bestEstimateColorHistogram_scl took 8.3e-05 seconds\n", " dataScalingColorBoxPlot took 6e-05 seconds\n", "*** Merging into template file ***\n", " Rendering bestGatesetEvalTable took 0.05512 seconds\n", " Rendering targetGatesBoxTable took 0.065936 seconds\n", " Rendering progressBarPlot_scl took 0.000477 seconds\n", " Rendering bestGatesVsTargetTable_gi took 0.00352 seconds\n", " Rendering bestEstimateTVDColorBoxPlot took 0.018732 seconds\n", " Rendering bestEstimateColorScatterPlot_scl took 0.000662 seconds\n", " Rendering softwareEnvTable took 0.002411 seconds\n", " Rendering bestGatesetVsTargetTable took 0.000854 seconds\n", " Rendering bestEstimateColorBoxPlot_scl took 0.000608 seconds\n", " Rendering datasetOverviewTable took 0.000553 seconds\n", " Rendering bestGatesVsTargetTable_sum took 0.006147 seconds\n", " Rendering bestGatesetErrGenBoxTable took 0.158547 seconds\n", " Rendering stdoutBlock took 0.000755 seconds\n", " Rendering progressTable_scl took 0.000507 seconds\n", " Rendering prepStrListTable took 0.002495 seconds\n", " Rendering profilerTable took 0.001271 seconds\n", " Rendering exampleTable took 0.004339 seconds\n", " Rendering bestGatesetSpamVsTargetTable took 0.001954 seconds\n", " Rendering bestGatesVsTargetTable_gv took 0.005387 seconds\n", " Rendering metricSwitchboard_gv took 6.8e-05 seconds\n", " Rendering singleMetricTable_gv took 0.007842 seconds\n", " Rendering metricSwitchboard_gi took 5.8e-05 seconds\n", " Rendering targetSpamBriefTable took 0.033334 seconds\n", " Rendering progressBarPlot_sum took 0.002098 seconds\n", " Rendering gramBarPlot took 0.002117 seconds\n", " Rendering colorBoxPlotKeyPlot took 0.008788 seconds\n", " Rendering progressBarPlot took 0.002165 seconds\n", " Rendering fiducialListTable took 0.003868 seconds\n", " Rendering finalFitComparePlot took 0.002323 seconds\n", " Rendering bestGatesetGaugeOptParamsTable took 0.00072 seconds\n", " Rendering bestEstimateColorBoxPlot took 0.014267 seconds\n", " Rendering bestEstimateColorHistogram took 0.008428 seconds\n", " Rendering metadataTable took 0.003064 seconds\n", " Rendering bestEstimateColorScatterPlot took 0.010434 seconds\n", " Rendering bestGatesetGatesBoxTable took 0.115008 seconds\n", " Rendering dataScalingColorBoxPlot took 0.000474 seconds\n", " Rendering topSwitchboard took 0.000113 seconds\n", " Rendering bestGatesetSpamParametersTable took 0.001758 seconds\n", " Rendering progressTable took 0.002041 seconds\n", " Rendering bestGatesVsTargetTable_gvgerms took 0.004367 seconds\n", " Rendering bestGatesVsTargetTable_gigerms took 0.001651 seconds\n", " Rendering bestGatesetDecompTable took 0.045453 seconds\n", " Rendering germList2ColTable took 0.001492 seconds\n", " Rendering bestGatesetSpamBriefTable took 0.066916 seconds\n", " Rendering maxLSwitchboard1 took 0.000102 seconds\n", " Rendering bestGatesetChoiEvalTable took 0.067528 seconds\n", " Rendering bestGermsEvalTable took 0.043135 seconds\n", " Rendering effectStrListTable took 0.002114 seconds\n", " Rendering bestEstimateColorHistogram_scl took 0.000524 seconds\n", " Rendering singleMetricTable_gi took 0.005022 seconds\n", "Output written to example_files/easy_2q_report directory\n", "*** Report Generation Complete! Total time 57.187s ***\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pygsti.report.create_standard_report(results, filename=\"example_files/easy_2q_report\",\n", " title=\"Example 2Q-GST Report\", verbosity=2)" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Now open [example_files/easy_2q_report/main.html](example_files/easy_2q_report/main.html) to see the results. You've run 2-qubit GST!\n", "\n", "You can save the `Results` object for later by just pickling it:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "import pickle\n", "with open(\"example_files/easy_2q_results.pkl\",\"wb\") as pklfile:\n", " pickle.dump(results, pklfile)" ] }, { "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.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }