Skip to content

Removing Trotter pitfalls#740

Merged
TysonRayJones merged 10 commits intodevelfrom
trotter-random-via-indices
May 7, 2026
Merged

Removing Trotter pitfalls#740
TysonRayJones merged 10 commits intodevelfrom
trotter-random-via-indices

Conversation

@TysonRayJones
Copy link
Copy Markdown
Member

No description provided.

since it is TERMS that are actually permuted (both coef and string)
so that tempAlloc can be used for a generic allocation failure
and overhauled pauli reordering logic to avoid superfluous subroutines which had hidden vector creation and copy overheads
@TysonRayJones TysonRayJones marked this pull request as draft May 3, 2026 21:07
@TysonRayJones
Copy link
Copy Markdown
Member Author

TysonRayJones commented May 3, 2026

Not yet implemented: changing Trotter functions to consult & permute an index list

@TysonRayJones TysonRayJones marked this pull request as ready for review May 5, 2026 02:08
@TysonRayJones
Copy link
Copy Markdown
Member Author

@vaferreiQMT @otbrown Any objections to this? The parts worthy of explicit consideration are:

  • renamed permutePaulis to permuteTerms, since it's not the "Paulis" that are permuted; it is entire terms (Pauli strings and their corresponding coefficients).
  • removed unguarded allocs from pauli reordering which removes util_getInversePermutation and paulis_applyPermutationToTerms, doing everything directly inside paulis_sortTermsViaComparator. This is because the former approach caused non-obvious temporary copies of the sum.
  • I kept sortPauliStrSumLexicographic() and sortPauliStrSumMagnitude(), though their "obvious" utility has now been removed (which was restoring a concrete ordering after random permutation in the Trotter functions). I think sortPauliStrSumMagnitude() remains useful however, since useful for significance sampling.
  • rand_permutePauliStrSum() was removed since it is now no longer called anywhere. In theory, we can retain it and expose a new randomizePauliStrSumOrder() API function for the user, but I shied from this since it doesn't seem to have much utility: randomisation only benefits the Trotter functions, which accept permuteTerms. I suppose it would be just as useful as sortPauliStrSumLexicographic(); as an alternative to sortPauliStrSumMagnitude() for testing the relative benefits of sorting by magnitude. Any strong thoughts??

@vaferreiQMT
Copy link
Copy Markdown

All looks reasonable to me. I also think that sortPauliStrSumMagnitude() is worth keeping, but I don't mind getting rid of rand_permutePauliStrSum() since I agree that it likely wouldn't be of particular use for most users beyond comparing the impact of different sorting methods.

@TysonRayJones TysonRayJones merged commit e8eec97 into devel May 7, 2026
130 checks passed
@TysonRayJones TysonRayJones deleted the trotter-random-via-indices branch May 7, 2026 00:02
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