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

Integer overflow when creating circuits from QASM files with large ints #12773

Closed
nonhermitian opened this issue Jul 15, 2024 · 1 comment · Fixed by #12774
Closed

Integer overflow when creating circuits from QASM files with large ints #12773

nonhermitian opened this issue Jul 15, 2024 · 1 comment · Fixed by #12774
Labels
bug Something isn't working mod: qasm2 Relating to OpenQASM 2 import or export

Comments

@nonhermitian
Copy link
Contributor

nonhermitian commented Jul 15, 2024

Environment

  • Qiskit version: 1.1.1
  • Python version:
  • Operating system:

What is happening?

As reported Qiskit/benchpress#17, qasm imports lead to int overflows when qasm files contain large ints. E.g. this example will fail

OPENQASM 2.0;
include "qelib1.inc";
qreg q0[301];
creg c0[301];
h q0[300];
measure q0[300] -> c0[300];
if(c0==2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376) h q0[0];

with

thread '<unnamed>' panicked at crates/qasm2/src/lex.rs:279:42:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PanicException: called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }

How can we reproduce the issue?

Run the above QASM file with QuantumCircuit.from_qasm_file

What should happen?

It should be imported

Any suggestions?

The int is larger than int64, which I assume is the root cause.

@nonhermitian nonhermitian added the bug Something isn't working label Jul 15, 2024
@jakelishman jakelishman added the mod: qasm2 Relating to OpenQASM 2 import or export label Jul 15, 2024
@jakelishman
Copy link
Member

Thanks for the report. That's a pretty gross case. We fixed much of this in #12140, but this exact one implies we might need big-int handling in Rust space, if not now (we can hack around while we're still using Python space) then later just to represent huge classical register conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: qasm2 Relating to OpenQASM 2 import or export
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants