Skip to content

Commit

Permalink
Bugfix for models from pspecs with instruments.
Browse files Browse the repository at this point in the history
Should also fix StandardGST runs with instruments.
  • Loading branch information
sserita committed Sep 13, 2023
1 parent 3e98e17 commit 843d714
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions pygsti/models/explicitmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,10 +1565,12 @@ def add_availability(opkey, op):

if all([udim == 2 for udim in all_udims]):
return _QubitProcessorSpec(nqudits, list(gate_unitaries.keys()), gate_unitaries, availability,
qubit_labels=qudit_labels)
qubit_labels=qudit_labels,
instrument_names=list(self.instruments.keys()), nonstd_instruments=self.instruments)
else:
return _QuditProcessorSpec(qudit_labels, all_udims, list(gate_unitaries.keys()), gate_unitaries,
availability)
availability,
instrument_names=list(self.instruments.keys()), nonstd_instruments=self.instruments)

def create_modelmember_graph(self):
return _MMGraph({
Expand Down
19 changes: 12 additions & 7 deletions pygsti/models/modelconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,13 +936,18 @@ def _spec_to_densevec(spec, is_prep):
inst_members = {}
for k, lst in instrument_spec.items():
member = None
for effect_spec, prep_spec in lst:
effect_vec = _spec_to_densevec(effect_spec, is_prep=False)
prep_vec = _spec_to_densevec(prep_spec, is_prep=True)
if member is None:
member = _np.outer(effect_vec, prep_vec)
else:
member += _np.outer(effect_vec, prep_vec)
if len(lst) == 2:
for effect_spec, prep_spec in lst:
effect_vec = _spec_to_densevec(effect_spec, is_prep=False)
prep_vec = _spec_to_densevec(prep_spec, is_prep=True)
if member is None:
member = _np.outer(effect_vec, prep_vec)
else:
member += _np.outer(effect_vec, prep_vec)
else: # elements are key, array of outer product already
# TODO: This appears to be the new standard format. Deprecate outer prod code above?
# But old code could still be useful.
member = lst.copy()

assert (member is not None), \
"You must provide at least one rank-1 specifier for each instrument member!"
Expand Down

0 comments on commit 843d714

Please sign in to comment.