{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Tutorial showing use of a `Workspace` object\n", "### Part 2: Switchboards\n", "\n", "\"This tutorial introduces the `Switchboard` workspace object and demonstrates its use. You may have gotten the sense from the last tutorial that screen real estate can quickly be taken up by plots and tables. Wouldn't it me nice if we could interactively switch between plots or figures using buttons or sliders instead of having to scroll through endless pages of plots? `Switchboard` to the rescue!\n", "\n", "First though, let's run GST on the standard 1Q model to get some results (the same ones as the first tutorial)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- LGST ---\n", " Singular values of I_tilde (truncating to first 4 of 6) = \n", " 4.244328793221975\n", " 1.159506846570491\n", " 0.9649617410146953\n", " 0.9298672060840962\n", " 0.029510276363796027\n", " 0.015229208752962249\n", " \n", " Singular values of target I_tilde (truncating to first 4 of 6) = \n", " 4.242640687119289\n", " 1.4142135623730965\n", " 1.4142135623730963\n", " 1.414213562373096\n", " 2.3622173882006357e-16\n", " 1.3362030788752568e-16\n", " \n", "MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits ()\n", "*** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", "--- LGST ---\n", " Singular values of I_tilde (truncating to first 4 of 6) = \n", " 4.243015084729839\n", " 1.2760361082265363\n", " 1.1880547371027554\n", " 1.1273979665546423\n", " 0.040505909458993954\n", " 0.006154609019536988\n", " \n", " Singular values of target I_tilde (truncating to first 4 of 6) = \n", " 4.242640687119289\n", " 1.4142135623730965\n", " 1.4142135623730963\n", " 1.414213562373096\n", " 2.3622173882006357e-16\n", " 1.3362030788752568e-16\n", " \n", "MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits ()\n", "*** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", "--- LGST ---\n", " Singular values of I_tilde (truncating to first 4 of 6) = \n", " 4.243408966836775\n", " 1.215749715539674\n", " 1.0745548673227847\n", " 1.0278962361191093\n", " 0.026830767403026236\n", " 0.005978640323065989\n", " \n", " Singular values of target I_tilde (truncating to first 4 of 6) = \n", " 4.242640687119289\n", " 1.4142135623730965\n", " 1.4142135623730963\n", " 1.414213562373096\n", " 2.3622173882006357e-16\n", " 1.3362030788752568e-16\n", " \n", "MatrixLayout: 1 processors divided into 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits ()\n", "*** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n" ] } ], "source": [ "import numpy as np\n", "import pygsti\n", "from pygsti.modelpacks import smq1Q_XYI\n", "\n", "#The usual GST setup: we're going to run GST on the standard XYI 1-qubit model\n", "target_model = smq1Q_XYI.target_model()\n", "prep_fiducials = smq1Q_XYI.prep_fiducials()\n", "meas_fiducials = smq1Q_XYI.meas_fiducials()\n", "germs = smq1Q_XYI.germs()\n", "maxLengths = [1,2,4,8]\n", "listOfExperiments = pygsti.circuits.create_lsgst_circuits(\n", " target_model.operations.keys(), prep_fiducials, meas_fiducials, germs, maxLengths)\n", "\n", "#Create some datasets for analysis\n", "mdl_datagen1 = target_model.depolarize(op_noise=0.1, spam_noise=0.001)\n", "mdl_datagen2 = target_model.depolarize(op_noise=0.05, spam_noise=0.01).rotate(rotate=(0.01,0,0))\n", "\n", "ds1 = pygsti.data.simulate_data(mdl_datagen1, listOfExperiments, num_samples=1000,\n", " sample_error=\"binomial\", seed=1234)\n", "ds2 = pygsti.data.simulate_data(mdl_datagen2, listOfExperiments, num_samples=1000,\n", " sample_error=\"binomial\", seed=1234)\n", "ds3 = ds1.copy_nonstatic(); ds3.add_counts_from_dataset(ds2); ds3.done_adding_data()\n", "\n", "#Run GST on all three datasets\n", "target_model.set_all_parameterizations(\"full TP\")\n", "results1 = pygsti.run_long_sequence_gst(ds1, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=0)\n", "results2 = pygsti.run_long_sequence_gst(ds2, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=0)\n", "results3 = pygsti.run_long_sequence_gst(ds3, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=0)\n", "\n", "#make some shorthand variable names for later\n", "tgt = results1.estimates['GateSetTomography'].models['target']\n", "\n", "ds1 = results1.dataset\n", "ds2 = results2.dataset\n", "ds3 = results3.dataset\n", "\n", "mdl1 = results1.estimates['GateSetTomography'].models['go0']\n", "mdl2 = results2.estimates['GateSetTomography'].models['go0']\n", "mdl3 = results3.estimates['GateSetTomography'].models['go0']\n", "\n", "circuits = results1.circuit_lists['final']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we create the workspace, as before. This time, we'll leave `autodisplay=False` (the default), to demonstrate how this gives us more control over when workspace items are displayed. In particular, we'll build up a several workspace objects and display them all at once. **NOTE that setting `connected=True` means you need to have an internet connection!**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "