Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.25k stars 2.37k forks source link

Unable to load QASM 3 with openpulse grammar. #12960

Open keriksson-rosenqvist opened 3 months ago

keriksson-rosenqvist commented 3 months ago

Environment

What is happening?

Attempting to qasm3.loads(<qasm_string>) when the sting includes openpulse segments fails with errors as below:

defcalgrammar "openpulse";       ->    node of type CalibrationGrammarDeclaration is not supported

cal {....}                       ->    node of type CalibrationStatement is not supported

defcal {....}                    ->    node of type CalibrationDefinition is not supported

How can we reproduce the issue?

from qiskit import qasm3

qasm = """OPENQASM 3;
include "stdgates.inc";
defcalgrammar "openpulse";
bit[2] c;
"""

qasm3.loads(qasm)

What should happen?

There should be a way to load QASM 3 including the openpulse grammar. If not through qasm3.loads then with some other documented approach.

Any suggestions?

No response

jakelishman commented 3 months ago

Qiskit has no support for OpenPulse, and we currently have no plan to add support for it. You're welcome to write your own library (see https://github.com/openqasm/openpulse-python for a functional parser to an AST), but Pulse development in Qiskit itself is currently somewhat on hold.

keriksson-rosenqvist commented 3 months ago

Thank you for the information and link. I will see if that can be used to resolve my issue.

For reference this became an issue when the new version of Qiskit dropped the qasm -> AST feature set as we have previously been able to achieve the functionality by extending that parser. If there is another way to hook into the v.046 QasmParser in >= v1.0.0 I'd love to know.

jakelishman commented 3 months ago

The "QASM -> AST" thing was for OpenQASM 2, whereas OpenPulse is a calibration grammar for OpenQASM 3. The equivalent (and much easier) strategy for you is probably to use https://github.com/openqasm/openpulse-python like I linked above.