{ "cells": [ { "cell_type": "markdown", "metadata": {}, "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": {}, "outputs": [], "source": [ "from __future__ import print_function\n", "import pygsti" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1: Construct the desired 2-qubit model\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 model. (Another example covers how to create a custom 2-qubit model.)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from pygsti.construction import std2Q_XYICNOT\n", "target_model = std2Q_XYICNOT.target_model()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2: Obtain lists of fiducial and germ operation sequences\n", "These are the building blocks of the operation sequences performed in the experiment. Typically, these lists are either provided by pyGSTi because you're using a \"standard\" model (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": {}, "outputs": [], "source": [ "prep_fiducials = std2Q_XYICNOT.prepStrs\n", "effect_fiducials = std2Q_XYICNOT.effectStrs" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "germs4 = pygsti.construction.circuit_list(\n", " [ ('Gix',), ('Giy',), ('Gxi',), ('Gyi',) ] )\n", "\n", "germs11 = pygsti.construction.circuit_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": {}, "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": {}, "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 model, 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(target_model.operations.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": {}, "outputs": [], "source": [ "#Generate some \"fake\" (simulated) data based on a depolarized version of the target model\n", "mdl_datagen = target_model.depolarize(op_noise=0.1, spam_noise=0.001)\n", "ds = pygsti.construction.generate_fake_data(mdl_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": {}, "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 operation 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": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Circuit 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 model:\n", " \n", " rho0 = FullSPAMVec 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: FullSPAMVec 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: FullSPAMVec 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: FullSPAMVec 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: FullSPAMVec 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", " FullDenseOp 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", " FullDenseOp 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", " FullDenseOp 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", " FullDenseOp 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", " FullDenseOp 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", " FullDenseOp 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 operation sequences ---: \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.49\n", " --- Outer Iter 1: norm_f = 1952.43, mu=1933.11, |J|=9726.98\n", " --- Outer Iter 2: norm_f = 1642.96, mu=644.37, |J|=9666.38\n", " --- Outer Iter 3: norm_f = 1555.63, mu=214.79, |J|=9660.03\n", " --- Outer Iter 4: norm_f = 1517.27, mu=71.5967, |J|=9672.62\n", " --- Outer Iter 5: norm_f = 1501.95, mu=23.8656, |J|=9693.31\n", " --- Outer Iter 6: norm_f = 1497.5, mu=7.95519, |J|=9715.91\n", " --- Outer Iter 7: norm_f = 1496.41, mu=2.65173, |J|=9730.51\n", " --- Outer Iter 8: norm_f = 1496.21, mu=0.88391, |J|=9737.72\n", " --- Outer Iter 9: norm_f = 1496.19, mu=0.294637, |J|=9740.22\n", " --- Outer Iter 10: norm_f = 1496.19, mu=0.0982122, |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 (2721 data params - 1616 model params = expected mean of 1105; p-value = 2.81997e-14)\n", " Completed in 339.6s\n", " 2*Delta(log(L)) = 1501.17\n", " Iteration 1 took 339.7s\n", " \n", "--- Iterative MLGST: Iter 2 of 2 1317 operation sequences ---: \n", " --- Minimum Chi^2 GST ---\n", " Memory limit = 3.00GB\n", " Cur, Persist, Gather = 0.34, 0.06, 0.29 GB\n", " Evaltree generation (default) w/mem limit = 2.30GB\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 (3951 data params - 1616 model params = expected mean of 2335; p-value = 1.8225e-09)\n", " Completed in 408.5s\n", " 2*Delta(log(L)) = 2771.33\n", " Iteration 2 took 408.5s\n", " \n", " Switching to ML objective (last iteration)\n", " --- MLGST ---\n", " Memory: limit = 3.00GB(cur, persist, gthr = 0.31, 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 (3951 data params - 1616 model params = expected mean of 2335; p-value = 1.0588e-09)\n", " Completed in 261.1s\n", " 2*Delta(log(L)) = 2767.75\n", " Final MLGST took 261.1s\n", " \n", "Iterative MLGST Total Time: 1009.3s\n", " -- Adding Gauge Optimized (go0) --\n", "--- Re-optimizing logl after robust data scaling ---\n", " --- MLGST ---\n", " Memory: limit = 3.00GB(cur, persist, gthr = 0.29, 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 (3951 data params - 1616 model params = expected mean of 2335; p-value = 1.0588e-09)\n", " Completed in 43.1s\n", " -- Adding Gauge Optimized (go0) --\n", "Total time=0.293146 hours\n" ] } ], "source": [ "import time\n", "start = time.time()\n", "results = pygsti.do_long_sequence_gst(ds, target_model, 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": {}, "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": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "*** Creating workspace ***\n", "*** Generating switchboard ***\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": [ "*** Generating tables ***\n", " targetSpamBriefTable took 0.558514 seconds\n", " targetGatesBoxTable took 0.393092 seconds\n", " datasetOverviewTable took 0.041697 seconds\n", " bestGatesetSpamParametersTable took 0.000538 seconds\n", " bestGatesetSpamBriefTable took 0.372994 seconds\n", " bestGatesetSpamVsTargetTable took 1.529932 seconds\n", " bestGatesetGaugeOptParamsTable took 0.000415 seconds\n", " bestGatesetGatesBoxTable took 0.431361 seconds\n", " bestGatesetChoiEvalTable took 0.901477 seconds\n", " bestGatesetDecompTable took 7.244969 seconds\n", " bestGatesetEvalTable took 0.04129 seconds\n", " bestGermsEvalTable took 0.012821 seconds\n", " bestGatesetVsTargetTable took 0.051373 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_gv took 9.331426 seconds\n", " bestGatesVsTargetTable_gvgerms took 0.223209 seconds\n", " bestGatesVsTargetTable_gi took 0.09484 seconds\n", " bestGatesVsTargetTable_gigerms took 0.01241 seconds\n", " bestGatesVsTargetTable_sum took 9.432998 seconds\n", " bestGatesetErrGenBoxTable took 1.9915 seconds\n", " metadataTable took 0.000748 seconds\n", " stdoutBlock took 0.000933 seconds\n", " profilerTable took 0.000542 seconds\n", " softwareEnvTable took 0.032556 seconds\n", " exampleTable took 0.045136 seconds\n", " singleMetricTable_gv took 9.97891 seconds\n", " singleMetricTable_gi took 0.165092 seconds\n", " fiducialListTable took 0.000747 seconds\n", " prepStrListTable took 0.000383 seconds\n", " effectStrListTable took 0.000164 seconds\n", " colorBoxPlotKeyPlot took 0.060831 seconds\n", " germList2ColTable took 0.000195 seconds\n", " progressTable took 3.552062 seconds\n", "*** Generating plots ***\n", " gramBarPlot took 0.17467 seconds\n", " progressBarPlot took 2.135457 seconds\n", " progressBarPlot_sum took 0.001909 seconds\n", " finalFitComparePlot took 1.073815 seconds\n", " bestEstimateColorBoxPlot took 4.376099 seconds\n", " bestEstimateTVDColorBoxPlot took 3.977058 seconds\n", " bestEstimateColorScatterPlot took 5.122052 seconds\n", " bestEstimateColorHistogram took 4.155411 seconds\n", " progressTable_scl took 7.1e-05 seconds\n", " progressBarPlot_scl took 5.6e-05 seconds\n", " bestEstimateColorBoxPlot_scl took 7.8e-05 seconds\n", " bestEstimateColorScatterPlot_scl took 6.6e-05 seconds\n", " bestEstimateColorHistogram_scl took 7.1e-05 seconds\n", " dataScalingColorBoxPlot took 5.1e-05 seconds\n", "*** Merging into template file ***\n", " Rendering topSwitchboard took 0.000108 seconds\n", " Rendering maxLSwitchboard1 took 7.7e-05 seconds\n", " Rendering targetSpamBriefTable took 0.16939 seconds\n", " Rendering targetGatesBoxTable took 0.188537 seconds\n", " Rendering datasetOverviewTable took 0.000937 seconds\n", " Rendering bestGatesetSpamParametersTable took 0.001861 seconds\n", " Rendering bestGatesetSpamBriefTable took 0.51621 seconds\n", " Rendering bestGatesetSpamVsTargetTable took 0.001745 seconds\n", " Rendering bestGatesetGaugeOptParamsTable took 0.000908 seconds\n", " Rendering bestGatesetGatesBoxTable took 0.398657 seconds\n", " Rendering bestGatesetChoiEvalTable took 0.311584 seconds\n", " Rendering bestGatesetDecompTable took 0.206528 seconds\n", " Rendering bestGatesetEvalTable took 0.043702 seconds\n", " Rendering bestGermsEvalTable took 0.042149 seconds\n", " Rendering bestGatesetVsTargetTable took 0.000978 seconds\n", " Rendering bestGatesVsTargetTable_gv took 0.003662 seconds\n", " Rendering bestGatesVsTargetTable_gvgerms took 0.002338 seconds\n", " Rendering bestGatesVsTargetTable_gi took 0.003787 seconds\n", " Rendering bestGatesVsTargetTable_gigerms took 0.001739 seconds\n", " Rendering bestGatesVsTargetTable_sum took 0.00384 seconds\n", " Rendering bestGatesetErrGenBoxTable took 0.940568 seconds\n", " Rendering metadataTable took 0.004467 seconds\n", " Rendering stdoutBlock took 0.001252 seconds\n", " Rendering profilerTable took 0.001671 seconds\n", " Rendering softwareEnvTable took 0.001998 seconds\n", " Rendering exampleTable took 0.020202 seconds\n", " Rendering metricSwitchboard_gv took 4.1e-05 seconds\n", " Rendering metricSwitchboard_gi took 3.1e-05 seconds\n", " Rendering singleMetricTable_gv took 0.006546 seconds\n", " Rendering singleMetricTable_gi took 0.005427 seconds\n", " Rendering fiducialListTable took 0.005624 seconds\n", " Rendering prepStrListTable took 0.00406 seconds\n", " Rendering effectStrListTable took 0.002822 seconds\n", " Rendering colorBoxPlotKeyPlot took 0.029401 seconds\n", " Rendering germList2ColTable took 0.00213 seconds\n", " Rendering progressTable took 0.001933 seconds\n", " Rendering gramBarPlot took 0.022023 seconds\n", " Rendering progressBarPlot took 0.019769 seconds\n", " Rendering progressBarPlot_sum took 0.01847 seconds\n", " Rendering finalFitComparePlot took 0.020392 seconds\n", " Rendering bestEstimateColorBoxPlot took 0.07229 seconds\n", " Rendering bestEstimateTVDColorBoxPlot took 0.059786 seconds\n", " Rendering bestEstimateColorScatterPlot took 0.120078 seconds\n", " Rendering bestEstimateColorHistogram took 0.068549 seconds\n", " Rendering progressTable_scl took 0.000931 seconds\n", " Rendering progressBarPlot_scl took 0.000874 seconds\n", " Rendering bestEstimateColorBoxPlot_scl took 0.000825 seconds\n", " Rendering bestEstimateColorScatterPlot_scl took 0.000721 seconds\n", " Rendering bestEstimateColorHistogram_scl took 0.000796 seconds\n", " Rendering dataScalingColorBoxPlot took 0.000599 seconds\n", "Output written to example_files/easy_2q_report directory\n", "*** Report Generation Complete! Total time 71.5234s ***\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": {}, "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": {}, "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": {}, "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": 1 }