{ "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, 4, 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", " ):\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", "\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": [], "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": "markdown", "metadata": {}, "source": [ "### Check that the interpolator is working" ] }, { "cell_type": "code", "execution_count": 9, "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": 10, "metadata": {}, "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": 11, "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.6903 0.7236]\n", " [ 0.0000 0.0000 -0.7236 0.6903]]\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": "markdown", "metadata": {}, "source": [ "## Make a fake dataset" ] }, { "cell_type": "code", "execution_count": 12, "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": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "14" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.num_params" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OutcomeLabelDict([(('0',), 0.7440406663460976), (('1',), 0.2559593336539022)])" ] }, "execution_count": 14, "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": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PRINTING MODEL GPINDICES!!!\n", ">>> rho0 [FullState]: 4 params, indices=slice(0, 4, None)\n", ">>> Mdefault [UnconstrainedPOVM]: 8 params, indices=slice(4, 12, None)\n", ">>> Gxpi2:0 [InterpolatedDenseOp]: 1 params, indices=slice(12, 13, None)\n", ">>> Gypi2:0 [InterpolatedDenseOp]: 1 params, indices=slice(13, 14, None)\n" ] } ], "source": [ "model._print_gpindices()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "14\n" ] } ], "source": [ "# # Link the over-rotation errors on Gx and Gy\n", "# model['rho0'].set_gpindices(slice(0,4),model)\n", "# model['Mdefault'].set_gpindices(slice(4,12),model)\n", "# model['Gxpi2',0].set_gpindices(slice(12,13),model)\n", "# model['Gypi2',0].set_gpindices(slice(12,13),model)\n", "# model._rebuild_paramvec()\n", "# model._print_gpindices()\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": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OutcomeLabelDict([(('0',), 0.7440406663460976), (('1',), 0.2559593336539022)])" ] }, "execution_count": 17, "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": 18, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using greedy algorithm.\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", " Outer iteration: 1 of 2 amplified, 0 germs\n", " Inner iter over candidate germs [##################################################] 100.0% Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0)\n", " Added Gypi2:0@(0) to final germs (Score: major=-1.0 minor=0.8105694654717684, N: 1)\n", " Outer iteration: 1 of 2 amplified, 1 germs\n", " Inner iter over candidate germs [##################################################] 100.0% Gxpi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0Gypi2:0@(0)\n", " Added Gxpi2:0@(0) to final germs (Score: major=-2.0 minor=1.621138935590229, N: 2)\n", " Outer iteration: 2 of 2 amplified, 2 germs\n", "Constructed germ set:\n", "['Gypi2:0@(0)', 'Gxpi2:0@(0)']\n", "Score: Score: major=0.0 minor=inf, N: 0\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": 19, "metadata": {}, "outputs": [], "source": [ "fiducial_pairs = pygsti.algorithms.fiducialpairreduction.find_sufficient_fiducial_pairs_per_germ(\n", " model, \n", " smq1Q_XY.prep_fiducials([0]),\n", " smq1Q_XY.meas_fiducials([0]), \n", " final_germs)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{Circuit(Gypi2:0@(0)): [(0, 0), (0, 1)], Circuit(Gxpi2:0@(0)): [(0, 0), (0, 1)]}\n" ] } ], "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": 78, "metadata": {}, "outputs": [], "source": [ "working_dir = Path.cwd() / 'example_files'\n", "\n", "# get experiment design from smq1Q_XY\n", "# exp_design = smq1Q_XY.get_gst_experiment_design(max_max_length=32,qubit_labels=('Q0',)) \n", "\n", "# Use fiducial pair reductions\n", "exp_design = pygsti.protocols.StandardGSTDesign(model, \n", " smq1Q_XY.prep_fiducials([0]), \n", " smq1Q_XY.meas_fiducials([0]), \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", "# write an empty data object (creates a template to fill in)\n", "pygsti.io.write_empty_protocol_data(exp_design, working_dir, clobber_ok=True)\n", "\n", "# fill in the template with simulated data (you would run the experiment and use actual data)\n", "pygsti.io.fill_in_empty_dataset_with_fake_data(\n", " datagen_model,\n", " working_dir / 'data/dataset.txt', num_samples=1000, seed=1234)\n", "\n", "# load the data object back in, now with the experimental data\n", "data = pygsti.io.load_data_from_dir(working_dir)" ] }, { "cell_type": "code", "execution_count": 76, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "35" ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(data.dataset)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fisher information matrix" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What is the expected covariance in the estimated parameters given the specified experiment? Assuming the GST estimator is unbiased,\n", "\n", "$$ \\mathrm{cov}\\left(\\left\\langle \\vec \\theta \\right\\rangle\\right) \\le I(\\theta)^{-1}$$\n", "\n", "Where $I(\\vec\\theta)$ is the Fisher information matrix, with entries:\n", "\n", "$$ I_{m,n} = - \\left\\langle \\frac{\\partial^2}{\\partial \\theta_m \\partial \\theta_n} \\mathrm{log} f(x;\\vec\\theta) \\right\\rangle $$\n", "\n", "Here $f(x;\\vec\\theta)$ is the likelihood function. For a single quantum circuit, it is equal to:\n", "\n", "$$ f(x;\\vec\\theta) = \\prod_i p_i(\\theta)^{x_i} $$\n", "\n", "Where $p_i(theta)$ is the probability of measuring the $i$th possible outcome, and $x_i$ is the number of times that outcome was observed. The logarithmic derivatives can be evaluated as:\n", "\n", "$$\n", "\\begin{align}\n", "I_{m,n} &= - \\sum_i \\left\\langle x_i \\frac{\\partial^2}{\\partial \\theta_m \\partial \\theta_n} \\log p_i(\\vec\\theta)\\right\\rangle \\\\\n", " &= - \\sum_i \\left\\langle x_i \\frac{\\partial}{\\partial \\theta_m } \\frac{\\partial \\theta_n p_i(\\vec\\theta)}{p_i(\\vec\\theta)}\\right\\rangle \\\\\n", " &= - \\sum_i \\left\\langle x_i \\left(\\frac{\\partial\\theta_m \\partial \\theta_n p_i(\\vec\\theta)}{p_i(\\vec\\theta)} - \n", " \\frac{(\\partial\\theta_m p_i(\\vec\\theta) )(\\partial\\theta_n p_i(\\vec\\theta))}{p_i(\\vec\\theta)^2} \\right)\n", " \\right\\rangle \\\\\n", "I &= N \\sum_i \\left( \n", " \\frac{(\\nabla p_i(\\vec\\theta) )(\\nabla p_i(\\vec\\theta))^\\mathsf{T}}{p_i(\\vec\\theta)} -\n", " \\nabla\\nabla p_i(\\vec\\theta) \\right) \\vert_{\\theta = \\theta_0}\\\\\n", "&= N \\sum_i \\left( \n", " \\frac{J_i J_i^\\mathsf{T}}{p_i} - H_i \\right) \\vert_{\\theta = \\theta_0} \n", "\\end{align}\n", "$$\n", "\n" ] }, { "cell_type": "code", "execution_count": 88, "metadata": {}, "outputs": [], "source": [ "def fisher_information_matrix(model, circuit_list):\n", " n_params = model.num_params\n", " outcomes = model.sim.probs(()).keys()\n", " fisher_information = np.zeros([n_params, n_params])\n", " for circuit in circuit_list:\n", " p = model.sim.probs (circuit)\n", " j = model.sim.dprobs(circuit)\n", " h = model.sim.hprobs(circuit)\n", " for outcome in outcomes:\n", " fisher_information += np.outer(j[outcome], j[outcome])/p[outcome] - h[outcome] \n", " return fisher_information" ] }, { "cell_type": "code", "execution_count": 93, "metadata": {}, "outputs": [], "source": [ "fim = fisher_information_matrix(model, exp_design.all_circuits_needing_data[0:2])" ] }, { "cell_type": "code", "execution_count": 99, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ ":1: RuntimeWarning: invalid value encountered in log\n", " np.log(np.linalg.inv(fisher_information_matrix(model, exp_design.all_circuits_needing_data[0:6])))\n" ] }, { "data": { "text/plain": [ "array([[ -2.4849, nan, -35.1551, -2.4849, nan, nan, -34.3222, -35.3782, -34.5673, -34.6851, nan,\n", " -36.0714, nan, nan],\n", " [ nan, 1.3541, nan, 0.9474, 1.3862, 0.7837, nan, nan, nan, nan, 0.5966,\n", " 1.8351, 1.1788, 1.7805],\n", " [-35.2635, nan, -0.1295, nan, nan, nan, -0.9581, 1.0328, 0.5676, 0.3140, nan,\n", " nan, nan, nan],\n", " [ -2.4849, 0.9474, nan, 0.5923, 1.0365, 0.5696, nan, nan, nan, nan, 0.0500,\n", " 1.4359, 0.8999, 1.3422],\n", " [ nan, 1.3862, nan, 1.0365, 1.9922, 1.6898, nan, nan, nan, nan, 1.4629,\n", " 2.0662, 1.3962, 1.7764],\n", " [ nan, 0.7837, nan, 0.5696, 1.6898, 1.5024, nan, nan, nan, nan, 1.1590,\n", " 1.6392, 1.1709, 1.1678],\n", " [-34.8032, nan, -0.9581, nan, nan, nan, 1.3086, 1.4033, 1.5180, 1.2039, nan,\n", " nan, nan, nan],\n", " [-33.8549, nan, 1.0328, nan, nan, nan, 1.4033, 2.4262, 2.0509, 1.6648, nan,\n", " nan, nan, nan],\n", " [-34.1413, nan, 0.5676, nan, nan, nan, 1.5180, 2.0509, 1.9922, 1.7073, nan,\n", " nan, nan, nan],\n", " [-34.4705, nan, 0.3140, nan, nan, nan, 1.2039, 1.6648, 1.7073, 1.5759, nan,\n", " nan, nan, nan],\n", " [ nan, 0.5966, nan, 0.0500, 1.4629, 1.1590, nan, nan, nan, nan, 1.3967,\n", " 1.2242, -0.6442, 1.0996],\n", " [ nan, 1.8351, nan, 1.4359, 2.0662, 1.6392, nan, nan, nan, nan, 1.2242,\n", " 2.4309, 1.8259, 2.2329],\n", " [ nan, 1.1788, nan, 0.8999, 1.3962, 1.1709, nan, nan, nan, nan, -0.6442,\n", " 1.8259, 1.7238, 1.4482],\n", " [ nan, 1.7805, nan, 1.3422, 1.7764, 1.1678, nan, nan, nan, nan, 1.0996,\n", " 2.2329, 1.4482, 2.2118]])" ] }, "execution_count": 99, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.log(np.linalg.inv(fisher_information_matrix(model, exp_design.all_circuits_needing_data[0:6])))" ] }, { "cell_type": "code", "execution_count": 94, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([ 2.5000e-01+0.0000e+00j, -3.9005e+15+1.1457e+15j, -3.9005e+15-1.1457e+15j, 5.3603e+14+0.0000e+00j,\n", " 1.4888e+14+0.0000e+00j, 2.8210e+00+0.0000e+00j, 1.1441e+00+0.0000e+00j, -4.9274e-01+0.0000e+00j,\n", " -3.7677e-01+4.9547e-02j, -3.7677e-01-4.9547e-02j, 4.3818e-01+1.0126e-01j, 4.3818e-01-1.0126e-01j,\n", " 2.4698e-01+3.9999e-02j, 2.4698e-01-3.9999e-02j]),\n", " array([[ 1.0000e+00+0.0000e+00j, 2.6254e-17-2.8793e-17j, 2.6254e-17+2.8793e-17j, -1.5293e-16+0.0000e+00j,\n", " 7.8796e-18+0.0000e+00j, -6.6313e-02+0.0000e+00j, -2.5171e-01+0.0000e+00j, 1.6226e-01+0.0000e+00j,\n", " 1.6653e-02-1.2934e-01j, 1.6653e-02+1.2934e-01j, 4.6007e-01+0.0000e+00j, 4.6007e-01-0.0000e+00j,\n", " 9.1612e-01+0.0000e+00j, 9.1612e-01-0.0000e+00j],\n", " [ 0.0000e+00+0.0000e+00j, 5.4595e-03-1.4286e-03j, 5.4595e-03+1.4286e-03j, 6.0662e-02+0.0000e+00j,\n", " -4.8244e-01+0.0000e+00j, -2.5079e-02+0.0000e+00j, -1.3608e-01+0.0000e+00j, 1.1794e-01+0.0000e+00j,\n", " 3.1224e-01+5.5154e-02j, 3.1224e-01-5.5154e-02j, 8.4144e-03-4.1106e-01j, 8.4144e-03+4.1106e-01j,\n", " -1.8597e-03-9.5862e-02j, -1.8597e-03+9.5862e-02j],\n", " [ 0.0000e+00+0.0000e+00j, 1.0742e-03-7.1716e-04j, 1.0742e-03+7.1716e-04j, -1.7696e-01+0.0000e+00j,\n", " -9.1593e-03+0.0000e+00j, 4.9275e-02+0.0000e+00j, 4.0996e-02+0.0000e+00j, 6.1700e-01+0.0000e+00j,\n", " 5.1216e-01+0.0000e+00j, 5.1216e-01-0.0000e+00j, 1.4029e-01+1.2222e-01j, 1.4029e-01-1.2222e-01j,\n", " -2.7354e-02-1.4018e-01j, -2.7354e-02+1.4018e-01j],\n", " [ 0.0000e+00+0.0000e+00j, -3.2515e-04+2.1709e-04j, -3.2515e-04-2.1709e-04j, 5.3565e-02+0.0000e+00j,\n", " 2.7725e-03+0.0000e+00j, -7.3487e-02+0.0000e+00j, -8.0255e-01+0.0000e+00j, -3.2937e-02+0.0000e+00j,\n", " 1.0429e-02+7.7806e-02j, 1.0429e-02-7.7806e-02j, -1.9685e-01+1.2352e-01j, -1.9685e-01-1.2352e-01j,\n", " -8.9057e-02-3.9972e-02j, -8.9057e-02+3.9972e-02j],\n", " [ 0.0000e+00+0.0000e+00j, 5.6111e-02+8.2978e-02j, 5.6111e-02-8.2978e-02j, -1.4039e-02+0.0000e+00j,\n", " 8.0565e-03+0.0000e+00j, -8.6914e-04+0.0000e+00j, -2.5048e-01+0.0000e+00j, 1.3138e-01+0.0000e+00j,\n", " -2.0173e-02-1.0589e-01j, -2.0173e-02+1.0589e-01j, 2.3022e-01-2.4351e-01j, 2.3022e-01+2.4351e-01j,\n", " 6.5127e-02+9.2371e-02j, 6.5127e-02-9.2371e-02j],\n", " [ 0.0000e+00+0.0000e+00j, 5.0706e-01+0.0000e+00j, 5.0706e-01-0.0000e+00j, -2.3587e-02+0.0000e+00j,\n", " 2.1322e-02+0.0000e+00j, -3.4552e-02+0.0000e+00j, -1.7008e-01+0.0000e+00j, 4.6777e-02+0.0000e+00j,\n", " 2.4101e-01+4.4141e-02j, 2.4101e-01-4.4141e-02j, -1.5430e-01+2.5313e-01j, -1.5430e-01-2.5313e-01j,\n", " 2.2442e-02+6.9485e-03j, 2.2442e-02-6.9485e-03j],\n", " [ 0.0000e+00+0.0000e+00j, 1.8158e-01-4.9221e-02j, 1.8158e-01+4.9221e-02j, 2.4866e-01+0.0000e+00j,\n", " 1.7203e-02+0.0000e+00j, 3.9975e-01+0.0000e+00j, 8.7746e-02+0.0000e+00j, 5.8934e-01+0.0000e+00j,\n", " 4.2298e-01-3.5674e-02j, 4.2298e-01+3.5674e-02j, -1.6961e-02-1.1032e-01j, -1.6961e-02+1.1032e-01j,\n", " 3.4126e-02+1.1343e-01j, 3.4126e-02-1.1343e-01j],\n", " [ 0.0000e+00+0.0000e+00j, 4.2836e-01-1.1778e-01j, 4.2836e-01+1.1778e-01j, -1.1086e-01+0.0000e+00j,\n", " 4.3833e-03+0.0000e+00j, -2.1374e-01+0.0000e+00j, 1.5286e-01+0.0000e+00j, -1.8174e-01+0.0000e+00j,\n", " 9.9550e-02+2.0668e-01j, 9.9550e-02-2.0668e-01j, 2.7644e-01+1.4411e-01j, 2.7644e-01-1.4411e-01j,\n", " 6.1154e-03+1.2143e-01j, 6.1154e-03-1.2143e-01j],\n", " [ 0.0000e+00+0.0000e+00j, -5.6111e-02-8.2978e-02j, -5.6111e-02+8.2978e-02j, 1.4039e-02+0.0000e+00j,\n", " -8.0565e-03+0.0000e+00j, -2.5264e-02+0.0000e+00j, -3.4056e-01+0.0000e+00j, -2.0239e-02+0.0000e+00j,\n", " 1.0205e-01+5.2742e-02j, 1.0205e-01-5.2742e-02j, -3.7080e-02-2.3843e-01j, -3.7080e-02+2.3843e-01j,\n", " 2.0292e-01+2.3261e-02j, 2.0292e-01-2.3261e-02j],\n", " [ 0.0000e+00+0.0000e+00j, -5.0706e-01-7.6328e-17j, -5.0706e-01+7.6328e-17j, 2.3587e-02+0.0000e+00j,\n", " -2.1322e-02+0.0000e+00j, -1.7302e-02+0.0000e+00j, -1.0638e-01+0.0000e+00j, 1.5399e-01+0.0000e+00j,\n", " 1.5459e-01-6.8028e-02j, 1.5459e-01+6.8028e-02j, 3.4715e-02+2.4953e-01j, 3.4715e-02-2.4953e-01j,\n", " -7.4991e-02+5.5816e-02j, -7.4991e-02-5.5816e-02j],\n", " [ 0.0000e+00+0.0000e+00j, -1.8158e-01+4.9221e-02j, -1.8158e-01-4.9221e-02j, -2.4866e-01+0.0000e+00j,\n", " -1.7203e-02+0.0000e+00j, -7.5957e-01+0.0000e+00j, 3.0804e-02+0.0000e+00j, 3.3859e-01+0.0000e+00j,\n", " 3.0128e-01+1.5700e-02j, 3.0128e-01-1.5700e-02j, -5.3246e-02-9.5386e-02j, -5.3246e-02+9.5386e-02j,\n", " 4.8362e-02+7.5766e-02j, 4.8362e-02-7.5766e-02j],\n", " [ 0.0000e+00+0.0000e+00j, -4.2836e-01+1.1778e-01j, -4.2836e-01-1.1778e-01j, 1.1086e-01+0.0000e+00j,\n", " -4.3833e-03+0.0000e+00j, 2.6530e-01+0.0000e+00j, 1.1354e-01+0.0000e+00j, -1.8161e-01+0.0000e+00j,\n", " 2.3807e-01+2.9685e-01j, 2.3807e-01-2.9685e-01j, 1.0296e-01+1.4131e-01j, 1.0296e-01-1.4131e-01j,\n", " 9.7454e-02+8.8680e-02j, 9.7454e-02-8.8680e-02j],\n", " [ 0.0000e+00+0.0000e+00j, -5.4706e-03+3.6525e-03j, -5.4706e-03-3.6525e-03j, 9.0124e-01+0.0000e+00j,\n", " 4.6648e-02+0.0000e+00j, -3.6333e-01+0.0000e+00j, 5.2699e-02+0.0000e+00j, 4.6452e-02+0.0000e+00j,\n", " 3.1126e-02-4.3564e-03j, 3.1126e-02+4.3564e-03j, 4.9290e-02+4.5567e-02j, 4.9290e-02-4.5567e-02j,\n", " -6.8719e-03-2.6016e-02j, -6.8719e-03+2.6016e-02j],\n", " [ 0.0000e+00+0.0000e+00j, 1.0416e-02-2.9633e-03j, 1.0416e-02+2.9633e-03j, 1.2778e-02+0.0000e+00j,\n", " -8.7368e-01+0.0000e+00j, 1.3928e-02+0.0000e+00j, 7.5572e-02+0.0000e+00j, -6.5498e-02+0.0000e+00j,\n", " -1.7340e-01-3.0630e-02j, -1.7340e-01+3.0630e-02j, -4.6730e-03+2.2828e-01j, -4.6730e-03-2.2828e-01j,\n", " 1.0328e-03+5.3238e-02j, 1.0328e-03-5.3238e-02j]]))" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.linalg.eig(np.linalg.inv(fim))" ] }, { "cell_type": "code", "execution_count": 90, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" }, { "data": { "image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
" ] }, "metadata": { "needs_background": "light" }, "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": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Iterative GST: Iter 1 of 9 4 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.0112986 (4 data params - 14 (approx) model params = expected mean of -10; p-value = nan)\n", " Completed in 0.1s\n", " Iteration 1 took 0.1s\n", " \n", "--- Iterative GST: Iter 2 of 9 7 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.241037 (7 data params - 14 (approx) model params = expected mean of -7; p-value = nan)\n", " Completed in 0.0s\n", " Iteration 2 took 0.1s\n", " \n", "--- Iterative GST: Iter 3 of 9 11 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 = 1.31238 (11 data params - 14 (approx) model params = expected mean of -3; p-value = nan)\n", " Completed in 0.4s\n", " Iteration 3 took 0.4s\n", " \n", "--- Iterative GST: Iter 4 of 9 15 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 = 9.93515 (15 data params - 14 (approx) model params = expected mean of 1; p-value = 0.00162152)\n", " Completed in 0.4s\n", " Iteration 4 took 0.4s\n", " \n", "--- Iterative GST: Iter 5 of 9 19 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 = 12.6447 (19 data params - 14 (approx) model params = expected mean of 5; p-value = 0.0269459)\n", " Completed in 0.2s\n", " Iteration 5 took 0.2s\n", " \n", "--- Iterative GST: Iter 6 of 9 23 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 = 14.7439 (23 data params - 14 (approx) model params = expected mean of 9; p-value = 0.0982157)\n", " Completed in 0.2s\n", " Iteration 6 took 0.2s\n", " \n", "--- Iterative GST: Iter 7 of 9 27 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 = 14.9305 (27 data params - 14 (approx) model params = expected mean of 13; p-value = 0.311713)\n", " Completed in 0.2s\n", " Iteration 7 took 0.2s\n", " \n", "--- Iterative GST: Iter 8 of 9 31 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 = 18.7044 (31 data params - 14 (approx) model params = expected mean of 17; p-value = 0.345761)\n", " Completed in 0.2s\n", " Iteration 8 took 0.2s\n", " \n", "--- Iterative GST: Iter 9 of 9 35 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.3196 (35 data params - 14 (approx) model params = expected mean of 21; p-value = 0.381298)\n", " Completed in 0.2s\n", " Iteration 9 took 0.3s\n", " \n", " Last iteration:\n", " --- dlogl GST ---\n", " 2*Delta(log(L)) = 22.9198 (35 data params - 14 (approx) model params = expected mean of 21; p-value = 0.348267)\n", " Completed in 0.4s\n", " Final optimization took 0.4s\n", " \n", "Iterative GST Total Time: 2.5s\n" ] } ], "source": [ "proto = pygsti.protocols.GateSetTomography(target_model)\n", "results = proto.run(data)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Actual: [1.03 1.00]\n", "Estimated: [1.0304 1.0000]\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": 32, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "array([ 1.0001, -0.0730, -0.0239, 0.9976])\n", "array([ 1.0064, -0.0219, -0.0209, 1.0079])\n", "array([ 0.9969, 0.0461, 0.0113, -0.9958])\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 (jaqal)", "language": "python", "name": "jaqal" }, "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.8.6" } }, "nbformat": 4, "nbformat_minor": 4 }