From 627ec20ac5c05d4eede08a41364e80c390721da7 Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Tue, 16 Jul 2024 14:59:06 -0600 Subject: [PATCH 1/9] povm convert fixed for fullTP->GLND, missing CPTPLND considerations --- pygsti/modelmembers/povms/__init__.py | 45 ++++++++++++++++++++++++-- pygsti/modelmembers/states/__init__.py | 4 +-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/pygsti/modelmembers/povms/__init__.py b/pygsti/modelmembers/povms/__init__.py index e946abd51..9ac030bb3 100644 --- a/pygsti/modelmembers/povms/__init__.py +++ b/pygsti/modelmembers/povms/__init__.py @@ -14,6 +14,8 @@ import itertools as _itertools import numpy as _np +import scipy.linalg as _spl +import scipy.optimize as _spo from .complementeffect import ComplementPOVMEffect from .composedeffect import ComposedPOVMEffect @@ -334,6 +336,8 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): The converted POVM vector, usually a distinct object from the object passed as input. """ + + ##TEST CONVERSION BETWEEN LINBLAD TYPES to_types = to_type if isinstance(to_type, (tuple, list)) else (to_type,) # HACK to support multiple to_type values error_msgs = {} @@ -375,14 +379,49 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): for lbl, vec in povm.items()] else: raise RuntimeError('Evotype must be compatible with Hilbert ops to use pure effects') - except Exception: # try static mixed states next: - base_items = [(lbl, convert_effect(vec, 'static', basis, idl.get(lbl, None), flatten_structure)) - for lbl, vec in povm.items()] + except RuntimeError: # try static mixed states next: + #if idl.get(lbl,None) is not None: + base_items = [] + for lbl, vec in povm.items(): + ideal_effect = idl.get(lbl,None) + if ideal_effect is not None: + base_items.append((lbl, convert_effect(ideal_effect, 'static', basis, ideal_effect, flatten_structure))) + else: + base_items.append((lbl, convert_effect(vec, 'static', basis, idl.get(lbl, None), flatten_structure))) base_povm = UnconstrainedPOVM(base_items, povm.evotype, povm.state_space) proj_basis = 'PP' if povm.state_space.is_entirely_qubits else basis errorgen = _LindbladErrorgen.from_error_generator(povm.state_space.dim, lndtype, proj_basis, basis, truncate=True, evotype=povm.evotype) + + #Need to set errorgen so exp(errorgen)|st> == |state> + base_dense_effects = [] + for item in base_items: + dense_effect = item[1].to_dense() + base_dense_effects.append(dense_effect.reshape((1,len(dense_effect)))) + + dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) + + dense_effects = [] + for effect in povm.values(): + dense_effect = effect.to_dense() + dense_effects.append(dense_effect.reshape((1,len(dense_effect)))) + + dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) + dense_povm = _np.concatenate(dense_effects, axis=0) + + def _objfn(v): + errorgen.from_vector(v) + return _np.linalg.norm(dense_povm - dense_ideal_povm @ _spl.expm(errorgen.to_dense())) + + #def callback(x): print("callbk: ",_np.linalg.norm(x),_objfn(x)) # REMOVE + soln = _spo.minimize(_objfn, _np.zeros(errorgen.num_params, 'd'), method="Nelder-Mead", options={}, + tol=1e-12) # , callback=callback) + #print("DEBUG: opt done: ",soln.success, soln.fun, soln.x) # REMOVE + if not soln.success and soln.fun > 1e-6: # not "or" because success is often not set correctly + raise ValueError("Failed to find an errorgen such that exp(errorgen)|ideal> = |state>") + errorgen.from_vector(soln.x) + EffectiveExpErrorgen = _IdentityPlusErrorgenOp if lndtype.meta == '1+' else _ExpErrorgenOp return ComposedPOVM(EffectiveExpErrorgen(errorgen), base_povm, mx_basis=basis) diff --git a/pygsti/modelmembers/states/__init__.py b/pygsti/modelmembers/states/__init__.py index f1cd5602c..b2e5c0b9d 100644 --- a/pygsti/modelmembers/states/__init__.py +++ b/pygsti/modelmembers/states/__init__.py @@ -266,8 +266,8 @@ def _objfn(v): errorgen.from_vector(v) return _np.linalg.norm(_spl.expm(errorgen.to_dense()) @ dense_st - dense_state) #def callback(x): print("callbk: ",_np.linalg.norm(x),_objfn(x)) # REMOVE - soln = _spo.minimize(_objfn, _np.zeros(errorgen.num_params, 'd'), method="CG", options={}, - tol=1e-8) # , callback=callback) + soln = _spo.minimize(_objfn, _np.zeros(errorgen.num_params, 'd'), method="Nelder-Mead", options={}, + tol=1e-12) # , callback=callback) #print("DEBUG: opt done: ",soln.success, soln.fun, soln.x) # REMOVE if not soln.success and soln.fun > 1e-6: # not "or" because success is often not set correctly raise ValueError("Failed to find an errorgen such that exp(errorgen)|ideal> = |state>") From 484fe3e8c361d8412f895bef2af58fbaecbdea8a Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Thu, 8 Aug 2024 15:22:29 -0600 Subject: [PATCH 2/9] full TP -> GLND reparam now avoids dumb-gauge, minimizes 2norm --- pygsti/modelmembers/povms/__init__.py | 40 ++++++++++++++++++++++---- pygsti/modelmembers/states/__init__.py | 31 +++++++++++++++++--- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/pygsti/modelmembers/povms/__init__.py b/pygsti/modelmembers/povms/__init__.py index 9ac030bb3..1c92ca673 100644 --- a/pygsti/modelmembers/povms/__init__.py +++ b/pygsti/modelmembers/povms/__init__.py @@ -409,18 +409,48 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) dense_povm = _np.concatenate(dense_effects, axis=0) + + def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): + + errgen = _LindbladErrorgen.from_error_generator(4, parameterization="GLND") + exp_errgen = _ExpErrorgenOp(errgen) + ideal_vec = _np.zeros(12) + J = _np.zeros((dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1],12)) + + for i in range(len(ideal_vec)): + new_vec = ideal_vec.copy() + new_vec[i] = epsilon + exp_errgen.from_vector(new_vec) + vectorized_povm = _np.zeros(dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1]) + perturbed_povm = (dense_ideal_povm @ exp_errgen.to_dense() - dense_ideal_povm)/epsilon + + perturbed_povm_t = perturbed_povm.transpose() + for j, column in enumerate(perturbed_povm_t): + vectorized_povm[j*len(perturbed_povm_t[0]):(j+1)*len(perturbed_povm_t[0])] = column + + J[:,i] = vectorized_povm.transpose() + + _,S,V = _np.linalg.svd(J) + return V[:len(S),] + + phys_directions = calc_physical_subspace(dense_ideal_povm) + def _objfn(v): - errorgen.from_vector(v) + L_vec = _np.zeros(len(phys_directions[0])) + for coeff, phys_direction in zip(v,phys_directions): + L_vec += coeff * phys_direction + errorgen.from_vector(L_vec) return _np.linalg.norm(dense_povm - dense_ideal_povm @ _spl.expm(errorgen.to_dense())) #def callback(x): print("callbk: ",_np.linalg.norm(x),_objfn(x)) # REMOVE - soln = _spo.minimize(_objfn, _np.zeros(errorgen.num_params, 'd'), method="Nelder-Mead", options={}, - tol=1e-12) # , callback=callback) + soln = _spo.minimize(_objfn, _np.zeros(len(phys_directions), 'd'), method="Nelder-Mead", options={}, + tol=1e-13) # , callback=callback) #print("DEBUG: opt done: ",soln.success, soln.fun, soln.x) # REMOVE if not soln.success and soln.fun > 1e-6: # not "or" because success is often not set correctly - raise ValueError("Failed to find an errorgen such that exp(errorgen)|ideal> = |state>") - errorgen.from_vector(soln.x) + raise ValueError("Failed to find an errorgen such that 1e-6: # not "or" because success is often not set correctly raise ValueError("Failed to find an errorgen such that exp(errorgen)|ideal> = |state>") - errorgen.from_vector(soln.x) + + errgen_vec = _np.linalg.pinv(phys_directions) @ soln.x + errorgen.from_vector(errgen_vec) EffectiveExpErrorgen = _IdentityPlusErrorgenOp if lndtype.meta == '1+' else _ExpErrorgenOp return ComposedState(st, EffectiveExpErrorgen(errorgen)) From 6365db895dec6c2166f333994bb5815a5c79e3cb Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Fri, 16 Aug 2024 15:21:20 -0600 Subject: [PATCH 3/9] bypass our changes if reparam is not full TP -> GLND --- pygsti/modelmembers/povms/__init__.py | 115 +++++++++++++------------- pygsti/models/modelparaminterposer.py | 2 +- 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/pygsti/modelmembers/povms/__init__.py b/pygsti/modelmembers/povms/__init__.py index 1c92ca673..658b97ef7 100644 --- a/pygsti/modelmembers/povms/__init__.py +++ b/pygsti/modelmembers/povms/__init__.py @@ -381,6 +381,7 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): raise RuntimeError('Evotype must be compatible with Hilbert ops to use pure effects') except RuntimeError: # try static mixed states next: #if idl.get(lbl,None) is not None: + base_items = [] for lbl, vec in povm.items(): ideal_effect = idl.get(lbl,None) @@ -393,64 +394,64 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): proj_basis = 'PP' if povm.state_space.is_entirely_qubits else basis errorgen = _LindbladErrorgen.from_error_generator(povm.state_space.dim, lndtype, proj_basis, basis, truncate=True, evotype=povm.evotype) - - #Need to set errorgen so exp(errorgen)|st> == |state> - base_dense_effects = [] - for item in base_items: - dense_effect = item[1].to_dense() - base_dense_effects.append(dense_effect.reshape((1,len(dense_effect)))) - - dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) - - dense_effects = [] - for effect in povm.values(): - dense_effect = effect.to_dense() - dense_effects.append(dense_effect.reshape((1,len(dense_effect)))) - - dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) - dense_povm = _np.concatenate(dense_effects, axis=0) - - def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): - - errgen = _LindbladErrorgen.from_error_generator(4, parameterization="GLND") - exp_errgen = _ExpErrorgenOp(errgen) - ideal_vec = _np.zeros(12) - J = _np.zeros((dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1],12)) - - for i in range(len(ideal_vec)): - new_vec = ideal_vec.copy() - new_vec[i] = epsilon - exp_errgen.from_vector(new_vec) - vectorized_povm = _np.zeros(dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1]) - perturbed_povm = (dense_ideal_povm @ exp_errgen.to_dense() - dense_ideal_povm)/epsilon - - perturbed_povm_t = perturbed_povm.transpose() - for j, column in enumerate(perturbed_povm_t): - vectorized_povm[j*len(perturbed_povm_t[0]):(j+1)*len(perturbed_povm_t[0])] = column + if to_type == 'GLND' and isinstance(povm, destination_types.get('full TP', NoneType)): + #Need to set errorgen so exp(errorgen)|st> == |state> + base_dense_effects = [] + for item in base_items: + dense_effect = item[1].to_dense() + base_dense_effects.append(dense_effect.reshape((1,len(dense_effect)))) + + dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) + + dense_effects = [] + for effect in povm.values(): + dense_effect = effect.to_dense() + dense_effects.append(dense_effect.reshape((1,len(dense_effect)))) + + dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) + dense_povm = _np.concatenate(dense_effects, axis=0) + + def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): + + errgen = _LindbladErrorgen.from_error_generator(4, parameterization="GLND") + exp_errgen = _ExpErrorgenOp(errgen) + ideal_vec = _np.zeros(12) + J = _np.zeros((dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1],12)) - J[:,i] = vectorized_povm.transpose() - - _,S,V = _np.linalg.svd(J) - return V[:len(S),] - - phys_directions = calc_physical_subspace(dense_ideal_povm) - - - def _objfn(v): - L_vec = _np.zeros(len(phys_directions[0])) - for coeff, phys_direction in zip(v,phys_directions): - L_vec += coeff * phys_direction - errorgen.from_vector(L_vec) - return _np.linalg.norm(dense_povm - dense_ideal_povm @ _spl.expm(errorgen.to_dense())) - - #def callback(x): print("callbk: ",_np.linalg.norm(x),_objfn(x)) # REMOVE - soln = _spo.minimize(_objfn, _np.zeros(len(phys_directions), 'd'), method="Nelder-Mead", options={}, - tol=1e-13) # , callback=callback) - #print("DEBUG: opt done: ",soln.success, soln.fun, soln.x) # REMOVE - if not soln.success and soln.fun > 1e-6: # not "or" because success is often not set correctly - raise ValueError("Failed to find an errorgen such that 1e-6: # not "or" because success is often not set correctly + raise ValueError("Failed to find an errorgen such that Date: Thu, 22 Aug 2024 11:13:55 -0600 Subject: [PATCH 4/9] removed magic numbers, adapted for arbitrary number of qubits --- pygsti/modelmembers/states/__init__.py | 9 +- .../badfit_options.json | 18 + .../gaugeopt_suite.json | 10 + .../meta.json | 1 + .../target_model.json | 1206 +++++++++++++++++ 5 files changed, 1240 insertions(+), 4 deletions(-) create mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json create mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json create mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json create mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json diff --git a/pygsti/modelmembers/states/__init__.py b/pygsti/modelmembers/states/__init__.py index 15d682b7f..e3b41f6db 100644 --- a/pygsti/modelmembers/states/__init__.py +++ b/pygsti/modelmembers/states/__init__.py @@ -261,13 +261,14 @@ def convert(state, to_type, basis, ideal_state=None, flatten_structure=False): #Need to set errorgen so exp(errorgen)|st> == |state> dense_st = st.to_dense() dense_state = state.to_dense() - + num_qubits = st.state_space.num_qubits + num_errgens = 2**(4*num_qubits)-2**(2*num_qubits) def calc_physical_subspace(ideal_prep, epsilon = 1e-9): - errgen = _LindbladErrorgen.from_error_generator(4, parameterization="GLND") + errgen = _LindbladErrorgen.from_error_generator(2**(2*num_qubits), parameterization="GLND") exp_errgen = _ExpErrorgenOp(errgen) - ideal_vec = _np.zeros(12) - J = _np.zeros((3,12)) + ideal_vec = _np.zeros(num_errgens) + J = _np.zeros((state.num_params, num_errgens)) for i in range(len(ideal_vec)): new_vec = ideal_vec.copy() diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json new file mode 100644 index 000000000..882900f74 --- /dev/null +++ b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json @@ -0,0 +1,18 @@ +{ + "module": "pygsti.protocols.gst", + "class": "GSTBadFitOptions", + "version": 0, + "threshold": 2.0, + "actions": [], + "wildcard": { + "budget_includes_spam": true, + "L1_weights": null, + "primitive_op_labels": null, + "initial_budget": null, + "methods": [ + "neldermead" + ], + "indadmissable_action": "print", + "1d_reference": "diamond distance" + } +} \ No newline at end of file diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json new file mode 100644 index 000000000..242d98153 --- /dev/null +++ b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json @@ -0,0 +1,10 @@ +{ + "module": "pygsti.protocols.gst", + "class": "GSTGaugeOptSuite", + "version": 0, + "gaugeopt_suite_names": [ + "stdgaugeopt" + ], + "gaugeopt_argument_dicts": {}, + "gaugeopt_target": null +} \ No newline at end of file diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json new file mode 100644 index 000000000..707ecc89e --- /dev/null +++ b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json @@ -0,0 +1 @@ +{"type": "pygsti.protocols.gst.LinearGateSetTomography", "auxfile_types": {"target_model": "serialized-object", "gaugeopt_suite": "serialized-object", "badfit_options": "serialized-object"}, "name": "testGST", "tags": {}, "_nameddict_attributes": [], "verbosity": 2, "profile": 1, "record_output": true, "oplabels": "default", "oplabel_aliases": null, "unreliable_ops": ["Gcnot", "Gcphase", "Gms", "Gcn", "Gcx", "Gcz"]} \ No newline at end of file diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json new file mode 100644 index 000000000..3334f7276 --- /dev/null +++ b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json @@ -0,0 +1,1206 @@ +{ + "module": "pygsti.models.explicitmodel", + "class": "ExplicitOpModel", + "version": 0, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "parameter_labels": [ + [ + "rho0", + "VecElement Re(0)" + ], + [ + "rho0", + "VecElement Re(1)" + ], + [ + "rho0", + "VecElement Re(2)" + ], + [ + "rho0", + "VecElement Re(3)" + ], + [ + "Mdefault", + "VecElement Re(0)" + ], + [ + "Mdefault", + "VecElement Re(1)" + ], + [ + "Mdefault", + "VecElement Re(2)" + ], + [ + "Mdefault", + "VecElement Re(3)" + ], + [ + "Mdefault", + "VecElement Re(0)" + ], + [ + "Mdefault", + "VecElement Re(1)" + ], + [ + "Mdefault", + "VecElement Re(2)" + ], + [ + "Mdefault", + "VecElement Re(3)" + ], + [ + [], + "MxElement 0,0" + ], + [ + [], + "MxElement 0,1" + ], + [ + [], + "MxElement 0,2" + ], + [ + [], + "MxElement 0,3" + ], + [ + [], + "MxElement 1,0" + ], + [ + [], + "MxElement 1,1" + ], + [ + [], + "MxElement 1,2" + ], + [ + [], + "MxElement 1,3" + ], + [ + [], + "MxElement 2,0" + ], + [ + [], + "MxElement 2,1" + ], + [ + [], + "MxElement 2,2" + ], + [ + [], + "MxElement 2,3" + ], + [ + [], + "MxElement 3,0" + ], + [ + [], + "MxElement 3,1" + ], + [ + [], + "MxElement 3,2" + ], + [ + [], + "MxElement 3,3" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 0,0" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 0,1" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 0,2" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 0,3" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 1,0" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 1,1" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 1,2" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 1,3" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 2,0" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 2,1" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 2,2" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 2,3" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 3,0" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 3,1" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 3,2" + ], + [ + [ + "Gxpi2", + 0 + ], + "MxElement 3,3" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 0,0" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 0,1" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 0,2" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 0,3" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 1,0" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 1,1" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 1,2" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 1,3" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 2,0" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 2,1" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 2,2" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 2,3" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 3,0" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 3,1" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 3,2" + ], + [ + [ + "Gypi2", + 0 + ], + "MxElement 3,3" + ] + ], + "parameter_bounds": null, + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + }, + "default_gate_type": "full", + "default_prep_type": [ + "full" + ], + "default_povm_type": [ + "full" + ], + "default_instrument_type": [ + "full" + ], + "prep_prefix": "rho", + "effect_prefix": "E", + "gate_prefix": "G", + "povm_prefix": "M", + "instrument_prefix": "I", + "evotype": "densitymx", + "simulator": { + "module": "pygsti.forwardsims.matrixforwardsim", + "class": "MatrixForwardSimulator", + "version": 0, + "mode": "time_independent" + }, + "default_gauge_group": { + "module": "pygsti.models.gaugegroup", + "class": "FullGaugeGroup", + "version": 0, + "state_space_dimension": 4, + "evotype": "densitymx", + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + } + }, + "parameter_interposer": null, + "modelmembers": { + "0": { + "module": "pygsti.modelmembers.states.fullstate", + "class": "FullState", + "submembers": [], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 0, + 1, + 2, + 3 + ], + "relative_submember_parameter_indices": [], + "parameter_labels": [ + "VecElement Re(0)", + "VecElement Re(1)", + "VecElement Re(2)", + "VecElement Re(3)" + ], + "parameter_bounds": null, + "dense_superket_vector": [ + 0.7071067811865476, + 0.0, + 0.0, + 0.7071067811865476 + ], + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + }, + "memberdict_types": [ + "preps" + ], + "memberdict_labels": [ + "rho0" + ] + }, + "1": { + "module": "pygsti.modelmembers.states.fullstate", + "class": "FullState", + "submembers": [], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 4, + 5, + 6, + 7 + ], + "relative_submember_parameter_indices": [], + "parameter_labels": [ + "VecElement Re(0)", + "VecElement Re(1)", + "VecElement Re(2)", + "VecElement Re(3)" + ], + "parameter_bounds": null, + "dense_superket_vector": [ + 0.7071067811865476, + 0.0, + 0.0, + 0.7071067811865476 + ], + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + } + }, + "2": { + "module": "pygsti.modelmembers.povms.fulleffect", + "class": "FullPOVMEffect", + "submembers": [ + 1 + ], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 4, + 5, + 6, + 7 + ], + "relative_submember_parameter_indices": [ + [ + 0, + 1, + 2, + 3 + ] + ], + "parameter_labels": null, + "parameter_bounds": null + }, + "3": { + "module": "pygsti.modelmembers.states.fullstate", + "class": "FullState", + "submembers": [], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 8, + 9, + 10, + 11 + ], + "relative_submember_parameter_indices": [], + "parameter_labels": [ + "VecElement Re(0)", + "VecElement Re(1)", + "VecElement Re(2)", + "VecElement Re(3)" + ], + "parameter_bounds": null, + "dense_superket_vector": [ + 0.7071067811865476, + 0.0, + 0.0, + -0.7071067811865476 + ], + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + } + }, + "4": { + "module": "pygsti.modelmembers.povms.fulleffect", + "class": "FullPOVMEffect", + "submembers": [ + 3 + ], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 8, + 9, + 10, + 11 + ], + "relative_submember_parameter_indices": [ + [ + 0, + 1, + 2, + 3 + ] + ], + "parameter_labels": null, + "parameter_bounds": null + }, + "5": { + "module": "pygsti.modelmembers.povms.unconstrainedpovm", + "class": "UnconstrainedPOVM", + "submembers": [ + 2, + 4 + ], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "relative_submember_parameter_indices": [ + [ + 0, + 1, + 2, + 3 + ], + [ + 4, + 5, + 6, + 7 + ] + ], + "parameter_labels": [ + "VecElement Re(0)", + "VecElement Re(1)", + "VecElement Re(2)", + "VecElement Re(3)", + "VecElement Re(0)", + "VecElement Re(1)", + "VecElement Re(2)", + "VecElement Re(3)" + ], + "parameter_bounds": null, + "effect_labels": [ + "0", + "1" + ], + "memberdict_types": [ + "povms" + ], + "memberdict_labels": [ + "Mdefault" + ] + }, + "6": { + "module": "pygsti.modelmembers.operations.fullarbitraryop", + "class": "FullArbitraryOp", + "submembers": [], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "relative_submember_parameter_indices": [], + "parameter_labels": [ + "MxElement 0,0", + "MxElement 0,1", + "MxElement 0,2", + "MxElement 0,3", + "MxElement 1,0", + "MxElement 1,1", + "MxElement 1,2", + "MxElement 1,3", + "MxElement 2,0", + "MxElement 2,1", + "MxElement 2,2", + "MxElement 2,3", + "MxElement 3,0", + "MxElement 3,1", + "MxElement 3,2", + "MxElement 3,3" + ], + "parameter_bounds": null, + "dense_matrix": [ + [ + 1.0, + 0.0, + 0.0, + 1.0146536357569526e-17 + ], + [ + 0.0, + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 1.0, + 0.0 + ], + [ + 1.0146536357569526e-17, + 0.0, + 0.0, + 1.0 + ] + ], + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + }, + "memberdict_types": [ + "operations" + ], + "memberdict_labels": [ + "[]" + ] + }, + "7": { + "module": "pygsti.modelmembers.operations.fullarbitraryop", + "class": "FullArbitraryOp", + "submembers": [], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43 + ], + "relative_submember_parameter_indices": [], + "parameter_labels": [ + "MxElement 0,0", + "MxElement 0,1", + "MxElement 0,2", + "MxElement 0,3", + "MxElement 1,0", + "MxElement 1,1", + "MxElement 1,2", + "MxElement 1,3", + "MxElement 2,0", + "MxElement 2,1", + "MxElement 2,2", + "MxElement 2,3", + "MxElement 3,0", + "MxElement 3,1", + "MxElement 3,2", + "MxElement 3,3" + ], + "parameter_bounds": null, + "dense_matrix": [ + [ + 0.9999999999999999, + 0.0, + 8.865115929175828e-17, + 1.1102230246251564e-16 + ], + [ + 0.0, + 0.9999999999999999, + 0.0, + 0.0 + ], + [ + -1.1102230246251565e-16, + 0.0, + 9.47634626983522e-17, + -0.9999999999999998 + ], + [ + 8.865115929175828e-17, + 0.0, + 0.9999999999999999, + 7.850462293418876e-17 + ] + ], + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + }, + "memberdict_types": [ + "operations" + ], + "memberdict_labels": [ + "Gxpi2:0" + ] + }, + "8": { + "module": "pygsti.modelmembers.operations.fullarbitraryop", + "class": "FullArbitraryOp", + "submembers": [], + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + }, + "evotype": "densitymx", + "model_parameter_indices": [ + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59 + ], + "relative_submember_parameter_indices": [], + "parameter_labels": [ + "MxElement 0,0", + "MxElement 0,1", + "MxElement 0,2", + "MxElement 0,3", + "MxElement 1,0", + "MxElement 1,1", + "MxElement 1,2", + "MxElement 1,3", + "MxElement 2,0", + "MxElement 2,1", + "MxElement 2,2", + "MxElement 2,3", + "MxElement 3,0", + "MxElement 3,1", + "MxElement 3,2", + "MxElement 3,3" + ], + "parameter_bounds": null, + "dense_matrix": [ + [ + 0.9999999999999999, + -8.865115929175828e-17, + 0.0, + 1.1102230246251564e-16 + ], + [ + 1.1102230246251565e-16, + 9.47634626983522e-17, + 0.0, + 0.9999999999999998 + ], + [ + 0.0, + 0.0, + 0.9999999999999999, + 0.0 + ], + [ + 8.865115929175828e-17, + -0.9999999999999999, + 0.0, + 7.850462293418876e-17 + ] + ], + "basis": { + "module": "pygsti.baseobjs.basis", + "class": "BuiltinBasis", + "version": 0, + "name": "pp", + "sparse": false, + "state_space": { + "module": "pygsti.baseobjs.statespace", + "class": "ExplicitStateSpace", + "version": 0, + "labels": [ + [ + 0 + ] + ], + "unitary_space_dimensions": [ + [ + 2 + ] + ], + "types": [ + [ + "Q" + ] + ] + } + }, + "memberdict_types": [ + "operations" + ], + "memberdict_labels": [ + "Gypi2:0" + ] + } + } +} \ No newline at end of file From d4fd8184440b8dd0d4952390af61179d076e359b Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Thu, 22 Aug 2024 11:15:33 -0600 Subject: [PATCH 5/9] removed temp files --- .../badfit_options.json | 18 - .../gaugeopt_suite.json | 10 - .../meta.json | 1 - .../target_model.json | 1206 ----------------- 4 files changed, 1235 deletions(-) delete mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json delete mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json delete mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json delete mode 100644 test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json deleted file mode 100644 index 882900f74..000000000 --- a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/badfit_options.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "module": "pygsti.protocols.gst", - "class": "GSTBadFitOptions", - "version": 0, - "threshold": 2.0, - "actions": [], - "wildcard": { - "budget_includes_spam": true, - "L1_weights": null, - "primitive_op_labels": null, - "initial_budget": null, - "methods": [ - "neldermead" - ], - "indadmissable_action": "print", - "1d_reference": "diamond distance" - } -} \ No newline at end of file diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json deleted file mode 100644 index 242d98153..000000000 --- a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/gaugeopt_suite.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "module": "pygsti.protocols.gst", - "class": "GSTGaugeOptSuite", - "version": 0, - "gaugeopt_suite_names": [ - "stdgaugeopt" - ], - "gaugeopt_argument_dicts": {}, - "gaugeopt_target": null -} \ No newline at end of file diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json deleted file mode 100644 index 707ecc89e..000000000 --- a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"type": "pygsti.protocols.gst.LinearGateSetTomography", "auxfile_types": {"target_model": "serialized-object", "gaugeopt_suite": "serialized-object", "badfit_options": "serialized-object"}, "name": "testGST", "tags": {}, "_nameddict_attributes": [], "verbosity": 2, "profile": 1, "record_output": true, "oplabels": "default", "oplabel_aliases": null, "unreliable_ops": ["Gcnot", "Gcphase", "Gms", "Gcn", "Gcx", "Gcz"]} \ No newline at end of file diff --git a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json b/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json deleted file mode 100644 index 3334f7276..000000000 --- a/test_packages/temp_test_files/test_LinearGateSetTomography_serialization/target_model.json +++ /dev/null @@ -1,1206 +0,0 @@ -{ - "module": "pygsti.models.explicitmodel", - "class": "ExplicitOpModel", - "version": 0, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "parameter_labels": [ - [ - "rho0", - "VecElement Re(0)" - ], - [ - "rho0", - "VecElement Re(1)" - ], - [ - "rho0", - "VecElement Re(2)" - ], - [ - "rho0", - "VecElement Re(3)" - ], - [ - "Mdefault", - "VecElement Re(0)" - ], - [ - "Mdefault", - "VecElement Re(1)" - ], - [ - "Mdefault", - "VecElement Re(2)" - ], - [ - "Mdefault", - "VecElement Re(3)" - ], - [ - "Mdefault", - "VecElement Re(0)" - ], - [ - "Mdefault", - "VecElement Re(1)" - ], - [ - "Mdefault", - "VecElement Re(2)" - ], - [ - "Mdefault", - "VecElement Re(3)" - ], - [ - [], - "MxElement 0,0" - ], - [ - [], - "MxElement 0,1" - ], - [ - [], - "MxElement 0,2" - ], - [ - [], - "MxElement 0,3" - ], - [ - [], - "MxElement 1,0" - ], - [ - [], - "MxElement 1,1" - ], - [ - [], - "MxElement 1,2" - ], - [ - [], - "MxElement 1,3" - ], - [ - [], - "MxElement 2,0" - ], - [ - [], - "MxElement 2,1" - ], - [ - [], - "MxElement 2,2" - ], - [ - [], - "MxElement 2,3" - ], - [ - [], - "MxElement 3,0" - ], - [ - [], - "MxElement 3,1" - ], - [ - [], - "MxElement 3,2" - ], - [ - [], - "MxElement 3,3" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 0,0" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 0,1" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 0,2" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 0,3" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 1,0" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 1,1" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 1,2" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 1,3" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 2,0" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 2,1" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 2,2" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 2,3" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 3,0" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 3,1" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 3,2" - ], - [ - [ - "Gxpi2", - 0 - ], - "MxElement 3,3" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 0,0" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 0,1" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 0,2" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 0,3" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 1,0" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 1,1" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 1,2" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 1,3" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 2,0" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 2,1" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 2,2" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 2,3" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 3,0" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 3,1" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 3,2" - ], - [ - [ - "Gypi2", - 0 - ], - "MxElement 3,3" - ] - ], - "parameter_bounds": null, - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - }, - "default_gate_type": "full", - "default_prep_type": [ - "full" - ], - "default_povm_type": [ - "full" - ], - "default_instrument_type": [ - "full" - ], - "prep_prefix": "rho", - "effect_prefix": "E", - "gate_prefix": "G", - "povm_prefix": "M", - "instrument_prefix": "I", - "evotype": "densitymx", - "simulator": { - "module": "pygsti.forwardsims.matrixforwardsim", - "class": "MatrixForwardSimulator", - "version": 0, - "mode": "time_independent" - }, - "default_gauge_group": { - "module": "pygsti.models.gaugegroup", - "class": "FullGaugeGroup", - "version": 0, - "state_space_dimension": 4, - "evotype": "densitymx", - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - } - }, - "parameter_interposer": null, - "modelmembers": { - "0": { - "module": "pygsti.modelmembers.states.fullstate", - "class": "FullState", - "submembers": [], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 0, - 1, - 2, - 3 - ], - "relative_submember_parameter_indices": [], - "parameter_labels": [ - "VecElement Re(0)", - "VecElement Re(1)", - "VecElement Re(2)", - "VecElement Re(3)" - ], - "parameter_bounds": null, - "dense_superket_vector": [ - 0.7071067811865476, - 0.0, - 0.0, - 0.7071067811865476 - ], - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - }, - "memberdict_types": [ - "preps" - ], - "memberdict_labels": [ - "rho0" - ] - }, - "1": { - "module": "pygsti.modelmembers.states.fullstate", - "class": "FullState", - "submembers": [], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 4, - 5, - 6, - 7 - ], - "relative_submember_parameter_indices": [], - "parameter_labels": [ - "VecElement Re(0)", - "VecElement Re(1)", - "VecElement Re(2)", - "VecElement Re(3)" - ], - "parameter_bounds": null, - "dense_superket_vector": [ - 0.7071067811865476, - 0.0, - 0.0, - 0.7071067811865476 - ], - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - } - }, - "2": { - "module": "pygsti.modelmembers.povms.fulleffect", - "class": "FullPOVMEffect", - "submembers": [ - 1 - ], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 4, - 5, - 6, - 7 - ], - "relative_submember_parameter_indices": [ - [ - 0, - 1, - 2, - 3 - ] - ], - "parameter_labels": null, - "parameter_bounds": null - }, - "3": { - "module": "pygsti.modelmembers.states.fullstate", - "class": "FullState", - "submembers": [], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 8, - 9, - 10, - 11 - ], - "relative_submember_parameter_indices": [], - "parameter_labels": [ - "VecElement Re(0)", - "VecElement Re(1)", - "VecElement Re(2)", - "VecElement Re(3)" - ], - "parameter_bounds": null, - "dense_superket_vector": [ - 0.7071067811865476, - 0.0, - 0.0, - -0.7071067811865476 - ], - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - } - }, - "4": { - "module": "pygsti.modelmembers.povms.fulleffect", - "class": "FullPOVMEffect", - "submembers": [ - 3 - ], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 8, - 9, - 10, - 11 - ], - "relative_submember_parameter_indices": [ - [ - 0, - 1, - 2, - 3 - ] - ], - "parameter_labels": null, - "parameter_bounds": null - }, - "5": { - "module": "pygsti.modelmembers.povms.unconstrainedpovm", - "class": "UnconstrainedPOVM", - "submembers": [ - 2, - 4 - ], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11 - ], - "relative_submember_parameter_indices": [ - [ - 0, - 1, - 2, - 3 - ], - [ - 4, - 5, - 6, - 7 - ] - ], - "parameter_labels": [ - "VecElement Re(0)", - "VecElement Re(1)", - "VecElement Re(2)", - "VecElement Re(3)", - "VecElement Re(0)", - "VecElement Re(1)", - "VecElement Re(2)", - "VecElement Re(3)" - ], - "parameter_bounds": null, - "effect_labels": [ - "0", - "1" - ], - "memberdict_types": [ - "povms" - ], - "memberdict_labels": [ - "Mdefault" - ] - }, - "6": { - "module": "pygsti.modelmembers.operations.fullarbitraryop", - "class": "FullArbitraryOp", - "submembers": [], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "relative_submember_parameter_indices": [], - "parameter_labels": [ - "MxElement 0,0", - "MxElement 0,1", - "MxElement 0,2", - "MxElement 0,3", - "MxElement 1,0", - "MxElement 1,1", - "MxElement 1,2", - "MxElement 1,3", - "MxElement 2,0", - "MxElement 2,1", - "MxElement 2,2", - "MxElement 2,3", - "MxElement 3,0", - "MxElement 3,1", - "MxElement 3,2", - "MxElement 3,3" - ], - "parameter_bounds": null, - "dense_matrix": [ - [ - 1.0, - 0.0, - 0.0, - 1.0146536357569526e-17 - ], - [ - 0.0, - 1.0, - 0.0, - 0.0 - ], - [ - 0.0, - 0.0, - 1.0, - 0.0 - ], - [ - 1.0146536357569526e-17, - 0.0, - 0.0, - 1.0 - ] - ], - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - }, - "memberdict_types": [ - "operations" - ], - "memberdict_labels": [ - "[]" - ] - }, - "7": { - "module": "pygsti.modelmembers.operations.fullarbitraryop", - "class": "FullArbitraryOp", - "submembers": [], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43 - ], - "relative_submember_parameter_indices": [], - "parameter_labels": [ - "MxElement 0,0", - "MxElement 0,1", - "MxElement 0,2", - "MxElement 0,3", - "MxElement 1,0", - "MxElement 1,1", - "MxElement 1,2", - "MxElement 1,3", - "MxElement 2,0", - "MxElement 2,1", - "MxElement 2,2", - "MxElement 2,3", - "MxElement 3,0", - "MxElement 3,1", - "MxElement 3,2", - "MxElement 3,3" - ], - "parameter_bounds": null, - "dense_matrix": [ - [ - 0.9999999999999999, - 0.0, - 8.865115929175828e-17, - 1.1102230246251564e-16 - ], - [ - 0.0, - 0.9999999999999999, - 0.0, - 0.0 - ], - [ - -1.1102230246251565e-16, - 0.0, - 9.47634626983522e-17, - -0.9999999999999998 - ], - [ - 8.865115929175828e-17, - 0.0, - 0.9999999999999999, - 7.850462293418876e-17 - ] - ], - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - }, - "memberdict_types": [ - "operations" - ], - "memberdict_labels": [ - "Gxpi2:0" - ] - }, - "8": { - "module": "pygsti.modelmembers.operations.fullarbitraryop", - "class": "FullArbitraryOp", - "submembers": [], - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - }, - "evotype": "densitymx", - "model_parameter_indices": [ - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59 - ], - "relative_submember_parameter_indices": [], - "parameter_labels": [ - "MxElement 0,0", - "MxElement 0,1", - "MxElement 0,2", - "MxElement 0,3", - "MxElement 1,0", - "MxElement 1,1", - "MxElement 1,2", - "MxElement 1,3", - "MxElement 2,0", - "MxElement 2,1", - "MxElement 2,2", - "MxElement 2,3", - "MxElement 3,0", - "MxElement 3,1", - "MxElement 3,2", - "MxElement 3,3" - ], - "parameter_bounds": null, - "dense_matrix": [ - [ - 0.9999999999999999, - -8.865115929175828e-17, - 0.0, - 1.1102230246251564e-16 - ], - [ - 1.1102230246251565e-16, - 9.47634626983522e-17, - 0.0, - 0.9999999999999998 - ], - [ - 0.0, - 0.0, - 0.9999999999999999, - 0.0 - ], - [ - 8.865115929175828e-17, - -0.9999999999999999, - 0.0, - 7.850462293418876e-17 - ] - ], - "basis": { - "module": "pygsti.baseobjs.basis", - "class": "BuiltinBasis", - "version": 0, - "name": "pp", - "sparse": false, - "state_space": { - "module": "pygsti.baseobjs.statespace", - "class": "ExplicitStateSpace", - "version": 0, - "labels": [ - [ - 0 - ] - ], - "unitary_space_dimensions": [ - [ - 2 - ] - ], - "types": [ - [ - "Q" - ] - ] - } - }, - "memberdict_types": [ - "operations" - ], - "memberdict_labels": [ - "Gypi2:0" - ] - } - } -} \ No newline at end of file From 167d742b315883969398f682547e26fc33dcbcbb Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Fri, 23 Aug 2024 10:24:27 -0600 Subject: [PATCH 6/9] removed magic numbers from povm convert, and added a check if there is valid GLND representation for povm --- pygsti/modelmembers/povms/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pygsti/modelmembers/povms/__init__.py b/pygsti/modelmembers/povms/__init__.py index 658b97ef7..34e5b3135 100644 --- a/pygsti/modelmembers/povms/__init__.py +++ b/pygsti/modelmembers/povms/__init__.py @@ -415,14 +415,21 @@ def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): errgen = _LindbladErrorgen.from_error_generator(4, parameterization="GLND") exp_errgen = _ExpErrorgenOp(errgen) - ideal_vec = _np.zeros(12) - J = _np.zeros((dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1],12)) + num_qubits = povm.state_space.num_qubits + num_errgens = 2**(4*num_qubits)-2**(2*num_qubits) + #TODO: Maybe we can use the num of params instead of number of matrix entries, as some of them are linearly dependent. + #i.e E0 completely determines E1 if those are the only two povm elements (E0 + E1 = Identity) + num_entries = dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1] + assert num_errgens > povm.num_params, "POVM has too many elements, GLND parameterization is not possible" + + ideal_vec = _np.zeros(num_errgens) + J = _np.zeros((num_entries,num_errgens)) for i in range(len(ideal_vec)): new_vec = ideal_vec.copy() new_vec[i] = epsilon exp_errgen.from_vector(new_vec) - vectorized_povm = _np.zeros(dense_ideal_povm.shape[0]*dense_ideal_povm.shape[1]) + vectorized_povm = _np.zeros(num_entries) perturbed_povm = (dense_ideal_povm @ exp_errgen.to_dense() - dense_ideal_povm)/epsilon perturbed_povm_t = perturbed_povm.transpose() From c6ec19f899e0850adc1f078fb6b431f4123a204c Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Wed, 4 Sep 2024 09:22:22 -0600 Subject: [PATCH 7/9] commented povm file --- pygsti/modelmembers/povms/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pygsti/modelmembers/povms/__init__.py b/pygsti/modelmembers/povms/__init__.py index 34e5b3135..b020aef84 100644 --- a/pygsti/modelmembers/povms/__init__.py +++ b/pygsti/modelmembers/povms/__init__.py @@ -395,7 +395,8 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): errorgen = _LindbladErrorgen.from_error_generator(povm.state_space.dim, lndtype, proj_basis, basis, truncate=True, evotype=povm.evotype) if to_type == 'GLND' and isinstance(povm, destination_types.get('full TP', NoneType)): - #Need to set errorgen so exp(errorgen)|st> == |state> + + #Collect all ideal effects base_dense_effects = [] for item in base_items: dense_effect = item[1].to_dense() @@ -403,6 +404,7 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) + #Collect all noisy effects dense_effects = [] for effect in povm.values(): dense_effect = effect.to_dense() @@ -411,6 +413,9 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False): dense_ideal_povm = _np.concatenate(base_dense_effects, axis=0) dense_povm = _np.concatenate(dense_effects, axis=0) + #It is often the case that there are more error generators than physical degrees of freedom in the POVM + #We define a function which finds linear comb. of errgens that span these degrees of freedom. + #This has been called "the dumb gauge", and this function is meant to avoid it def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): errgen = _LindbladErrorgen.from_error_generator(4, parameterization="GLND") @@ -423,6 +428,9 @@ def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): assert num_errgens > povm.num_params, "POVM has too many elements, GLND parameterization is not possible" ideal_vec = _np.zeros(num_errgens) + + #Compute the jacobian with respect to the error generators. This will allow us to see which + #error generators change the POVM entries J = _np.zeros((num_entries,num_errgens)) for i in range(len(ideal_vec)): @@ -443,7 +451,8 @@ def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9): phys_directions = calc_physical_subspace(dense_ideal_povm) - + #We use optimization to find the best error generator representation + #we only vary physical directions, not independent error generators def _objfn(v): L_vec = _np.zeros(len(phys_directions[0])) for coeff, phys_direction in zip(v,phys_directions): From 2bf56d6759b829fd0a81b8e3a5ef3bb3c0020a3b Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Wed, 4 Sep 2024 09:36:27 -0600 Subject: [PATCH 8/9] commented state file --- pygsti/modelmembers/states/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pygsti/modelmembers/states/__init__.py b/pygsti/modelmembers/states/__init__.py index e3b41f6db..f50752ffa 100644 --- a/pygsti/modelmembers/states/__init__.py +++ b/pygsti/modelmembers/states/__init__.py @@ -258,16 +258,22 @@ def convert(state, to_type, basis, ideal_state=None, flatten_structure=False): errorgen = _LindbladErrorgen.from_error_generator(state.state_space.dim, to_type, proj_basis, basis, truncate=True, evotype=state.evotype) if st is not state and not _np.allclose(st.to_dense(), state.to_dense()): - #Need to set errorgen so exp(errorgen)|st> == |state> + dense_st = st.to_dense() dense_state = state.to_dense() num_qubits = st.state_space.num_qubits num_errgens = 2**(4*num_qubits)-2**(2*num_qubits) + + #GLND for states suffers from "dumb gauge" freedom. This function identifies + #the physical directions to avoid this gauge. def calc_physical_subspace(ideal_prep, epsilon = 1e-9): errgen = _LindbladErrorgen.from_error_generator(2**(2*num_qubits), parameterization="GLND") exp_errgen = _ExpErrorgenOp(errgen) ideal_vec = _np.zeros(num_errgens) + + #Compute the jacobian with respect to the error generators. This will allow us to see which + #error generators change the POVM entries J = _np.zeros((state.num_params, num_errgens)) for i in range(len(ideal_vec)): @@ -281,13 +287,15 @@ def calc_physical_subspace(ideal_prep, epsilon = 1e-9): phys_directions = calc_physical_subspace(dense_state) + #We use optimization to find the best error generator representation + #we only vary physical directions, not independent error generators def _objfn(v): L_vec = _np.zeros(len(phys_directions[0])) for coeff, phys_direction in zip(v,phys_directions): L_vec += coeff * phys_direction errorgen.from_vector(L_vec) return _np.linalg.norm(_spl.expm(errorgen.to_dense()) @ dense_st - dense_state) - #def callback(x): print("callbk: ",_np.linalg.norm(x),_objfn(x)) # REMOVE + soln = _spo.minimize(_objfn, _np.zeros(len(phys_directions), 'd'), method="Nelder-Mead", options={}, tol=1e-13) # , callback=callback) #print("DEBUG: opt done: ",soln.success, soln.fun, soln.x) # REMOVE From 0ec92dd4865bf8639ee076444bba87e1707e3488 Mon Sep 17 00:00:00 2001 From: Juan G Mendoza Date: Thu, 26 Sep 2024 11:58:55 -0600 Subject: [PATCH 9/9] started implementing CPTPLND compatibility with set_all_parameterization --- pygsti/modelmembers/states/__init__.py | 7 +++++-- pygsti/tools/jamiolkowski.py | 21 +++++++++++++++++++++ test/unit/objects/test_model.py | 10 ++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/pygsti/modelmembers/states/__init__.py b/pygsti/modelmembers/states/__init__.py index f50752ffa..f8d8628ab 100644 --- a/pygsti/modelmembers/states/__init__.py +++ b/pygsti/modelmembers/states/__init__.py @@ -32,6 +32,7 @@ from pygsti.baseobjs import statespace as _statespace from pygsti.tools import basistools as _bt from pygsti.tools import optools as _ot +from pygsti.tools import sum_of_negative_choi_eigenvalues_gate # Avoid circular import import pygsti.modelmembers as _mm @@ -286,15 +287,17 @@ def calc_physical_subspace(ideal_prep, epsilon = 1e-9): return V[:len(S),] phys_directions = calc_physical_subspace(dense_state) - + cptp_penalty = .5 #We use optimization to find the best error generator representation #we only vary physical directions, not independent error generators + def _objfn(v): L_vec = _np.zeros(len(phys_directions[0])) for coeff, phys_direction in zip(v,phys_directions): L_vec += coeff * phys_direction errorgen.from_vector(L_vec) - return _np.linalg.norm(_spl.expm(errorgen.to_dense()) @ dense_st - dense_state) + proc_matrix = _spl.expm(errorgen.to_dense()) + return _np.linalg.norm(proc_matrix @ dense_st - dense_state) + cptp_pentaly * sum_of_negative_choi_eigenvalues_gate(proc_matrix) soln = _spo.minimize(_objfn, _np.zeros(len(phys_directions), 'd'), method="Nelder-Mead", options={}, tol=1e-13) # , callback=callback) diff --git a/pygsti/tools/jamiolkowski.py b/pygsti/tools/jamiolkowski.py index e204c5206..055b65543 100644 --- a/pygsti/tools/jamiolkowski.py +++ b/pygsti/tools/jamiolkowski.py @@ -273,6 +273,27 @@ def fast_jamiolkowski_iso_std_inv(choi_mx, op_mx_basis): #transform operation matrix into appropriate basis return _bt.change_basis(opMxInStdBasis, op_mx_basis.create_equivalent('std'), op_mx_basis) +def sum_of_negative_choi_eigenvalues_gate(op_mx, op_mx_basis): + """ + Compute the sum of the negative Choi eigenvalues of a process matrix. + + Parameters + ---------- + op_mx : np.array + + op_mx_basis : Basis + + Returns + ------- + float + the sum of the negative eigenvalues of the Choi representation of op_mx + """ + sumOfNeg = 0 + J = fast_jamiolkowski_iso_std(op_mx, op_mx_basis) # Choi mx basis doesn't matter + evals = _np.linalg.eigvals(J) # could use eigvalsh, but wary of this since eigh can be wrong... + for ev in evals: + if ev.real < 0: sumOfNeg -= ev.real + return sumOfNeg def sum_of_negative_choi_eigenvalues(model, weights=None): """ diff --git a/test/unit/objects/test_model.py b/test/unit/objects/test_model.py index fdad0a22c..cf5f24460 100644 --- a/test/unit/objects/test_model.py +++ b/test/unit/objects/test_model.py @@ -136,6 +136,16 @@ def test_set_all_parameterizations_HS(self): nParamsPerGate=6, nParamsPerSP=6 ) + + def test_set_all_parameterizations_(self): + self.model.set_all_parameterizations("H+S") + self._assert_model_params( + nOperations=3, + nSPVecs=2, + nEVecs=0, + nParamsPerGate=6, + nParamsPerSP=6 + ) def test_element_accessors(self): # XXX what does this test cover and is it useful? EGN: covers the __getitem__/__setitem__ functions of model