Skip to content

Conversation

@rileyjmurray
Copy link
Contributor

@rileyjmurray rileyjmurray commented Oct 21, 2025

This resolves #644. The fix was easier than I expected for two reasons. First, gauge optimization w.r.t. the Frobenius norm already incorporated instruments by way of ExplicitOpModelCalc.frobeniusdist and ExplicitOpModelCalc.residuals. Second, gauge optimization w.r.t. trace distance or infidelity can incorporate instruments just by working with operation dicts from target_model._excalc() and mdl._excalc(), rather than the operation dicts in target_model and mdl.

While I was making these changes, I (1) replaced instances of np.dot with the matmul infix operator, and (2) simplified branching in explicitcalc.py.

…tOpModelCalc.operations rather than ExplicitOpModel.operations. Replace instances of np.dot() with @ infix operator. Simplify branching in explicitcalc.py.
@rileyjmurray rileyjmurray requested review from a team as code owners October 21, 2025 04:58
@rileyjmurray rileyjmurray requested review from coreyostrove and kevincyoung and removed request for a team October 21, 2025 04:58
@rileyjmurray
Copy link
Contributor Author

The current fidelity-based objective tries to make fidelities as close to 1 as possible.
image
This makes zero sense when the target operation isn't TP, as is the case in operations from instruments. I could fix this so it tries to match eigenvalue_entanglement_infidelity from reportables.py. I'd rather not, since I already have those changes proposed in PR #669.

My solution for this PR is to disable tests for fidelity-based gauge optimization in the presence of instruments. I can enable those tests as part of PR #669 after this PR is merged.

@rileyjmurray
Copy link
Contributor Author

During today's dev meeting @coreyostrove expressed a desire to not have our fix just rely on the ExplicitOpModelCalc class (or at least to not rely on it by calling the private function ExplicitOpModel._excalc()). While there are various ways of accomplishing this, it seems that all of them would entail significant revisions to gaugeopt.py::_create_objective_fn. This is undesirable since I have other pending PRs that affect gaugeopt.py::_create_objective_fn. The other downside to doing anything other than ExplicitOpModelCalc is that this gets tied up in how leakage is specified (e.g., with an n_leak parameter) and that's the subject of yet another PR that I'm yet to open.

@coreyostrove, if it's alright with you I'd prefer to merge this change in now. I can include more comprehensive changes to gaugeopt.py::_create_objective_fn in my PR that adds general leakage modeling.

Copy link
Contributor

@coreyostrove coreyostrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coreyostrove, if it's alright with you I'd prefer to merge this change in now. I can include more comprehensive changes to gaugeopt.py::_create_objective_fn in my PR that adds general leakage modeling.

PR approved conditional on you writing this ⬆️ on that todo list on your whiteboard 😉.

Great work tracking this down and patching these issues. Also glad to see we weren't actually skipping the instruments. Hopefully @pcwysoc will forgive us (me) for the false alarm!

@rileyjmurray rileyjmurray merged commit b5feea1 into bugfix Oct 24, 2025
4 checks passed
rileyjmurray added a commit that referenced this pull request Oct 24, 2025
The automatic ``develop <- bugfix`` merge from Corey's PR yesterday
(#674)
[failed](https://github.com/sandialabs/pyGSTi/actions/runs/18768908655/job/53549598808#step:3:20).

The current state of bugfix includes changes from #674 and the PR I just
merged, #672. There's no way that the automatic ``develop <- bugfix``
merge will work since it includes the changes from yesterday that failed
the auto-merge. So this PR catches develop up with collective changes in
#672 and #674.

Tests for the candidate ``develop <- bugfix`` merge workflow passed (all
that failed was the auto-merge), so I'm going to merge this PR without
waiting for tests to pass.

Notes:

It's not clear to me why the auto-merge for #674 failed. It might have
something to do with the weird commit history I call out in the
screenshot below.

<img width="1168" height="204" alt="image"
src="https://github.com/user-attachments/assets/d8f196f8-26f6-45d1-b77f-e74c63e0a0d1"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants