Skip to content

Commit

Permalink
Updates germ_length_limit interpretation to avoid dropping a germ com…
Browse files Browse the repository at this point in the history
…pletely.

Previously, in GST circuit construction when a maximum length was greater
than the per-germ maximum length given by the `germ_length_limit` argument,
the circuits for that germ were always omitted.  This could be annoying,
however, if *only* large maximum lengths are given and a germ has a
max-length limit smaller than all the maximum lengths requested.  This
commit alters the behavior of the GST circuit construction routines to
include the circuits for such a germ that have the germ's repeated length
equals its max-length-limit (even though this limit is smaller than the first
maximum length requested).
  • Loading branch information
enielse committed Sep 26, 2023
1 parent 02b9d36 commit 69357a7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pygsti/circuits/gstcircuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ def _create_raw_lsgst_lists(op_label_src, prep_strs, effect_strs, germ_list, max
else:
#Typical case of germs repeated to maxLen using Rfn
for germ in germ_list:
if maxLen > germ_length_limits.get(germ, 1e100): continue
if maxLen == max_length_list[0] and maxLen > germ_length_limits.get(germ, 1e100):
maxLen_thisgerm = germ_length_limits[germ] # IndexError should not occur here!
elif maxLen > germ_length_limits.get(germ, 1e100):
continue
else:
maxLen_thisgerm = maxLen

if rndm is None:
fiducialPairsThisIter = fiducialPairs[germ]
Expand Down Expand Up @@ -232,7 +237,7 @@ def _create_raw_lsgst_lists(op_label_src, prep_strs, effect_strs, germ_list, max

lst += _gsc.create_circuits("f[0]+R(germ,N)+f[1]",
f=fiducialPairsThisIter,
germ=germ, N=maxLen,
germ=germ, N=maxLen_thisgerm,
R=Rfn, order=('f',))
if nest:
lsgst_list += lst # add new strings to running list
Expand Down Expand Up @@ -566,9 +571,14 @@ def add_to_plaquettes(pkey_dict, plaquette_dict, base_circuit, maxlen, germ, pow
#Typical case of germs repeated to maxLen using r_fn
for ii, germ in enumerate(germs):
if germ == empty_germ: continue # handled specially above
if maxLen > germ_length_limits.get(germ, 1e100): continue
if maxLen == max_lengths[0] and maxLen > germ_length_limits.get(germ, 1e100):
maxLen_thisgerm = germ_length_limits[germ] # IndexError should not occur here!
elif maxLen > germ_length_limits.get(germ, 1e100):
continue
else:
maxLen_thisgerm = maxLen

germ_power = truncFn(germ, maxLen)
germ_power = truncFn(germ, maxLen_thisgerm)
power = len(germ_power) // len(germ) # this *could* be the germ power
if germ_power != germ * power:
power = None # Signals there is no well-defined power
Expand All @@ -579,7 +589,7 @@ def add_to_plaquettes(pkey_dict, plaquette_dict, base_circuit, maxlen, germ, pow
# Switch on fidpair dicts with germ or (germ, L) keys
key = germ
if fidpair_germ_power_keys:
key = (germ, maxLen)
key = (germ, maxLen_thisgerm)

if rndm is None:
fiducialPairsThisIter = fidPairDict.get(key, allPossiblePairs) \
Expand Down

0 comments on commit 69357a7

Please sign in to comment.