Moderately increase speed of compute_cost in sabre
Summary
This commit modies the heuristic scoring function compute_cost in the sabre swap rust code to use a faster sum implementation. This is based on the fast_sum() used in the pauli expectation value module but modified to deal with the different data structures used in sabre. This new implementation enables the compiler to more easily use SIMD when available. This is about as fast as we can make a sume of values of indeterminite length without dropping to use SIMD intrinsics directly, either for x86/x86_64 with an unsafe calls (via the simdeez library) or requiring nightly rust and using packed_simd_2 or stdsimd which is cross platform. While this isn't a huge performance boost, it does provide a 1-10% speed up to compute cost in local testing.
Details and comments
Thank you for opening a new pull request.
Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.
While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.
One or more of the the following people are requested to review this:
- @Qiskit/terra-core
- @kevinhartman
- @mtreinish
Pull Request Test Coverage Report for Build 3107389202
- 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.006%) to 84.409%
| Totals | |
|---|---|
| Change from base Build 3106018719: | 0.006% |
| Covered Lines: | 59281 |
| Relevant Lines: | 70231 |
💛 - Coveralls
I ran asv on this and none of the benchmarks showed an improvement or regression beyond system noise. I did see up to a 10% improvement doing local testing with some quick scripts I threw together, but maybe that was more system noise than the code change. If other people want to try this to see if it makes a difference for them that would be good. In the meantime I'll take a look at the assembly to see what the difference is if any.
I'm just going to close this, it didn't really make a difference in testing and the code for sabre has changed quite a bit in the ~2 months since I first wrote this.