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

Handle huge integers in OpenQASM 2 expression evaluator (backport #12140) #12401

Merged
merged 1 commit into from
May 14, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented May 14, 2024

Summary

This modifies the expression evaluator to directly parse the backing string data of an integer token in a floating-point context, which lets us handle numbers that would otherwise overflow a usize. It's possible for this to be totally valid, if, for example, the integer is a multiple of some very large power of two that doesn't overflow a double-precision float.

We already needed to immediately cast the integer to a float, so this is just a more accurate way of doing the evaluation, and doesn't affect when we use integers in other contexts.

Details and comments

Fix #11561


This is an automatic backport of pull request #12140 done by [Mergify](https://mergify.com).

* Handle huge integers in OpenQASM 2 expression evaluator

This modifies the expression evaluator to directly parse the backing
string data of an integer token in a floating-point context, which lets
us handle numbers that would otherwise overflow a `usize`.  It's
possible for this to be totally valid, if, for example, the integer is a
multiple of some very large power of two that doesn't overflow a
double-precision float.

We already needed to immediately cast the integer to a float, so this is
just a more accurate way of doing the evaluation, and doesn't affect
when we use integers in other contexts.

* Clarify int/float split

(cherry picked from commit fe69594)
@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:

@github-actions github-actions bot added Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qasm2 Relating to OpenQASM 2 import or export labels May 14, 2024
@github-actions github-actions bot added this to the 1.1.0 milestone May 14, 2024
@jakelishman jakelishman modified the milestones: 1.1.0, 0.46.2 May 14, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 9082848530

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 2 files are covered.
  • 22 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.007%) to 86.86%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/sabre_swap/mod.rs 1 97.52%
crates/qasm2/src/lex.rs 3 92.88%
crates/qasm2/src/parse.rs 18 96.23%
Totals Coverage Status
Change from base Build 8848773890: -0.007%
Covered Lines: 74993
Relevant Lines: 86338

💛 - Coveralls

@jakelishman jakelishman added this pull request to the merge queue May 14, 2024
Merged via the queue into stable/0.46 with commit 5c927a8 May 14, 2024
12 of 14 checks passed
@mergify mergify bot deleted the mergify/bp/stable/0.46/pr-12140 branch May 14, 2024 19:19
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: qasm2 Relating to OpenQASM 2 import or export
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants