Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`extern port` / `extern frame` in `cal` blocks fail to parse, blocking nearly every spec OpenPulse example

オープン
#401 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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 の本文から書いたものです。

説明

bug llm-assisted qasm3 qasm3-coverage

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

  1. Open an issue on openqasm/openqasm against the
    openpulse Python package, with the reproducer above, and link it back here.
  2. Once fixed upstream, raise the openpulse floor in the pulse extra in pyproject.toml
    and add the spec examples as test fixtures.
  3. 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.
  4. Decide whether to carry a temporary workaround — see below.

Implementation Details

  • The pulse path is src/pyqasm/pulse/; cal / defcal bodies are handed to
    openpulse.parser.parse_openpulse, and the error above is re-raised from there. The
    pulse extra pins openpulse>=1.0.1 in pyproject.toml.
  • Possible interim workaround: strip a leading extern from port / frame declarations
    before handing the body to the parser, then mark the resulting symbol as externally provided
    in pyqasm'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 openpulse release 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
    xfail with a reference to the upstream issue so they flip to passing automatically when the
    dependency is bumped.
主要言語
Python
スター
29
フォーク
33
平均マージ
2日 4時間
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

qBraid/pyqasm のほかの issue

qBraid/pyqasm の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。