Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use float-epsilon calculation in Sabre best scores #9117

Merged
merged 2 commits into from
Nov 14, 2022

Conversation

jakelishman
Copy link
Member

Summary

This should not meaningfully affect any small-scale outputs, but at larger scales, there are floating-point instabilities that can make the "best swaps" set miss swaps that are logically at the same score as others. This does not (cannot) fully stabilise us against all minor floating-point rounding errors in calculations; the order of iteration through the swaps can still technically change the swap set, for example if three swaps with relative differences {0, 0.8, 1.6} * BEST_EPSILON are encountered in a different orders. The float epsilon is chosen to be significantly larger than the actual magnitude of fluctuations, and significantly smaller than the changes caused by all the actual components of scoring, in order to mitigate this effect.

Details and comments

This detail is (to the best of my knowledge), the only reason that #9012 broke RNG compatibility in large circuits with the previous Rust version.

Tagging "bugfix" for the more developer-facing GitHub release notes, but there's no specific note for this in the public documentation; that will come with a later PR.

@jakelishman jakelishman added Changelog: Bugfix Include in the "Fixed" section of the changelog Rust This PR or issue is related to Rust code in the repository mod: transpiler Issues and PRs related to Transpiler labels Nov 10, 2022
@jakelishman jakelishman requested a review from a team as a code owner November 10, 2022 17:49
@qiskit-bot
Copy link
Collaborator

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:

This should not meaningfully affect any small-scale outputs, but at
larger scales, there are floating-point instabilities that can make the
"best swaps" set miss swaps that are logically at the same score as
others.  This does not (cannot) fully stabilise us against all minor
floating-point rounding errors in calculations; the order of iteration
through the swaps can still technically change the swap set, for example
if three swaps with relative differences `{0, 0.8, 1.6} * BEST_EPSILON`
are encountered in a different orders.  The float epsilon is chosen to
be significantly larger than the actual magnitude of fluctuations, and
significantly smaller than the changes caused by all the actual
components of scoring, in order to mitigate this effect.
@coveralls
Copy link

coveralls commented Nov 10, 2022

Pull Request Test Coverage Report for Build 3463181611

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 84.606%

Totals Coverage Status
Change from base Build 3463180100: 0.0%
Covered Lines: 62617
Relevant Lines: 74010

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

LGTM, seems straightforward enough

@mergify mergify bot merged commit 9270868 into Qiskit:main Nov 14, 2022
@jakelishman jakelishman deleted the sabre/epsilon-compare branch November 14, 2022 21:16
Cryoris pushed a commit to Cryoris/qiskit-terra that referenced this pull request Jan 12, 2023
This should not meaningfully affect any small-scale outputs, but at
larger scales, there are floating-point instabilities that can make the
"best swaps" set miss swaps that are logically at the same score as
others.  This does not (cannot) fully stabilise us against all minor
floating-point rounding errors in calculations; the order of iteration
through the swaps can still technically change the swap set, for example
if three swaps with relative differences `{0, 0.8, 1.6} * BEST_EPSILON`
are encountered in a different orders.  The float epsilon is chosen to
be significantly larger than the actual magnitude of fluctuations, and
significantly smaller than the changes caused by all the actual
components of scoring, in order to mitigate this effect.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: transpiler Issues and PRs related to Transpiler Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants