`extern port` / `extern frame` in `cal` blocks fail to parse, blocking nearly every spec OpenPulse example
Maintainers usually reply within 1 day
@Riiocodee is already working on this.
Since Oct 19, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- compilers, quantum-computing
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 29
- Forks
- 33
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from qBraid/pyqasm
-
dumps() prints the original program when unroll() leaves at most one statementPossibly taken @ShiveshDragon claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
qBraid/pyqasm#493 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
enhancement error-handling program-validation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 43/100
Maintainers usually reply within 1 day
-
dependencies enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
nolte/kamerplanter#3193 ·
Maintainers usually reply within 1 day
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day