{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "from pygsti.extras.errorgenpropagation.propagatableerrorgen import *\n", "from pygsti.extras.errorgenpropagation.errorpropagator import *\n", "from pygsti.circuits import Circuit\n", "import numpy as np\n", "import pygsti.processors\n", "import pygsti\n", "import pygsti.tools.lindbladtools as _lt\n", "import scipy\n", "import matplotlib.pyplot as plt" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to the Propagatable Error Generators Code" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Defining a circuit and error generators" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Currently Error Propgagation works for any model that meets three criteria\n", "\n", " 1. The circuit is clifford\n", " 2. The errors on each gate can be defined at a time t of interest in the small markovian errors basis\n", " 3. The error error model is defined such that a gate G has some linear combination of error generators following it\n", "\n", "We can therefore, start a code by defining a circuit and an error model by simply following the common pyGSTi notation" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "errorModel={\n", " 'Gxpi2' : {('H','Y'):.01}\n", "\n", "}\n", "c=Circuit(10*[('Gxpi2',0)])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Now we can take the above definitions and plug them into the errorpropagator function, to get out a list of post-circuit error generators out." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "errors=ErrorPropagator(c,errorModel,BCHOrder=1,BCHLayerwise=False,NonMarkovian=False)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Here BCH order determines the to what order the BCH order will be taken to (if applicable). BCHLayerwise will if false, propagatate all errors to the end before taking the BCH expansion, otherwise it will push the errorgens through a layer and combine with the the error generators for that layer by the rules given by the BCHOrder. Non-markovian prevents any simplification or BCH expansions being taken, instead allowing the output to be a list a lists, where the each sublist denotes the errorgenerators that were occuring at time t in the circuit." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Additionally, if you want to describe a gate with multiple associated error definitions you can define it as follows." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('H', ('X',), (0.09999999999999999+0j))]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MultiGateDict={'Gxpi22' : 'Gxpi2'}\n", "errorModel={\n", " 'Gxpi2' : {('H','Y'):.01},\n", " 'Gxpi22' : {('H','X'):.01}\n", "\n", "}\n", "c=Circuit(10*[('Gxpi2',0),('Gxpi22',0)])\n", "\n", "ErrorPropagator(c,errorModel,MultiGateDict=MultiGateDict, MultiGate=True)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Once the errors are propagated to the process matrix given by the end of circuit error generators is given by" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "expMat=np.zeros([4**len(c.line_labels),4**len(c.line_labels)],dtype=np.complex128)\n", "for error in errors:\n", " expMat +=error.toWeightedErrorBasisMatrix()\n", "processMatrix = scipy.linalg.expm(expMat)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Non-Markovianity" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "If you want to use the non markovianity function you need to define an n x n correlation where n is the number of layers." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "PyGSTi_EOC", "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.11.4" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }