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

Fix parsing of huge OpenQASM 2 conditionals #12774

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

jakelishman
Copy link
Member

Summary

We fixed handling of giant integers in gate expression positions gh-12140, and this commit fixes the handling in conditionals. Unfortunately, this means pulling in big-int handling properly; the integers simply are bigints, and we're not immediately converting them into something else.

The need to support this may influence how the Rust-space data models of QuantumCircuit evolve.

Details and comments

Fix #12773

We fixed handling of giant integers in gate expression positions
Qiskitgh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.
@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qasm2 Relating to OpenQASM 2 import or export labels Jul 15, 2024
@jakelishman jakelishman added this to the 1.1.2 milestone Jul 15, 2024
@jakelishman jakelishman requested a review from a team as a code owner July 15, 2024 11:17
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core
  • @kevinhartman
  • @mtreinish

@coveralls
Copy link

coveralls commented Jul 15, 2024

Pull Request Test Coverage Report for Build 10161788997

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 12 of 13 (92.31%) changed or added relevant lines in 2 files are covered.
  • 1014 unchanged lines in 72 files lost coverage.
  • Overall coverage decreased (-0.1%) to 89.765%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/qasm2/src/lex.rs 5 6 83.33%
Files with Coverage Reduction New Missed Lines %
qiskit/qobj/common.py 1 95.83%
qiskit/circuit/library/standard_gates/swap.py 1 98.21%
qiskit/primitives/backend_sampler.py 1 98.86%
qiskit/circuit/duration.py 1 70.27%
crates/accelerate/src/synthesis/permutation/utils.rs 1 99.02%
qiskit/circuit/library/standard_gates/rxx.py 1 97.87%
qiskit/transpiler/passes/layout/sabre_pre_layout.py 1 98.88%
crates/qasm2/src/lex.rs 1 92.23%
qiskit/primitives/base/base_sampler.py 1 96.97%
qiskit/circuit/random/utils.py 1 94.87%
Totals Coverage Status
Change from base Build 9917090942: -0.1%
Covered Lines: 66961
Relevant Lines: 74596

💛 - 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.

This LGTM it's a pretty straightforward change, and you pre-empted my question about using u128 as a short term bandaid with your unit tests. :) Just one inline comment about the cargo config, but that's small.

crates/qasm2/Cargo.toml Outdated Show resolved Hide resolved
@mtreinish mtreinish enabled auto-merge July 30, 2024 11:54
@jakelishman
Copy link
Member Author

@Mergifyio backport stable/1.1

Copy link
Contributor

mergify bot commented Jul 30, 2024

backport stable/1.1

✅ Backports have been created

@mtreinish mtreinish added this pull request to the merge queue Jul 30, 2024
Merged via the queue into Qiskit:main with commit 85f9860 Jul 30, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Jul 30, 2024
* Fix parsing of huge OpenQASM 2 conditionals

We fixed handling of giant integers in gate expression positions
gh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.

* Move `num-bigint` dependency to workspace

(cherry picked from commit 85f9860)

# Conflicts:
#	Cargo.toml
#	crates/accelerate/Cargo.toml
mergify bot pushed a commit that referenced this pull request Jul 30, 2024
* Fix parsing of huge OpenQASM 2 conditionals

We fixed handling of giant integers in gate expression positions
gh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.

* Move `num-bigint` dependency to workspace

(cherry picked from commit 85f9860)
@jakelishman jakelishman deleted the qasm2/bigint-condition branch July 30, 2024 14:24
jakelishman added a commit that referenced this pull request Jul 30, 2024
* Fix parsing of huge OpenQASM 2 conditionals

We fixed handling of giant integers in gate expression positions
gh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.

* Move `num-bigint` dependency to workspace

(cherry picked from commit 85f9860)
github-merge-queue bot pushed a commit that referenced this pull request Jul 30, 2024
* Fix parsing of huge OpenQASM 2 conditionals

We fixed handling of giant integers in gate expression positions
gh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.

* Move `num-bigint` dependency to workspace

(cherry picked from commit 85f9860)

Co-authored-by: Jake Lishman <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jul 30, 2024
* Fix parsing of huge OpenQASM 2 conditionals

We fixed handling of giant integers in gate expression positions
gh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.

* Move `num-bigint` dependency to workspace

(cherry picked from commit 85f9860)

Co-authored-by: Jake Lishman <[email protected]>
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
* Fix parsing of huge OpenQASM 2 conditionals

We fixed handling of giant integers in gate expression positions
Qiskitgh-12140, and this commit fixes the handling in conditionals.
Unfortunately, this means pulling in big-int handling properly; the
integers simply _are_ bigints, and we're not immediately converting them
into something else.

The need to support this may influence how the Rust-space data models of
`QuantumCircuit` evolve.

* Move `num-bigint` dependency to workspace
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 priority: high stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integer overflow when creating circuits from QASM files with large ints
5 participants