Skip to content

Conversation

coreyostrove
Copy link
Contributor

This PR adds three new features/updates to the error generator propagation module:

  1. Support for the analytic computation of Magnus expansions has been added and replaces the default behavior when computing the BCH approximation for an end-of-circuit error generator. The new implementation supports up to third-order in the Magnus expansion. The previous method, iterative pairwise application of the BCH approximation is still available, but is no longer the default method. A corresponding numerical implementation has been added to support new unit tests.
  2. The logic for automatically mapping pyGSTi circuit line labels into the form required for conversion into a stim.Tableau has been extended to support automatic inference for the vast majority of use cases. For tricky or edge cases there are now options for manually controlling the label mapping behavior.
  3. A new function has been added for analytically applying elementary error generators to paulis. A corresponding numerical implementation has been added to support corresponding unit tests.

Corey Ostrove added 11 commits May 11, 2025 20:02
Add an initial implementation of the analytic Magnus expansion for up to second order and switch to using this as the default choice for doing BCH for EOC error generators.
Add a numerical implementation of the magnus expansion up to second order for testing infrastructure purposes.
Add stim conversions for the 24 single-qubit clifford gates numbered C0-C24.
Add in an implementation of the third-order Magnus expansion.
Add correct weighting to boundaries of the discretized Magnus integrals to account for time-ordering.
Update the numerical magnus expansion testing code to include the third-order Magnus expansion.
Add unit tests for the new analytical magnus expansion implementation.
Generalize the method for converting a circuit to a stim Tableau to allow automatic inference of the mapping from pyGSTi labels to stim qubit labels for most standard cases. Also adds ability to specify a custom conversion behavior for cases where this doesn't work. Plus some new unit tests for the conversion methods.
New function for analytically computing the action of an elementary error generator on a give Pauli. Returns the resulting pauli along with the corresponding weight. Also included is a numerical implementation used as part of new unit tests.
@coreyostrove coreyostrove requested a review from tjproct August 4, 2025 04:50
Fix a unit tests with incorrect indentation and which used the wrong method for a couple conversions.
@coreyostrove coreyostrove added this to the 0.9.14 milestone Aug 4, 2025
@coreyostrove coreyostrove requested a review from jordanh6 August 4, 2025 19:36
@coreyostrove coreyostrove self-assigned this Aug 4, 2025
@coreyostrove coreyostrove marked this pull request as ready for review August 4, 2025 19:36
@coreyostrove coreyostrove requested review from rileyjmurray and a team as code owners August 4, 2025 19:36
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.

A few ease of development items which may be nice to have.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have a request that in principle could apply everywhere, but I specifically ask for this file: can you use a space for the first after "#" when using in-line comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, you're simply asking that every comment of the form #<some text> -> # <some text>, correct?

If so, then sure I can do that, but it is going to utterly annihilate the diff (there are ~650 such comments in this file). So I will make that the very last thing I do on the branch just before merging after this is approved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup! That's what I'm hoping for.

Corey Ostrove added 2 commits August 14, 2025 22:08
Add in plumbing for the additional kwargs used to control the behavior of the pyGSTi circuit to stim Tableau conversion process.
Add requested type annotations of the stim conversion methods and for the new functions in errgenproptools.
@coreyostrove
Copy link
Contributor Author

coreyostrove commented Aug 15, 2025

@nkoskelo or @rileyjmurray: How do I avoid this linting error for these type annotations? https://github.com/sandialabs/pyGSTi/actions/runs/16983348064/job/48147611727#step:11:28

Corey Ostrove added 2 commits August 15, 2025 12:26
Streamline the tests for the error generator propagation module by reducing the number of test cases for a number of the tests and replacing exhaustive testing with randomized selections.
By adding a conditional import of stim when type checking.
@coreyostrove
Copy link
Contributor Author

@nkoskelo or @rileyjmurray: How do I avoid this linting error for these type annotations? https://github.com/sandialabs/pyGSTi/actions/runs/16983348064/job/48147611727#step:11:28

Update: I added a conditional import to the top of the file and that resolved this.

if TYPE_CHECKING:
    import stim

Where the type checking flag is provided by the typing module.

Resolve a circular import error from new type annotation.
Update the inline comment styling per Riley's request.
@coreyostrove coreyostrove merged commit 850623c into develop Aug 17, 2025
4 checks passed
@coreyostrove coreyostrove deleted the feature-magnus-expansions branch August 17, 2025 00:38
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.

3 participants