{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Instability Detection and Characterization\n", "\n", "This tutorial shows how to implement instability (\"drift\") detection and characterization on time-stamped data. This data can be from *any* quantum circuits, on *any* number of qubits, but we require around 100+ time-stamps per circuit (perhaps fewer if there are multiple measurement outcomes per time-stamp). If you only have data that is binned into a few different time periods then consider instead using the `DataComparator` object demonstrated in the [DataSetComparison](../algorithms/DatasetComparison.ipynb) tutorial.\n", "\n", "Currently the gap between data collection times for each circuit is required to be approximately constant, both across the data collection times for each circuit, and across circuits. If this is not the case the code should still work, but the analysis it performs may be significantly sub-optimal, and interpretting the results is more complicated. There is beta-level capabilities within the functions used below to properly analyze unequally-spaced data, but it is untested and will not be used with the default options in the analysis code. This limitation will be addressed in a future release of pyGSTi.\n", "\n", "This notebook is an introduction to these tools, and it will be augmented with further notebooks at a later date." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from __future__ import print_function\n", "\n", "# Importing the drift module is essential\n", "from pygsti.extras import drift\n", "\n", "# Importing all of pyGSTi is optional, but often useful.\n", "import pygsti" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quick and Easy Analysis\n", "First we import some *time-stamped* data. For more information on the mechanics of using time-stamped `DataSets` see the [TimestampedDataSets](../objects/advanced/TimestampedDataSets.ipynb) tutorial. The data we are importing is from long-sequence GST on $G_i$, $G_x$, and $G_y$ with time-dependent coherent errors on the gates." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading ../tutorial_files/timeseries_data.txt: 100%\n" ] } ], "source": [ "ds = pygsti.io.load_tddataset(\"../tutorial_files/timeseries_data.txt\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we simply pass this data to `drift.do_stability_analysis()`. This has a variety of optional arguments that can be used to optimize the tool to different circumstances, but in this tutorial we won't discuss the full range of analyzes that can be performed using the `drift` module." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " - Formatting the data...done!\n", " - Calculating power spectra...done!\n", " - Running instability detection...done!\n", " - Running instability characterization...done!\n" ] } ], "source": [ "# This'll take 5 - 10 minutes. This will be sped up in the future.\n", "results = drift.do_stability_analysis(ds)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inspecting the results\n", "\n", "Everything has been calculated, and we can now look at the results. If we print the returned results object (a `StabilityAnalyzer` object), it will tell us whether instability was detected. If no instability is detected, then there is little else to do: the circuits are, as far as we can tell, stable, and most of the other results contained in a `StabilityAnalyzer` will not be very interesting. However, here instability is detected:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Instability *has* been detected, from tests at a global significance of 5.0%\n" ] } ], "source": [ "print(results)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "