Skip to content

Conversation

@juangmendoza19
Copy link
Contributor

Corey and I pair-programmed a new feature (in hopes it will be useful for AMS) that allows for the specification of iteration-specific optimizers.

This new feature allows the user to pass in many optimizers into GST, such that each GST iteration can use a different optimizer.

For example, if a user wants to have a different number of iterations only for the final logl GST iteration, it can specify a different optimizer just for the final iteration.

To use this feature, simply create a list of the optimizers to be used:

optimizers = [optimizer_1, optimizer_2, ..., optimizer_k]
your_favorite_gst_protocol.run(data, optimizers=optimizers)

Where k is the total number of iterations for the GST protocol (k == len(circuit_lists)).

Iteration i within GST will use optimizer_i

On a separate note, I found two GST unit test classes that were not being executed: TestStandardGST and TestGateSetTomography. Corey suggested their names must end with "Tester", so I renamed them "GateSetTomographyTester" and "StandardGSTTester".

This revealed two failing tests:

FAILED protocols/test_gst.py::GateSetTomographyTester::test_run_custom_sim - assert False
FAILED protocols/test_gst.py::StandardGSTTester::test_run_custom_sim - assert False

These tests are failing due to code that is not touched in this branch, and also fail in develop if named appropriately such that they are not skipped.

Also Corey promised I would get "street cred" for doing type annotations of any arguments touched in this PR. I hope this promise is fulfilled.

@juangmendoza19 juangmendoza19 requested review from a team and rileyjmurray as code owners November 25, 2025 20:54
@juangmendoza19 juangmendoza19 requested review from coreyostrove and removed request for a team November 25, 2025 20:54
@coreyostrove
Copy link
Contributor

Also Corey promised I would get "street cred" for doing type annotations of any arguments touched in this PR. I hope this promise is fulfilled.

To clarify, I specifically said you'd get "street cred with @rileyjmurray, exchangeable at a future date for help with hard linear algebra problems". Whether the general public thinks of you as cooler now is still to be determined.

@juangmendoza19
Copy link
Contributor Author

Also Corey promised I would get "street cred" for doing type annotations of any arguments touched in this PR. I hope this promise is fulfilled.

To clarify, I specifically said you'd get "street cred with @rileyjmurray, exchangeable at a future date for help with hard linear algebra problems". Whether the general public thinks of you as cooler now is still to be determined.

Much better than any other type of street cred I can think of.

@coreyostrove coreyostrove changed the base branch from master to develop November 25, 2025 22:19
@juangmendoza19 juangmendoza19 changed the title New Feature: specifying GST iteration-specific optimizers New Feature: GST iteration-specific optimizers Nov 26, 2025
if simulator is not None:
mdl_start.sim = simulator

if optimizers is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is repeated from the algorithms/core.iterative_gst_generator function. I think we should refactor to call the same utility helper function in both cases. That way if we update the allowed types to pass in we will only need to update the logic in one location.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll take this as an opportunity to soap box against DRY in this particular instance, and instead advocate for LoB (https://htmx.org/essays/locality-of-behaviour/).

assert _np.allclose(mdl_result2.to_vector() , mdl_result1.to_vector())
assert _np.allclose(mdl_result3.to_vector() , mdl_result1.to_vector())
assert _np.allclose(mdl_result4.to_vector() , mdl_result1.to_vector())

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you also want to test if we can have different optimizer settings for each iteration of the GST experiment?

Copy link
Contributor Author

@juangmendoza19 juangmendoza19 Dec 1, 2025

Choose a reason for hiding this comment

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

I can add a test to check if it runs, but I don't see an easy way to test its valid. At that point it might not have any more value than the

results3 = proto1.run(self.gst_data, optimizers=optimizers)

test.

Copy link
Contributor

@nkoskelo nkoskelo left a comment

Choose a reason for hiding this comment

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

Just a few comments.

@coreyostrove coreyostrove removed their request for review December 1, 2025 17:52
@coreyostrove
Copy link
Contributor

Quick comment: Github auto selected me as a reviewer, but since I helped write this code it wouldn't make sense for me to do so, in the off chance anyone was waiting for one from me.

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.

6 participants