`extern port` / `extern frame` in `cal` blocks fail to parse, blocking nearly every spec OpenPulse example
维护者通常 1 天内回复
@Riiocodee 已经在做这个了。
开始于 2026年10月19日。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- python
调研方向
Start in src/pyqasm/pulse/, where cal bodies go to openpulse.parser.parse_openpulse, and reproduce the extern port d0; failure with the openpulse parse call from the issue. The workaround in src/pyqasm/pulse/frame.py and the openpulse>=1.0.1 pin in the pulse extra of pyproject.toml need a maintainer decision first. Done means the surfaced error names the upstream limitation and the spec examples are added as xfail fixtures.
由索引模型根据 Issue 内容生成。
描述
Limitation
The OpenPulse chapter declares ports and frames provided by
the backend with extern:
extern port d0;
extern frame d0f;
This is the standard idiom — the Ports and
Frames sections use it, and so does essentially every
worked example in the chapter, along with
Calibrations in practice.
Every one of them fails in pyqasm.
Example QASM failure
OPENQASM 3.0;
defcalgrammar "openpulse";
cal {
extern port d0;
frame d0f = newframe(d0, 5.0e9, 0.0);
}
ValidationError: Failed to parse OpenPulse string: Unexpected token 'port' at line 4, column 11.
OPENQASM 3.0;
defcalgrammar "openpulse";
cal { extern frame m0f; }
defcal measure $0 -> bit {
return capture_v2(m0f, 2048ns);
}
// ValidationError: Failed to parse OpenPulse string: Unexpected token 'frame' at line 3, column 8.
Without extern, the same declarations parse:
cal {
port d0; // OK
frame f = newframe(d0, 5.0e9, 0.0); // OK
}
Root cause — upstream
This is not a defect in pyqasm's own code. The openpulse 1.0.1 parser rejects it
directly:
>>> from openpulse import parse
>>> parse('OPENQASM 3.0;\ncal {\n extern port d0;\n}\n')
openpulse.parser.OpenPulseParsingError: Unexpected token 'port' at line 2, column 10.
>>> parse('OPENQASM 3.0;\ncal {\n extern frame d0f;\n}\n')
openpulse.parser.OpenPulseParsingError: Unexpected token 'frame' at line 2, column 10.
The externDeclaration production accepts only classical types as parameters, so the
port / frame keywords are unexpected there.
Filing it here because the user-visible effect is that pyqasm cannot analyse the spec's pulse
examples, and because the fix needs tracking and a version bound on our side.
Change Requested
- Open an issue on
openqasm/openqasmagainst the
openpulsePython package, with the reproducer above, and link it back here. - Once fixed upstream, raise the
openpulsefloor in thepulseextra inpyproject.toml
and add the spec examples as test fixtures. - Until then, improve the error surfaced to users.
"Failed to parse OpenPulse string: Unexpected token 'port'"gives no indication that this is a known upstream limitation
rather than a mistake in their program. - Decide whether to carry a temporary workaround — see below.
Implementation Details
- The pulse path is
src/pyqasm/pulse/;cal/defcalbodies are handed to
openpulse.parser.parse_openpulse, and the error above is re-raised from there. The
pulseextra pinsopenpulse>=1.0.1inpyproject.toml. - Possible interim workaround: strip a leading
externfromport/framedeclarations
before handing the body to the parser, then mark the resulting symbol as externally provided
inpyqasm's own frame/port table (src/pyqasm/pulse/frame.py).port d0;and
frame f = newframe(...);already parse, so the rewrite is narrow. It is a text-level
workaround and should be gated behind a clear comment and removed once upstream lands —
maintainer call on whether that trade is worth it. - Verify against the latest
openpulserelease before filing upstream; this was reproduced on
1.0.1. - Tests: add the spec's Ports, Frames and Calibrations-in-practice examples as fixtures, marked
xfailwith a reference to the upstream issue so they flip to passing automatically when the
dependency is bumped.
- 主要语言
- Python
- 星标
- 29
- 派生
- 33
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 15
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
qBraid/pyqasm 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 63/100
维护者通常 1 天内回复
-
enhancement error-handling program-validation
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.py可能已有人在做 @danielgaskins 于 9 天前认领。 未关闭enhancement qasm2
难度 4/5 3-5 天 新手友好度 22/100
维护者通常 1 天内回复
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM可能已有人在做 @Jah-yee 于 18 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 1 天内回复
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost可能已有人在做 @tonycoder-hub 于 11 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 22/100
维护者通常 1 天内回复
相似的 Issue
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
难度 2/5 1-3 小时 新手友好度 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 70/100
NCAR/miles-credit#526 ·
-
documentation
难度 1/5 1-3 小时 新手友好度 76/100
conda/conda-lock#957 ·
维护者通常 1 天内回复
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
aws-samples/sample-per-model-bedrock#464 ·
维护者通常 1 天内回复