Closed MattePalte closed 1 month ago
Thanks for raising this issue! This is definitely an issue. The underlying problem is that the parser interprets "ms" as a time unit parser token for milliseconds. So the parser expects an identifier after the "gate" token, but gets a TimeUnit token, which is what triggers the error.
AFAIK, "ms" is not a reserved keyword in OpenQASM 2, but it is used in OpenQASM 3 for specifying delays and durations.
Could you maybe check if Qiskit's OpenQASM 3 exporter also yields an "ms" gate declaration? (You just need to change the qasm2
to qasm3
in your code).
By the way: if you work in Qiskit anyways, you can always just pass the Qiskit circuits directly to QCEC instead of the QASM files. Our Qiskit parser should work out of the box in that regard even if the gate is called "ms".
I'll try to see what I can do to address the underlying issue in the parser.
Alright, the underlying error was mainly due to how we previously handled timing literals. #724 fixes this. Thanks for bringing this up 🙏🏼
Environment information
Description
The
ms
gate is not correctly parsed by mqt-core, resulting in aRuntimeError
when trying to verify or parse the circuit.Expected behavior
The
ms
gate should be correctly parsed by mqt-core, as it is valid and can be created by Qiskit. A similar circuit parses without issue in Qiskit.How to Reproduce
Steps to Reproduce
ms
gate.qasm2.dumps()
function.Example Code Snippet
Create a circuit with Qiskit that includes the
ms
gate.Export the circuit to OpenQASM.
Attempt to verify the circuit using mqt-core.
Error Produced
Alternatively, using the
mqt.core
library directly, withoutmqt.qcec
, also results in the same error.However, the same circuit can be parsed without issue using Qiskit's
qasm
module.Output:
Possible Problem
The issue seems to be related to the parsing of the
ms
gate. The error message indicates the problem occurs whenms
is used, suggesting that the parser might be incorrectly handling this gate's name. This could be due to the parser's check for expected tokens inmqt-core/include/mqt-core/ir/parsers/qasm3_parser/Scanner.hpp
.