{ "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": false, "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.7502828285173155\n", " 2.3518957405180436\n", " 2.318639069417392\n", " 1.2302334842041527\n", " 1.2117463743117198\n", " 1.1873969447789428\n", " 0.8897042679854841\n", " 0.8169918501235112\n", " 0.5305300820082018\n", " 0.5155269364101752\n", " 0.3676760156532707\n", " 0.3517041657230517\n", " 0.30932109560940213\n", " 0.2334365962706313\n", " 0.22377281697587817\n", " 0.14850701015514287\n", " \n", " Singular values of target I_tilde (truncating to first 16 of 16) = \n", " 6.868027641505519\n", " 3.202537446873216\n", " 3.202537446873215\n", " 1.7692369322250323\n", " 1.7692369322250308\n", " 1.7320508075688799\n", " 1.2340048586337\n", " 1.2247448713915883\n", " 0.7071067811865485\n", " 0.7071067811865481\n", " 0.5000000000000001\n", " 0.49371439251332727\n", " 0.49371439251332666\n", " 0.3461223449171741\n", " 0.34612234491717386\n", " 0.2396420755723003\n", " \n", " Resulting gate set:\n", " \n", " rho0 = FullyParameterizedSPAMVec with dimension 16\n", " 0.50 0 0 0.50 0 0 0 0 0 0 0 0 0.50 0 0 0.50\n", " \n", " \n", " Mdefault = UnconstrainedPOVM with effect vectors:\n", " 00: FullyParameterizedSPAMVec with dimension 16\n", " 0.60-0.06 0.07 0.45-0.04 0.03-0.02-0.04 0.07 0 0.02 0.05 0.45-0.07 0.08 0.49\n", " \n", " 01: FullyParameterizedSPAMVec with dimension 16\n", " 0.50 0.06-0.06-0.45-0.03-0.06-0.01 0.01 0 0.02-0.09-0.02 0.36 0.05-0.07-0.41\n", " \n", " 10: FullyParameterizedSPAMVec with dimension 16\n", " 0.49-0.02 0.05 0.35 0.05 0 0.04 0.06-0.05-0.02 0.02-0.07-0.45 0.03-0.06-0.40\n", " \n", " 11: FullyParameterizedSPAMVec with dimension 16\n", " 0.41 0.02-0.06-0.36 0.03 0.03-0.01-0.04-0.03 0 0.05 0.04-0.37 0 0.06 0.31\n", " \n", " \n", " \n", " Gii = \n", " FullyParameterizedGate with shape (16, 16)\n", " 1.00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.02 0.87 0.05 0-0.04 0.05 0.02-0.01-0.02 0.05-0.07 0 0 0.02-0.03 0.02\n", " 0.02 0.04 0.90 0 0.04-0.12 0.05-0.04 0 0.06 0.02 0.01 0.02-0.04 0.07 0.02\n", " 0-0.02-0.02 0.91-0.02 0.04 0.03-0.02 0.02-0.04-0.03 0 0-0.02-0.03-0.01\n", " -0.02 0-0.01 0 0.92 0.02 0.03-0.02-0.05 0.05-0.11 0 0.03-0.05 0.03-0.02\n", " -0.02-0.10 0.05 0 0.04 0.91 0.13 0-0.03 0 0.08-0.04-0.02 0-0.03-0.04\n", " -0.04-0.04 0.03 0.03 0.04 0.07 0.88-0.04-0.01-0.16 0.07 0.05 0 0.09 0.04 0\n", " 0 0.05-0.03-0.02-0.03-0.08 0.05 0.96-0.05 0.12 0-0.11-0.08 0.10-0.10 0.03\n", " -0.05 0.07-0.08 0.02 0.05-0.05 0.09-0.05 0.83 0.13-0.07 0.04 0 0.07 0.01 0.02\n", " -0.07 0.10-0.07-0.07 0.02-0.06 0 0.12 0.02 0.78 0.13-0.11-0.03 0.12-0.02-0.03\n", " -0.01 0.10 0.06-0.04-0.02-0.08-0.13 0.04 0 0.06 0.85 0 0-0.12 0.05 0\n", " 0.04-0.04 0.06-0.05-0.05 0.04-0.02 0.05 0.07-0.22 0.05 0.83 0-0.04-0.01 0.06\n", " 0 0 0 0-0.02-0.01-0.05 0 0.01-0.04 0.04-0.06 0.90 0 0 0\n", " -0.01 0.02-0.04 0 0.06-0.12 0.06 0.04 0.05-0.13 0 0.02 0.05 0.83 0.11-0.04\n", " 0.04-0.06 0.05-0.02-0.02 0.08-0.04 0.03 0.08-0.09 0.10-0.04 0 0 0.89 0\n", " 0-0.04-0.03 0 0.03 0 0 0.01-0.07 0-0.12 0.03 0 0-0.01 0.90\n", " \n", " \n", " Gix = \n", " FullyParameterizedGate with shape (16, 16)\n", " 1.00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.02 0.89 0.02-0.02-0.02-0.01-0.02 0.02-0.02 0.08-0.02 0.02 0 0.02 0 0\n", " -0.08 0.10-0.08-0.92 0.04-0.08 0.04-0.04 0-0.02 0 0 0-0.02 0 0\n", " -0.10 0.10 0.90 0.10-0.03 0.05-0.03 0.03 0.01-0.01 0.01-0.01 0.02-0.04 0.02-0.02\n", " -0.01 0.03-0.01 0.01 0.92-0.04-0.08 0.08-0.02 0.08-0.02 0.02 0 0 0 0\n", " 0 0 0 0 0.01 0.78 0.01-0.01 0.03-0.01 0.03-0.03 0 0 0 0\n", " 0.01-0.05 0.01-0.01-0.13 0.18-0.13-0.87 0 0 0 0 0.02 0.01 0.02-0.02\n", " 0 0 0 0-0.10 0.06 0.90 0.10 0-0.04 0 0-0.02 0.02-0.02 0.02\n", " 0 0.01 0 0 0.02-0.01 0.02-0.02 0.89 0.05-0.11 0.11 0.02 0 0.02-0.02\n", " -0.06 0.02-0.06 0.06 0.06 0.11 0.06-0.06 0.03 0.81 0.03-0.03-0.01 0.06-0.01 0.01\n", " 0.02-0.04 0.02-0.02-0.09 0.04-0.09 0.09-0.11 0.08-0.11-0.89 0.02-0.04 0.02-0.02\n", " -0.01 0.05-0.01 0.01 0.04 0.03 0.04-0.04-0.09 0.15 0.91 0.09 0-0.06 0 0\n", " -0.02 0-0.02 0.02-0.01 0.01-0.01 0.01 0 0 0 0 0.91 0-0.09 0.09\n", " -0.03 0.03-0.03 0.03 0.04-0.12 0.04-0.04-0.06 0.10-0.06 0.06 0.04 0.85 0.04-0.04\n", " 0.03-0.04 0.03-0.03-0.13 0.18-0.13 0.13 0.05 0 0.05-0.05-0.09 0.14-0.09-0.91\n", " -0.02 0.02-0.02 0.02 0.05-0.13 0.05-0.05-0.04 0.01-0.04 0.04-0.09 0.12 0.91 0.09\n", " \n", " \n", " Giy = \n", " FullyParameterizedGate with shape (16, 16)\n", " 1.00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.12-0.13 0.08 0.88-0.03 0.05 0.04 0.03-0.04 0-0.12 0.04-0.01 0 0 0.01\n", " 0.03 0 0.94-0.03 0.05 0.08 0.03-0.05 0-0.06 0.06 0-0.02 0 0 0.02\n", " -0.09-0.93-0.10 0.09-0.05 0.04-0.02 0.05 0 0.01-0.05 0 0.01 0.01 0-0.01\n", " -0.02 0.02-0.06 0.02 0.93 0.06 0.04 0.07-0.08 0.07-0.15 0.08 0.04 0 0.04-0.04\n", " 0.03-0.04 0.07-0.03 0.07-0.06 0.11 0.93 0.09-0.09 0.16-0.09-0.01 0.02 0 0.01\n", " 0 0 0.09 0 0 0.08 0.80 0 0-0.04 0.17 0 0-0.03 0.02 0\n", " 0-0.05-0.04 0-0.12-0.83-0.09 0.12-0.03-0.07-0.02 0.03 0-0.08-0.06 0\n", " 0 0.01-0.05 0 0-0.02 0.05 0 0.87 0.07-0.07 0.13 0.02-0.02 0.01-0.02\n", " -0.05 0-0.08 0.05 0 0 0.07 0 0.10-0.09 0.14 0.90-0.03 0.05-0.03 0.03\n", " 0.02-0.04 0.09-0.02-0.01-0.02-0.08 0.01 0.05 0.03 1.01-0.05 0.02 0.04 0.01-0.02\n", " -0.04 0 0 0.04-0.02 0.09 0.02 0.02-0.05-0.92-0.08 0.05 0.02-0.03 0.03-0.02\n", " 0-0.01 0 0-0.01 0.02 0 0.01 0.02 0 0.02-0.02 0.90 0.11 0 0.10\n", " -0.03-0.02 0 0.03 0.06 0.03 0.04-0.06 0.03 0 0.09-0.03 0.15-0.11 0.11 0.85\n", " 0.02-0.02 0-0.02-0.06-0.01-0.12 0.06 0.10 0.04 0.11-0.10 0.03-0.09 0.93-0.03\n", " -0.01 0 0 0.01 0.04-0.02 0.03-0.04-0.03-0.09-0.02 0.03-0.08-0.92-0.10 0.08\n", " \n", " \n", " Gxi = \n", " FullyParameterizedGate with shape (16, 16)\n", " 1.00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.02 0.86 0.02 0-0.04 0.05 0 0.02 0.02-0.12 0.11 0 0 0.09 0.02-0.02\n", " 0-0.05 0.93 0 0.06-0.06 0.04-0.03 0-0.04-0.11 0.02 0.02-0.02 0.07-0.03\n", " -0.01 0.03-0.03 0.92-0.03 0.01 0 0 0-0.02 0.03-0.10 0 0.04 0.03 0.10\n", " 0 0 0 0 0.87-0.01 0 0 0.03-0.05 0.06-0.02 0-0.03 0.05 0\n", " -0.01-0.06-0.03 0-0.06 0.94 0 0.02 0.04-0.11 0.08-0.06 0 0-0.03 0.02\n", " 0-0.05 0.02 0 0.03 0 0.94-0.03 0.03-0.08 0-0.03 0.02 0-0.04-0.02\n", " 0.02 0-0.04 0-0.04 0-0.03 0.90-0.02 0.04-0.11 0.05 0-0.02-0.03-0.03\n", " -0.10 0.01-0.01 0 0.10 0.02 0.04 0.01-0.06-0.07 0.03-0.04-0.88-0.03 0.05-0.02\n", " 0.01-0.12-0.04 0-0.02 0.19 0.07 0.07 0.04-0.14-0.07-0.02-0.02-0.83-0.02 0\n", " -0.02 0.02-0.09 0.06 0.01-0.06-0.09-0.08 0-0.07-0.14 0.03-0.08 0.09-0.97 0.05\n", " 0-0.03 0-0.09 0.09 0.02 0.16 0.08-0.06-0.01 0.01-0.03 0 0.01 0.04-0.91\n", " -0.09-0.01 0 0 0.07-0.03 0.01 0 0.90 0 0 0 0.07 0.04-0.02 0.03\n", " -0.01-0.08 0.05 0.02 0.05-0.03-0.02-0.08 0.01 0.86 0 0-0.03 0.08-0.03 0.02\n", " 0 0-0.14 0 0 0.06 0.07 0.02-0.04 0.02 0.85 0.05-0.06 0.09-0.02 0.06\n", " 0.02-0.03 0-0.10-0.01-0.05-0.01 0.07 0.03 0.02 0 0.90 0.03-0.02 0.01 0.04\n", " \n", " \n", " Gyi = \n", " FullyParameterizedGate with shape (16, 16)\n", " 1.00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.02 0.88-0.01-0.01 0.04 0.06-0.01 0 0 0.04-0.02-0.03-0.04 0.12 0.02 0.03\n", " 0.02 0 0.93 0.01-0.02 0.02 0.07-0.01 0 0.07 0.02 0.02 0.03-0.06 0.06-0.06\n", " 0-0.04 0 0.91 0 0.04 0 0.13 0.02-0.03 0 0-0.02 0.01 0.01 0.10\n", " 0.08 0.03 0 0-0.15 0.05-0.08 0 0.05 0.07-0.12 0 0.92-0.03 0 0\n", " 0 0.05 0.04 0 0.03-0.14 0.05 0.04 0-0.02 0.09 0.04 0.02 0.83 0.13-0.02\n", " 0 0.06 0.15 0.03-0.02-0.03-0.09-0.08-0.04 0.05 0.14 0.03 0.02-0.06 0.88-0.04\n", " -0.01-0.02-0.03 0.08 0.06-0.02 0.02-0.12-0.06 0.03 0.05 0.02 0.03 0 0.11 0.91\n", " -0.01-0.02 0 0.02 0.01 0 0 0 0.86 0.04-0.07 0.03 0 0.02 0-0.01\n", " -0.04-0.01 0-0.02-0.05 0.10-0.19 0.04 0 0.75 0.03-0.03 0 0 0 0.05\n", " 0.01 0.03 0.09 0.03-0.03 0.04-0.04-0.02 0.08-0.08 0.96 0-0.04-0.05-0.06 0\n", " -0.01 0 0 0 0 0.08-0.01 0.02 0.02-0.09 0.02 0.91 0.01 0.06 0.04 0\n", " -0.09-0.02 0-0.01-0.91 0 0 0-0.08 0-0.03-0.04 0.09-0.06 0 0.02\n", " -0.04-0.10 0 0-0.06-0.81 0.05 0.04 0.01-0.13 0.04-0.03 0.05-0.02-0.01-0.01\n", " 0 0.05-0.05 0.01 0.04-0.03-0.86-0.11 0.03-0.03 0.06-0.01-0.03 0.10 0.09 0.02\n", " -0.02 0.04-0.04-0.09 0-0.08 0.03-0.93-0.05 0.10 0.03-0.08 0.01-0.04 0 0.09\n", " \n", " \n", " Gcnot = \n", " FullyParameterizedGate with shape (16, 16)\n", " 1.00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.02 0.87 0 0.02-0.01 0.02-0.03 0.02 0.03-0.02-0.03 0.07 0 0.01 0.04 0\n", " 0.04-0.05 0.06 0.02-0.06 0.05-0.15 0.03 0.07-0.05 0.19 0 0 0.03 0.94-0.02\n", " -0.11 0.09 0-0.02 0.01 0-0.01-0.06 0-0.01 0 0.10 0.11-0.12-0.04 0.92\n", " -0.01 0.03 0.06 0-0.03 0.91-0.06 0.10 0.03 0.03 0.06-0.03 0.01-0.03-0.04 0\n", " -0.04 0.01-0.04 0 0.86-0.07-0.06 0.06-0.01-0.06 0.05 0.10 0-0.06-0.01-0.03\n", " 0 0 0.10-0.04 0 0-0.01-0.01 0.10-0.07 0.13 0.79 0 0 0.07 0.02\n", " 0.02-0.04-0.06 0.01 0.05-0.15 0.05-0.02 0.05-0.13-0.81-0.06-0.08 0.03-0.02 0.02\n", " -0.03 0.04-0.01 0 0.04 0.04-0.01 0.05 0.02 0.94 0.03-0.03 0.03-0.03 0 0.02\n", " -0.04 0.03-0.02-0.01 0.10 0.02 0.04-0.10 0.86 0.06-0.04 0.12-0.03 0.03-0.06-0.07\n", " 0 0.05-0.02-0.03-0.12-0.02-0.07-0.87-0.03-0.02 0-0.02 0-0.08 0.06-0.02\n", " 0 0.02 0.05 0.05 0.10-0.10 0.88 0.12 0.06 0.04 0.04 0.08-0.02-0.05 0.03 0\n", " 0 0 0-0.07-0.12 0.10-0.04-0.04 0.07-0.09 0.02 0 0.91-0.02-0.01 0.09\n", " 0-0.02 0.10-0.06 0.02-0.05-0.03 0.06-0.10 0.04 0.02-0.06 0.01 0.84-0.04 0.03\n", " 0 0.06 0.90 0.03 0.04-0.03-0.09-0.06-0.02 0.12 0.01 0.09 0.06-0.10 0.04 0\n", " 0.10-0.13 0 0.92-0.04 0.03-0.11 0.02 0-0.06-0.13 0-0.10 0.13 0-0.01\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.14, 0.04, 0.30 GB\n", " Evaltree generation (default) w/mem limit = 2.52GB\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 = 5833.47, mu=0, |J|=9795.5\n", " --- Outer Iter 1: norm_f = 1952.44, mu=1933.12, |J|=9726.97\n", " --- Outer Iter 2: norm_f = 1642.96, mu=644.373, |J|=9666.38\n", " --- Outer Iter 3: norm_f = 1555.63, mu=214.791, |J|=9660.03\n", " --- Outer Iter 4: norm_f = 1517.27, mu=71.597, |J|=9672.62\n", " --- Outer Iter 5: norm_f = 1501.95, mu=23.8657, |J|=9693.31\n", " --- Outer Iter 6: norm_f = 1497.5, mu=7.95522, |J|=9715.91\n", " --- Outer Iter 7: norm_f = 1496.41, mu=2.65174, |J|=9730.51\n", " --- Outer Iter 8: norm_f = 1496.21, mu=0.883914, |J|=9737.72\n", " --- Outer Iter 9: norm_f = 1496.19, mu=0.294638, |J|=9740.22\n", " --- Outer Iter 10: norm_f = 1496.19, mu=0.0982127, |J|=9740.87\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 = 1496.19 (2720 data params - 1616 model params = expected mean of 1104; p-value = 2.40918e-14)\n", " Completed in 633.6s\n", " 2*Delta(log(L)) = 1501.17\n", " Iteration 1 took 633.6s\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.25, 0.06, 0.29 GB\n", " Evaltree generation (default) w/mem limit = 2.39GB\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 = 4476.66, mu=0, |J|=11844\n", " --- Outer Iter 1: norm_f = 3365.67, mu=2583.99, |J|=11739.7\n", " --- Outer Iter 2: norm_f = 3021.89, mu=861.328, |J|=11712.6\n", " --- Outer Iter 3: norm_f = 2855.59, mu=287.109, |J|=11699.6\n", " --- Outer Iter 4: norm_f = 2784.85, mu=95.7032, |J|=11689\n", " --- Outer Iter 5: norm_f = 2765.13, mu=31.9011, |J|=11686.2\n", " --- Outer Iter 6: norm_f = 2761.34, mu=10.6337, |J|=11686.7\n", " --- Outer Iter 7: norm_f = 2760.97, mu=3.54456, |J|=11686.7\n", " --- Outer Iter 8: norm_f = 2760.95, mu=1.18152, |J|=11686.5\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 = 2760.95 (3950 data params - 1616 model params = expected mean of 2334; p-value = 1.67177e-09)\n", " Completed in 645.8s\n", " 2*Delta(log(L)) = 2771.33\n", " Iteration 2 took 645.9s\n", " \n", " Switching to ML objective (last iteration)\n", " --- MLGST ---\n", " Memory: limit = 3.00GB(cur, persist, gthr = 0.19, 0.06, 0.29 GB)\n", " --- Outer Iter 0: norm_f = 1385.67, mu=0, |J|=8271.12\n", " --- Outer Iter 1: norm_f = 1384.07, mu=1284.17, |J|=8283.99\n", " --- Outer Iter 2: norm_f = 1383.96, mu=428.057, |J|=8282.83\n", " --- Outer Iter 3: norm_f = 1383.91, mu=142.686, |J|=8282.29\n", " --- Outer Iter 4: norm_f = 1383.88, mu=47.5619, |J|=8282.08\n", " --- Outer Iter 5: norm_f = 1383.88, mu=15.854, |J|=8282.01\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) = 1383.88 below upper bound of -2.95403e+06\n", " 2*Delta(log(L)) = 2767.75 (3950 data params - 1616 model params = expected mean of 2334; p-value = 9.70072e-10)\n", " Completed in 254.6s\n", " 2*Delta(log(L)) = 2767.75\n", " Final MLGST took 254.6s\n", " \n", "Iterative MLGST Total Time: 1534.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.18, 0.06, 0.29 GB)\n", " --- Outer Iter 0: norm_f = 1383.88, mu=0, |J|=8282.01\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) = 1383.88 below upper bound of -2.95403e+06\n", " 2*Delta(log(L)) = 2767.75 (3950 data params - 1616 model params = expected mean of 2334; p-value = 9.70072e-10)\n", " Completed in 39.3s\n", " -- Adding Gauge Optimized (go0) --\n", "Total time=0.438297 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.734874 seconds\n", " targetGatesBoxTable took 0.507036 seconds\n", " datasetOverviewTable took 0.050647 seconds\n", " bestGatesetSpamParametersTable took 0.000619 seconds\n", " bestGatesetSpamBriefTable took 0.461748 seconds\n", " bestGatesetSpamVsTargetTable took 1.429976 seconds\n", " bestGatesetGaugeOptParamsTable took 0.000319 seconds\n", " bestGatesetGatesBoxTable took 0.57293 seconds\n", " bestGatesetChoiEvalTable took 0.983698 seconds\n", " bestGatesetDecompTable took 7.610605 seconds\n", " bestGatesetEvalTable took 0.03024 seconds\n", " bestGermsEvalTable took 0.015404 seconds\n", " bestGatesetVsTargetTable took 0.155524 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 8.119418 seconds\n", " bestGatesVsTargetTable_gvgerms took 0.192741 seconds\n", " bestGatesVsTargetTable_gi took 0.122488 seconds\n", " bestGatesVsTargetTable_gigerms took 0.008179 seconds\n", " bestGatesVsTargetTable_sum took 7.986344 seconds\n", " bestGatesetErrGenBoxTable took 2.134497 seconds\n", " metadataTable took 0.000925 seconds\n", " stdoutBlock took 0.001139 seconds\n", " profilerTable took 0.000953 seconds\n", " softwareEnvTable took 0.03216 seconds\n", " exampleTable took 0.059328 seconds\n", " singleMetricTable_gv took 8.128886 seconds\n", " singleMetricTable_gi took 0.124729 seconds\n", " fiducialListTable took 0.000693 seconds\n", " prepStrListTable took 0.000236 seconds\n", " effectStrListTable took 0.000848 seconds\n", " colorBoxPlotKeyPlot took 0.07533 seconds\n", " germList2ColTable took 0.000195 seconds\n", " progressTable took 2.847374 seconds\n", "*** Generating plots ***\n", " gramBarPlot took 0.160595 seconds\n", " progressBarPlot took 2.805841 seconds\n", " progressBarPlot_sum took 0.000327 seconds\n", " finalFitComparePlot took 1.438123 seconds\n", " bestEstimateColorBoxPlot took 2.674535 seconds\n", " bestEstimateTVDColorBoxPlot took 2.520886 seconds\n", " bestEstimateColorScatterPlot took 3.109949 seconds\n", " bestEstimateColorHistogram took 2.651904 seconds\n", " progressTable_scl took 0.000138 seconds\n", " progressBarPlot_scl took 6.7e-05 seconds\n", " bestEstimateColorBoxPlot_scl took 9.4e-05 seconds\n", " bestEstimateColorScatterPlot_scl took 0.000142 seconds\n", " bestEstimateColorHistogram_scl took 9.9e-05 seconds\n", " dataScalingColorBoxPlot took 6.5e-05 seconds\n", "*** Merging into template file ***\n", " Rendering topSwitchboard took 0.00011 seconds\n", " Rendering maxLSwitchboard1 took 7.8e-05 seconds\n", " Rendering targetSpamBriefTable took 0.020168 seconds\n", " Rendering targetGatesBoxTable took 0.026171 seconds\n", " Rendering datasetOverviewTable took 0.000915 seconds\n", " Rendering bestGatesetSpamParametersTable took 0.002183 seconds\n", " Rendering bestGatesetSpamBriefTable took 0.034955 seconds\n", " Rendering bestGatesetSpamVsTargetTable took 0.002201 seconds\n", " Rendering bestGatesetGaugeOptParamsTable took 0.001144 seconds\n", " Rendering bestGatesetGatesBoxTable took 0.045558 seconds\n", " Rendering bestGatesetChoiEvalTable took 0.034364 seconds\n", " Rendering bestGatesetDecompTable took 0.025503 seconds\n", " Rendering bestGatesetEvalTable took 0.045465 seconds\n", " Rendering bestGermsEvalTable took 0.046008 seconds\n", " Rendering bestGatesetVsTargetTable took 0.001222 seconds\n", " Rendering bestGatesVsTargetTable_gv took 0.00615 seconds\n", " Rendering bestGatesVsTargetTable_gvgerms took 0.004573 seconds\n", " Rendering bestGatesVsTargetTable_gi took 0.004305 seconds\n", " Rendering bestGatesVsTargetTable_gigerms took 0.001967 seconds\n", " Rendering bestGatesVsTargetTable_sum took 0.005763 seconds\n", " Rendering bestGatesetErrGenBoxTable took 0.0786 seconds\n", " Rendering metadataTable took 0.003266 seconds\n", " Rendering stdoutBlock took 0.001288 seconds\n", " Rendering profilerTable took 0.002029 seconds\n", " Rendering softwareEnvTable took 0.003089 seconds\n", " Rendering exampleTable took 0.004039 seconds\n", " Rendering metricSwitchboard_gv took 4e-05 seconds\n", " Rendering metricSwitchboard_gi took 4.8e-05 seconds\n", " Rendering singleMetricTable_gv took 0.010279 seconds\n", " Rendering singleMetricTable_gi took 0.006699 seconds\n", " Rendering fiducialListTable took 0.004049 seconds\n", " Rendering prepStrListTable took 0.003351 seconds\n", " Rendering effectStrListTable took 0.002862 seconds\n", " Rendering colorBoxPlotKeyPlot took 0.004189 seconds\n", " Rendering germList2ColTable took 0.001848 seconds\n", " Rendering progressTable took 0.002292 seconds\n", " Rendering gramBarPlot took 0.003997 seconds\n", " Rendering progressBarPlot took 0.003744 seconds\n", " Rendering progressBarPlot_sum took 0.003275 seconds\n", " Rendering finalFitComparePlot took 0.002757 seconds\n", " Rendering bestEstimateColorBoxPlot took 0.031481 seconds\n", " Rendering bestEstimateTVDColorBoxPlot took 0.027688 seconds\n", " Rendering bestEstimateColorScatterPlot took 0.037231 seconds\n", " Rendering bestEstimateColorHistogram took 0.017917 seconds\n", " Rendering progressTable_scl took 0.000876 seconds\n", " Rendering progressBarPlot_scl took 0.000922 seconds\n", " Rendering bestEstimateColorBoxPlot_scl took 0.00084 seconds\n", " Rendering bestEstimateColorScatterPlot_scl took 0.000748 seconds\n", " Rendering bestEstimateColorHistogram_scl took 0.000846 seconds\n", " Rendering dataScalingColorBoxPlot took 0.000777 seconds\n", "Output written to example_files/easy_2q_report directory\n", "*** Report Generation Complete! Total time 59.092s ***\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.6.4" } }, "nbformat": 4, "nbformat_minor": 0 }