Robust Phase Estimation (RPE) Tutorial

This notebook demonstrates how to use Robust Phase Estimation (RPE) to estimate certain parameters of a standard single-qubit gate set. The RPE protocol is contained within the extras package of pyGSTi.

In [1]:
#Import relevant namespaces.
from __future__ import print_function

import pygsti
import pygsti.construction.std1Q_XY as Std1Q_XY
from pygsti.extras import rpe

import numpy as np
Fully specified RPE configuration.
In [2]:
#Declare the particular RPE instance we are interested in
#(X and Y pi/2 rotations)
rpeconfig_inst = rpe.rpeconfig_GxPi2_GyPi2_UpDn
In [3]:
#Declare a variety of relevant parameters

gs_target = Std1Q_XY.gs_target
gs_target.set_all_parameterizations('TP')
maxLengths_1024 = [0,1,2,4,8,16,32,64,128,256,512,1024]

stringListsRPE = rpe.rpeconstruction.make_rpe_angle_string_list_dict(10,rpeconfig_inst)

angleList = ['alpha','epsilon','theta']

numStrsD = {}
numStrsD['RPE'] = [6*i for i in np.arange(1,12)]
In [4]:
#Create noisy gateset
gs_real = gs_target.randomize_with_unitary(.01,seed=0)
In [5]:
#Extract noisy gateset angles
true_alpha = rpe.extract_alpha(gs_real,rpeconfig_inst)
true_epsilon = rpe.extract_epsilon(gs_real,rpeconfig_inst)
true_theta = rpe.extract_theta(gs_real,rpeconfig_inst)
In [6]:
#Simulate dataset
N=100
DS = pygsti.construction.generate_fake_data(gs_real,stringListsRPE['totalStrList'],N,sampleError='binomial',seed=1)
In [7]:
#Analyze dataset
resultsRPE = rpe.analyze_rpe_data(DS,gs_real,stringListsRPE,rpeconfig_inst)
In [8]:
#Print results
print('alpha_true - pi/2 =',true_alpha-np.pi/2)
print('epsilon_true - pi/2 =',true_epsilon-np.pi/2)
print('theta_true =',true_theta)
print()
print('alpha_true - alpha_est_final =',resultsRPE['alphaErrorList'][-1])
print('epsilon_true - epsilon_est_final =',resultsRPE['epsilonErrorList'][-1])
print('theta_true - theta_est_final =',resultsRPE['thetaErrorList'][-1])
alpha_true - pi/2 = 0.0279649415513
epsilon_true - pi/2 = 0.00671591123378
theta_true = 0.0233041210479

alpha_true - alpha_est_final = 1.83008894992e-05
epsilon_true - epsilon_est_final = 6.16866596674e-05
theta_true - theta_est_final = 0.0120789343601