{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from matplotlib import pyplot as plt\n", "from pprint import pprint\n", "np.set_printoptions(precision=4, linewidth=120, floatmode='maxprec_equal')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pygsti\n", "import pygsti.extras.interpygate as interp\n", "from pygsti.tools.basistools import change_basis\n", "from pygsti.modelpacks import smq1Q_XY" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "working_dir = Path.cwd()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Build model gate" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "sigI = np.array([[1.,0],[0, 1]], dtype='complex')\n", "sigX = np.array([[0, 1],[1, 0]], dtype='complex')\n", "sigY = np.array([[0,-1],[1, 0]], dtype='complex') * 1.j\n", "sigZ = np.array([[1, 0],[0,-1]], dtype='complex')\n", "sigM = (sigX - 1.j*sigY)/2.\n", "sigP = (sigX + 1.j*sigY)/2." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "class SingleQubitTargetOp(pygsti.modelmembers.operations.OpFactory):\n", "\n", " def __init__(self):\n", " self.process = self.create_target_gate\n", " pygsti.modelmembers.operations.OpFactory.__init__(self, 1, evotype=\"densitymx\")\n", " self.dim = 4\n", "\n", " def create_target_gate(self, v):\n", " \n", " phi, theta = v\n", " target_unitary = (np.cos(theta/2) * sigI + \n", " 1.j * np.sin(theta/2) * (np.cos(phi) * sigX + np.sin(phi) * sigY))\n", " superop = change_basis(np.kron(target_unitary.conj(), target_unitary), 'col', 'pp')\n", "\n", " return superop\n", " \n", " def create_object(self, args=None, sslbls=None):\n", " assert(sslbls is None)\n", " mx = self.process([*args])\n", " return pygsti.modelmembers.operations.StaticArbitraryOp(mx)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "class SingleQubitGate(interp.PhysicalProcess):\n", " def __init__(self, \n", " verbose=False,\n", " cont_param_gate = False,\n", " num_params = None,\n", "# process_shape = (4, 4),\n", " item_shape = (4,4),\n", " aux_shape = None,\n", " num_params_evaluated_as_group = 0,\n", " basis = 'pp'):\n", "\n", " self.verbose = verbose\n", "\n", " self.cont_param_gate = cont_param_gate\n", "\n", " self.num_params = num_params\n", " self.item_shape = item_shape\n", "\n", " self.aux_shape = aux_shape\n", " self.num_params_evaluated_as_group = num_params_evaluated_as_group\n", " self.basis = basis\n", " \n", " def create_process_matrix(self, v, comm=None, return_generator=False): \n", "\n", " processes = []\n", " phi, theta, t = v\n", " theta = theta * t\n", " target_unitary = (np.cos(theta/2) * sigI + \n", " 1.j * np.sin(theta/2) * (np.cos(phi) * sigX + np.sin(phi) * sigY))\n", " superop = change_basis(np.kron(target_unitary.conj(), target_unitary), 'col', 'pp')\n", " processes += [superop]\n", " return np.array(processes) if (processes is not None) else None\n", "\n", " def create_aux_info(self, v, comm=None):\n", " return [] # matches aux_shape=() above\n", " \n", " def create_process_matrices(self, v, grouped_v, comm=None):\n", " assert(len(grouped_v) == 1) # we expect a single \"grouped\" parameter\n", "\n", " processes = []\n", " times = grouped_v[0]\n", " phi_in, theta_in = v\n", " for t in times:\n", " phi = phi_in\n", " theta = theta_in * t\n", " target_unitary = (np.cos(theta/2) * sigI + \n", " 1.j * np.sin(theta/2) * (np.cos(phi) * sigX + np.sin(phi) * sigY))\n", " superop = change_basis(np.kron(target_unitary.conj(), target_unitary), 'col', 'pp')\n", " processes += [superop]\n", " return np.array(processes) if (processes is not None) else None\n", "\n", " def create_aux_infos(self, v, grouped_v, comm=None):\n", " import numpy as np\n", " times = grouped_v[0]\n", " return [ [] for t in times] # list elements must match aux_shape=() above" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "param_ranges = [(0.9,1.1,3)]\n", "\n", "arg_ranges = [2*np.pi*(1+np.cos(np.linspace(np.pi,0, 7)))/2,\n", " (0, np.pi, 3)] \n", "arg_indices = [0,1]\n", "\n", "\n", "target_op = SingleQubitTargetOp()\n", "gate_process = SingleQubitGate(num_params = 3,num_params_evaluated_as_group = 1)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/kyoung/Documents/Research/dev/venvs/pygsti_interpygate/lib/pyGSTi/pygsti/extras/interpygate/core.py:675: ComplexWarning: Casting complex values to real discards the imaginary part\n", " data[ind] = val # (other procs can just return None, so val = None)\n" ] } ], "source": [ "opfactory_linear = interp.InterpolatedOpFactory.create_by_interpolating_physical_process(\n", " target_op, gate_process, argument_ranges=arg_ranges, parameter_ranges=param_ranges, \n", " argument_indices=arg_indices, interpolator_and_args='linear')\n", "\n", "opfactory_spline = interp.InterpolatedOpFactory.create_by_interpolating_physical_process(\n", " target_op, gate_process, argument_ranges=arg_ranges, parameter_ranges=param_ranges, \n", " argument_indices=arg_indices, interpolator_and_args='spline')\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "pygsti.extras.interpygate.core.InterpolatedOpFactory" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(opfactory_linear)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check that the interpolator is working" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "if False:\n", " indices = (2,3)\n", " nparams = 30\n", "\n", " x = np.linspace(0,2*np.pi, nparams)\n", " y = np.linspace(0, np.pi, nparams)\n", " for p in np.linspace(.9,1.1,5):\n", "\n", " def interp_linear(x, y): \n", " op = opfactory_linear.create_op([x, y])\n", " return op.base_interpolator([x,y,p])[indices]\n", "\n", " def interp_spline(x, y): \n", " op = opfactory_spline.create_op([x, y])\n", " return op.base_interpolator([x,y,p])[indices]\n", "\n", " def truth(x, y):\n", " tmp_gate = gate_process.create_process_matrix([x,y,p])[0]\n", " tar_gate = target_op.create_target_gate([x,y])\n", " return pygsti.error_generator(tmp_gate, tar_gate, 'pp', 'logGTi')[indices]\n", "\n", "\n", " X, Y = np.meshgrid(x, y, indexing='ij')\n", " Z_linear = np.zeros([nparams, nparams])\n", " Z_spline = np.zeros([nparams, nparams])\n", " Z_truth = np.zeros([nparams, nparams])\n", " for idx, xx in enumerate(x):\n", " for idy, yy in enumerate(y):\n", " Z_linear[idx,idy] = interp_linear(xx,yy)\n", " Z_spline[idx,idy] = interp_spline(xx,yy)\n", " Z_truth[idx,idy] = truth(xx,yy)\n", "\n", " fig = plt.figure(figsize=(10,10))\n", " ax = plt.axes(projection='3d')\n", "\n", " ax.plot_surface(X, Y, Z_linear-Z_truth, rstride=1, cstride=1,\n", " edgecolor='none', alpha=.8)\n", " ax.plot_surface(X, Y, Z_spline-Z_truth, rstride=1, cstride=1,\n", " cmap='viridis', edgecolor='none', alpha=.8)\n", "\n", " ax.set_xlabel('x')\n", " ax.set_ylabel('y')\n", " ax.set_zlabel('z')\n", " # ax.set_zlim(-1,1)\n", " plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Build a model from this gate" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "scrolled": false }, "outputs": [], "source": [ "x_gate = opfactory_spline.create_op([0,np.pi/4])\n", "y_gate = opfactory_spline.create_op([np.pi/2,np.pi/4])" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[ 1.0000 0.0000 0.0000 0.0000]\n", " [ 0.0000 1.0000 0.0000 0.0000]\n", " [ 0.0000 0.0000 0.6902 0.7236]\n", " [ 0.0000 0.0000 -0.7236 0.6902]]\n", "\n", "[[ 1.0000 0.0000 -0.0000 0.0000]\n", " [-0.0000 0.7071 0.0000 -0.7071]\n", " [ 0.0000 0.0000 1.0000 0.0000]\n", " [ 0.0000 0.7071 -0.0000 0.7071]]\n" ] } ], "source": [ "x_gate.from_vector([1.03])\n", "y_gate.from_vector([1.0])\n", "print(np.round_(x_gate,4))\n", "print()\n", "print(np.round_(y_gate,4))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "x_gate.parameter_bounds = np.array([[0.91, 1.09]])\n", "y_gate.parameter_bounds = np.array([[0.91, 1.09]])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Make a fake dataset" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "#Model only has Gx and Gy gates. Let's rename them.\n", "\n", "model = pygsti.models.ExplicitOpModel([0],'pp')\n", "\n", "model['rho0'] = [ 1/np.sqrt(2), 0, 0, 1/np.sqrt(2) ] # density matrix [[1, 0], [0, 0]] in Pauli basis\n", "model['Mdefault'] = pygsti.modelmembers.povms.UnconstrainedPOVM(\n", " {'0': [ 1/np.sqrt(2), 0, 0, 1/np.sqrt(2) ], # projector onto [[1, 0], [0, 0]] in Pauli basis\n", " '1': [ 1/np.sqrt(2), 0, 0, -1/np.sqrt(2) ] }, evotype=\"default\") # projector onto [[0, 0], [0, 1]] in Pauli basis\n", "model['Gxpi2',0] = x_gate\n", "model['Gypi2',0] = y_gate" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "14" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.num_params" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OutcomeLabelDict([(('0',), 0.7440309049146735), (('1',), 0.2559690950853263)])" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Define the error model used to generate data\n", "datagen_model = model.copy()\n", "datagen_params = datagen_model.to_vector()\n", "datagen_params[-2:] = [1.03,1.00]\n", "datagen_model.from_vector(datagen_params)\n", "datagen_model.probabilities( (('Gxpi2',0),('Gypi2',0),))" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([(Label('rho0'), 'VecElement Re(0)'), (Label('rho0'), 'VecElement Re(1)'), (Label('rho0'), 'VecElement Re(2)'),\n", " (Label('rho0'), 'VecElement Re(3)'), (Label('Mdefault'), 'VecElement Re(0)'),\n", " (Label('Mdefault'), 'VecElement Re(1)'), (Label('Mdefault'), 'VecElement Re(2)'),\n", " (Label('Mdefault'), 'VecElement Re(3)'), (Label('Mdefault'), 'VecElement Re(0)'),\n", " (Label('Mdefault'), 'VecElement Re(1)'), (Label('Mdefault'), 'VecElement Re(2)'),\n", " (Label('Mdefault'), 'VecElement Re(3)'), (Label(('Gxpi2', 0)), 'Unknown param 0'),\n", " (Label(('Gypi2', 0)), 'Unknown param 0')], dtype=object)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.parameter_labels" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "14\n" ] } ], "source": [ "# # Link the over-rotation errors on Gx and Gy\n", "#model.collect_parameters(model.parameter_labels[-2:], 'Shared Gx/Gy physical parameter')\n", "#print(model.parameter_labels)\n", "print(model.num_params)\n", "\n", "# # Define the error model used to generate data\n", "# datagen_model = model.copy()\n", "# datagen_params = datagen_model.to_vector()\n", "# datagen_params[-1:] = [1.02]\n", "# datagen_model.from_vector(datagen_params)\n", "# datagen_model.probabilities( (('Gxpi2',0),('Gypi2',0),))" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OutcomeLabelDict([(('0',), 0.7440309049146735), (('1',), 0.2559690950853263)])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Define the perfect target model\n", "target_model = model.copy()\n", "target_params = target_model.to_vector()\n", "target_params[-2:] = [1,1]\n", "# target_model.from_vector(target_params)\n", "target_model.probabilities( (('Gxpi2',0),('Gypi2',0),))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Germ and fiducial selection" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initial Length Available Germ List: 23\n", "Length Available Germ List After Deduping: 23\n", "Length Available Germ List After Dropping Random Fraction: 23\n", "Memory estimate of 0.0 GB for all-Jac mode.\n", "Memory estimate of 0.0 GB for single-Jac mode.\n", "Using greedy algorithm.\n", "Number of gauge parameters: 12\n", "Number of non-gauge parameters: 2\n", "Memory estimate of 0.0 GB for all-Jac mode.\n", "Memory estimate of 0.0 GB for single-Jac mode.\n", "Complete initial germ set succeeds on all input models.\n", "Now searching for best germ set.\n", "Starting germ set optimization. Lower score is better.\n", " Numpy Array Data Type: complex128\n", " Numpy array data type for twirled derivatives is: complex128 If this isn't what you specified then something went wrong.\n", " Outer iteration: 1 of 2 amplified, 0 germs\n", " Inner iter over candidate germs Iter 01 of 23 Gxpi2:0@(0): \n", " Inner iter over candidate germs Iter 02 of 23 Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 03 of 23 Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 04 of 23 Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 05 of 23 Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 06 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 07 of 23 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 08 of 23 Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 09 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 10 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 11 of 23 Gxpi2:0Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 12 of 23 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 13 of 23 Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 14 of 23 Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 15 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 16 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 17 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 18 of 23 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 19 of 23 Gxpi2:0Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 20 of 23 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 21 of 23 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 22 of 23 Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 23 of 23 Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Added Gxpi2:0@(0) to final germs (Score: major=-1.0 minor=0.8106018907759105, N: 1)\n", " Outer iteration: 1 of 2 amplified, 1 germs\n", " Inner iter over candidate germs Iter 01 of 22 Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 02 of 22 Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 03 of 22 Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 04 of 22 Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 05 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 06 of 22 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 07 of 22 Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 08 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 09 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 10 of 22 Gxpi2:0Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 11 of 22 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 12 of 22 Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 13 of 22 Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 14 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 15 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 16 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 17 of 22 Gxpi2:0Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 18 of 22 Gxpi2:0Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 19 of 22 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gxpi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 20 of 22 Gxpi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 21 of 22 Gxpi2:0Gypi2:0Gxpi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Inner iter over candidate germs Iter 22 of 22 Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0): \n", " Added Gypi2:0@(0) to final germs (Score: major=-2.0 minor=1.6212037816746303, N: 2)\n", " Outer iteration: 2 of 2 amplified, 2 germs\n", "Constructed germ set:\n", "['Gxpi2:0@(0)', 'Gypi2:0@(0)']\n", "Score: major=-2.0 minor=1.6212037816746303, N: 2\n" ] } ], "source": [ "final_germs = pygsti.algorithms.germselection.find_germs(\n", " target_model, randomize=False, force=None, algorithm='greedy', \n", " verbosity=4, num_nongauge_params=2)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "fiducial_pairs = pygsti.algorithms.fiducialpairreduction.find_sufficient_fiducial_pairs_per_germ(\n", " model, \n", " smq1Q_XY.prep_fiducials(),\n", " smq1Q_XY.meas_fiducials(), \n", " final_germs)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "# # Reduce the number of fiducial pairs by hand, if you want\n", "\n", "# fiducial_pairs2 = fiducial_pairs.copy()\n", "# for key in fiducial_pairs2.keys():\n", "# fiducial_pairs2[key] = fiducial_pairs2[key][0:2]\n", "# fiducial_pairs = fiducial_pairs2\n", "\n", "# print(fiducial_pairs)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/kyoung/Documents/Research/dev/venvs/pygsti_interpygate/lib/pyGSTi/pygsti/protocols/gst.py:265: UserWarning: Given model failed to create a processor spec for StdGST experiment design!\n", " _warnings.warn(\"Given model failed to create a processor spec for StdGST experiment design!\")\n" ] } ], "source": [ "# Use fiducial pair reductions\n", "exp_design = pygsti.protocols.StandardGSTDesign(model, \n", " smq1Q_XY.prep_fiducials(), \n", " smq1Q_XY.meas_fiducials(), \n", " final_germs, \n", " max_lengths=[1,2,4,8,16,32,64,128,256], \n", " fiducial_pairs=fiducial_pairs,\n", " include_lgst=False)\n", "\n", "dataset = pygsti.data.simulate_data(datagen_model, exp_design.all_circuits_needing_data,\n", " num_samples=1000, seed=1234)\n", "\n", "data = pygsti.protocols.ProtocolData(exp_design, dataset)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "54" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(data.dataset)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fisher information matrix" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "fim = pygsti.tools.edesigntools.calculate_fisher_information_matrix(model,\n", " exp_design.all_circuits_needing_data)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/var/folders/05/42d4jfz15870xr0c6hjc_c800026_n/T/ipykernel_28989/1867990375.py:1: RuntimeWarning: invalid value encountered in log\n", " np.log(np.linalg.inv(fim))\n" ] }, { "data": { "text/plain": [ "array([[ -4.6821, -35.7964, nan, -4.6831, -36.5502, -36.3732, nan, -34.8380, nan, -40.8147, -38.8576,\n", " nan, -42.3144, -40.4273],\n", " [-36.4592, nan, -3.9925, -2.2600, nan, nan, -3.1437, nan, -4.0221, nan, -5.8737,\n", " -2.4551, nan, nan],\n", " [ nan, -3.9925, -2.9301, nan, -5.8227, -4.4764, -3.3587, -2.6634, nan, -5.5915, nan,\n", " nan, nan, -8.4140],\n", " [ -4.6831, -2.2600, nan, nan, -2.9565, -2.9226, nan, -1.2843, nan, -5.0098, -4.8720,\n", " nan, -8.8423, -6.7621],\n", " [-37.1522, nan, -5.8227, -2.9565, -4.0587, nan, -4.6441, nan, -6.6871, -3.8383, -4.4721,\n", " -2.9887, nan, -10.0110],\n", " [-37.1286, nan, -4.4764, -2.9226, nan, -3.4414, -3.5031, nan, -3.6720, nan, nan,\n", " -3.5654, -9.4105, nan],\n", " [ nan, -3.1437, -3.3587, nan, -4.6441, -3.5031, -3.5722, -2.0321, nan, nan, nan,\n", " nan, -9.8530, -7.7389],\n", " [-35.4846, nan, -2.6634, -1.2843, nan, nan, -2.0321, nan, -3.3582, -4.1831, -5.5326,\n", " -1.4265, nan, nan],\n", " [ nan, -4.0221, nan, nan, -6.6871, -3.6720, nan, -3.3582, -4.0587, nan, nan,\n", " nan, -9.6583, nan],\n", " [-39.0313, nan, -5.5915, -5.0098, -3.8383, nan, nan, -4.1831, nan, -2.2352, -5.1607,\n", " -3.5679, nan, -6.9599],\n", " [-38.9034, -5.8737, nan, -4.8720, -4.4721, nan, nan, -5.5326, nan, -5.1607, -2.5261,\n", " -3.9855, nan, -9.1875],\n", " [ nan, -2.4551, nan, nan, -2.9887, -3.5654, nan, -1.4265, nan, -3.5679, -3.9855,\n", " nan, -9.2930, -6.7245],\n", " [-43.0430, nan, nan, -8.8423, nan, -9.4105, -9.8530, nan, -9.6583, nan, nan,\n", " -9.2930, -11.3246, nan],\n", " [-40.9468, nan, -8.4140, -6.7621, -10.0110, nan, -7.7389, nan, nan, -6.9599, -9.1875,\n", " -6.7245, nan, -10.7647]])" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.log(np.linalg.inv(fim))" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAGkCAYAAACckEpMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnN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FP5+fl9Pqe+vl6hUKjnVlJSksyVAAADUNJi1N3drdtvv12e56mhoeGUz6utrVUkEum5tba2JmslAMAAlZRv030bov379+vdd9895VmRJAWDQQWDwWSsAQBIEb7H6NsQ7d27V5s2bdKQIUP8HgEASDP9jtHRo0e1b9++no9bWlrU3NysgoICFRcX69Zbb1VTU5M2bNigeDyutrY2SVJBQYGysrL82xwAkDb6HaOdO3fquuuu6/m4pqZGklRZWamHH35Y69evlyRdddVVvf6/TZs2aerUqWe/KQAgbfU7RlOnTpXnnfrfkj3dYwAA9IVr0wEAzBEjAIA5YgQAMEeMAADmiBEAwBwxAgCYS/pVu2Eg4GiOw3fxBzw3B+UF+KsJ+A5XX0+S06+pgYYzIwCAOWIEADBHjAAA5ogRAMAcMQIAmCNGAABzxAgAYI4YAQDMESMAgDliBAAwR4wAAOaIEQDAHDECAJgjRgAAc8QIAGCOGAEAzBEjAIA5YgQAMEeMAADmiBEAwBwxAgCYI0YAAHPECABgjhgBAMwRIwCAuUHWC3yX53mSpERXl/EmKSzgaI7naI6kgOfmoLyAw4NCanD19SQ5/Zpy4dvX8W9f108n4J3Jsxz64osvVFJSYr0GAMAnra2tGjZs2GmfM+BilEgkdPDgQeXl5SkQOPPfkkSjUZWUlKi1tVX5+flJ3NAdjik1cEypgWNyz/M8HTlyROFwWBkZp/9ToQH3bbqMjIzvLejp5OfnD8hflHPBMaUGjik1cExuhUKhM3oeb2AAAJgjRgAAc2kTo2AwqIceekjBYNB6Fd9wTKmBY0oNHNPANuDewAAAOP+kzZkRACB1ESMAgDliBAAwR4wAAOaIEQDAHDECAJgjRgAAc8QIAGDu/wD7PJixT0NWNAAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.matshow(np.linalg.inv(fim))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Run GST on the dataset" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Iterative GST: Iter 1 of 9 6 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 0.00354097 (6 data params - 14 (approx) model params = expected mean of -8; p-value = nan)\n", " Completed in 0.1s\n", " Iteration 1 took 0.1s\n", " \n", "--- Iterative GST: Iter 2 of 9 12 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 0.964698 (12 data params - 14 (approx) model params = expected mean of -2; p-value = nan)\n", " Completed in 0.1s\n", " Iteration 2 took 0.2s\n", " \n", "--- Iterative GST: Iter 3 of 9 18 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 4.36193 (18 data params - 14 (approx) model params = expected mean of 4; p-value = 0.359234)\n", " Completed in 0.3s\n", " Iteration 3 took 0.3s\n", " \n", "--- Iterative GST: Iter 4 of 9 24 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 10.9846 (24 data params - 14 (approx) model params = expected mean of 10; p-value = 0.358721)\n", " Completed in 0.2s\n", " Iteration 4 took 0.2s\n", " \n", "--- Iterative GST: Iter 5 of 9 30 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 17.6314 (30 data params - 14 (approx) model params = expected mean of 16; p-value = 0.345921)\n", " Completed in 0.2s\n", " Iteration 5 took 0.2s\n", " \n", "--- Iterative GST: Iter 6 of 9 36 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 22.5374 (36 data params - 14 (approx) model params = expected mean of 22; p-value = 0.42823)\n", " Completed in 0.1s\n", " Iteration 6 took 0.2s\n", " \n", "--- Iterative GST: Iter 7 of 9 42 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 26.8321 (42 data params - 14 (approx) model params = expected mean of 28; p-value = 0.527403)\n", " Completed in 0.1s\n", " Iteration 7 took 0.1s\n", " \n", "--- Iterative GST: Iter 8 of 9 48 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 35.9125 (48 data params - 14 (approx) model params = expected mean of 34; p-value = 0.378927)\n", " Completed in 0.2s\n", " Iteration 8 took 0.2s\n", " \n", "--- Iterative GST: Iter 9 of 9 54 circuits ---: \n", " MatrixLayout: 1 processors divided into 1 x 1 (= 1) grid along circuit and parameter directions.\n", " 1 atoms, parameter block size limits (None,)\n", " *** Distributing 1 atoms to 1 atom-processing groups (1 cores) ***\n", " More atom-processors than hosts: each host gets ~1 atom-processors\n", " Atom-processors already occupy a single node, dividing atom-processor into 1 param-processors.\n", " *** Divided 1-host atom-processor (~1 procs) into 1 param-processing groups ***\n", " --- chi2 GST ---\n", " Sum of Chi^2 = 40.6971 (54 data params - 14 (approx) model params = expected mean of 40; p-value = 0.439593)\n", " Completed in 0.2s\n", " Iteration 9 took 0.3s\n", " \n", " Last iteration:\n", " --- dlogl GST ---\n", " 2*Delta(log(L)) = 41.0113 (54 data params - 14 (approx) model params = expected mean of 40; p-value = 0.425988)\n", " Completed in 0.6s\n", " Final optimization took 0.6s\n", " \n", "Iterative GST Total Time: 2.3s\n" ] } ], "source": [ "proto = pygsti.protocols.GateSetTomography(model, gaugeopt_suite=None)\n", "results = proto.run(data)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Actual: [1.03 1.00]\n", "Estimated: [1.0303 1.0003]\n" ] } ], "source": [ "# What is the estimated value of the error parameter?\n", "\n", "final_model = results.estimates['GateSetTomography'].models['final iteration estimate']\n", "print('Actual: ', datagen_model.to_vector()[-2:])\n", "print('Estimated: ', final_model.to_vector()[-2:])" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "array([ 1.0011, -0.0056, 0.0060, 1.0006])\n", "array([ 1.0033, -0.0246, 0.0086, 1.0026])\n", "array([ 0.9978, 0.0204, -0.0169, -0.9982])\n" ] } ], "source": [ "pprint(np.sqrt(2)*final_model.to_vector()[0:4])\n", "pprint(np.sqrt(2)*final_model.to_vector()[4:8])\n", "pprint(np.sqrt(2)*final_model.to_vector()[8:12])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python (pygsti_interpygate)", "language": "python", "name": "pygsti_interpygate" }, "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.0" } }, "nbformat": 4, "nbformat_minor": 4 }