{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to generate error bars for 2Q-GST\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pygsti\n", "import time\n", "\n", "#If we were using MPI\n", "# from mpi4py import MPI\n", "# comm = MPI.COMM_WORLD\n", "comm = None\n", "\n", "#Load the 2-qubit results (if you don't have this directory, run the 2Q-GST example)\n", "results = pygsti.io.read_results_from_dir(\"example_files/My2QExample\", \"StandardGST\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true, "tags": [] }, "outputs": [], "source": [ "# error bars in reports require the presence of a fully-initialized\n", "# \"confidence region factory\" within the relevant Estimate object.\n", "# In most cases \"fully-initialized\" means that a Hessian has been \n", "# computed and projected onto the non-gauge space.\n", "\n", "# Choose forward simulator and how computation should be split up. Here are a couple examples:\n", "#results.estimates['CPTP'].models['stdgaugeopt'].sim = pygsti.forwardsims.MapForwardSimulator(num_atoms=100)\n", "results.estimates['CPTPLND'].models['stdgaugeopt'].sim = pygsti.forwardsims.MatrixForwardSimulator(param_blk_sizes=(30,30))\n", "\n", "# initialize a factory for the 'go0' gauge optimization within the 'default' estimate\n", "crfact = results.estimates['CPTPLND'].add_confidence_region_factory('stdgaugeopt', 'final')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true, "tags": [ "nbval-skip" ] }, "outputs": [], "source": [ "crfact.compute_hessian(comm=comm, mem_limit=3.0*(1024.0)**3) #optionally use multiple processors & set memlimit\n", "crfact.project_hessian('intrinsic error')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note above cell was executed for demonstration purposes, and was **keyboard-interrupted intentionally** since it would have taken forever on a single processor." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "nbval-skip" ] }, "outputs": [], "source": [ "#write results back to disk\n", "results.write()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.13" } }, "nbformat": 4, "nbformat_minor": 4 }