Skip to content

Fiducial Selection Bugfix #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions pygsti/algorithms/fiducialselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,17 +712,15 @@ def create_meas_cache(model, available_meas_fid_list, circuit_cache=None):
if circuit_cache is not None:
for povm in model.povms.values():
for E in povm.values():
if isinstance(E, _ComplementPOVMEffect): continue # complement is dependent on others
new_povm_effect_key_pair= (povm.to_vector().tobytes(), E.to_vector().tobytes())
new_povm_effect_key_pair= (povm.to_vector().tobytes(), E.to_dense().tobytes())
keypairlist.append(new_povm_effect_key_pair)
for measFid in available_meas_fid_list:
meas_cache[(new_povm_effect_key_pair[0],new_povm_effect_key_pair[1],measFid.str)] = _np.dot(E.to_dense(), circuit_cache[measFid.str])

else:
for povm in model.povms.values():
for E in povm.values():
if isinstance(E, _ComplementPOVMEffect): continue # complement is dependent on others
new_povm_effect_key_pair= (povm.to_vector().tobytes(), E.to_vector().tobytes())
new_povm_effect_key_pair= (povm.to_vector().tobytes(), E.to_dense().tobytes())
keypairlist.append(new_povm_effect_key_pair)
for measFid in available_meas_fid_list:
meas_cache[(new_povm_effect_key_pair[0],new_povm_effect_key_pair[1],measFid.str)] = _np.dot(E.to_dense(), model.sim.product(measFid))
Expand Down Expand Up @@ -777,7 +775,6 @@ def create_prep_mxs(model, prep_fid_list, prep_cache=None):
except KeyError as err:
print('A (Rho, Circuit) pair is missing from the cache, all such pairs should be available is using the caching option.')
raise err
#outputMat[:, i] = _np.dot(model.sim.product(prepFid), rho.to_dense())
outputMatList.append(outputMat)

else:
Expand Down Expand Up @@ -832,17 +829,15 @@ def create_meas_mxs(model, meas_fid_list, meas_cache=None):
#Actually, this is slowing things down a good amount, let's just print a
#descriptive error message if the key is missing
try:
outputMat[:, i] = meas_cache[0][(povm_key, E_key,measFid.str)]
outputMat[:, i] = meas_cache[0][(povm_key, E_key, measFid.str)]
except KeyError as err:
print('A (POVM, Effect, Circuit) pair is missing from the cache, all such pairs should be available is using the caching option.')
print('A (POVM, Effect, Circuit) pair is missing from the cache, all such pairs should be available if using the caching option.')
raise err
#outputMat[:, i] = _np.dot(E.to_dense(), model.sim.product(measFid))
outputMatList.append(outputMat)

else:
for povm in model.povms.values():
for E in povm.values():
if isinstance(E, _ComplementPOVMEffect): continue # complement is dependent on others
outputMat = _np.zeros([dimE, numFid], float)
for i, measFid in enumerate(meas_fid_list):
outputMat[:, i] = _np.dot(E.to_dense(), model.sim.product(measFid))
Expand Down Expand Up @@ -1774,10 +1769,6 @@ def _find_fiducials_greedy(model, fids_list, prep_or_meas, op_penalty=0.0,
else:
for fiducial in fids_list:
#calculate the score matrix
#if prep_or_meas == 'prep':
# fidArrayList = create_prep_mxs(model, [fiducial], fid_cache)
#elif prep_or_meas == 'meas':
# fidArrayList = create_meas_mxs(model, [fiducial], fid_cache)
current_score_mx= fiducial_compact_EVD_cache[fiducial]
current_score_gramian= fiducial_compact_EVD_cache[fiducial]@fiducial_compact_EVD_cache[fiducial].T
current_inv_trace = _np.trace(_np.linalg.pinv(current_score_gramian, hermitian=True))
Expand Down