Skip to content

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

@nonhermitian

Description

@nonhermitian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmod: qasm2Relating to OpenQASM 2 import or export

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions