`pow(k) @` modifier rejects non-integer exponents
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- python
調査の方向性
Start with the power-modifier check near src/pyqasm/visitor.py:1627, where the integer-only validation and the existing negative-integer inversion live. Then look at src/pyqasm/linalg.py and src/pyqasm/decomposer.py to see how a single-qubit matrix is turned into U(θ, φ, λ). Done means pow(0.5) @ x matches the sx matrix, pow(0.25) @ x and pow(1.5) @ z work, and unsupported multi-qubit or runtime-valued exponents raise a named ValidationError, with tests in tests/qasm3/test_gate.py.
索引モデルが issue の本文から書いたものです。
説明
Limitation
The power modifier is defined as: "The modifier
pow(k) @ replaces its gate argument U by its kth power U^k for some positive integer
or floating point number k (not necessarily constant)."
pyqasm requires k to be an integer and rejects everything else.
Example QASM failure
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
pow(0.5) @ x q[0];
ValidationError: Power modifier argument must be an integer in gate operation QuantumGate(...)
Integer exponents, including negative ones, work today:
pow(2) @ x q[0]; // OK
pow(-1) @ x q[0]; // OK
so the restriction is specifically on the fractional case — which is the interesting one, since
pow(0.5) @ x is the square root of X.
Change Requested
- Accept a floating-point
kinpow(k) @. - For a fractional
k, the repeat-the-gate expansion used for integers does not apply. The
unrolled result must be computed from the gate's matrix as U^k via matrix power — the
principal branch, matching the spec's definition. - Where a fractional power of a gate has a known closed form in the standard library, prefer
emitting that named gate over a synthesisedU(θ, φ, λ). For examplepow(0.5) @ xis
sx. - If a fractional power cannot be realised for a given gate, raise a
ValidationErrornaming
the gate and the exponent — not the current blanket "must be an integer".
Implementation Details
- The rejection is at
src/pyqasm/visitor.py:1627. The surrounding block already handles
negative integers by inverting and repeating, so the integer path is a useful reference for
where the fractional branch belongs. src/pyqasm/linalg.pyand the Cythonsrc/pyqasm/accelerate/linalg.pyxalready provide the
matrix machinery used by the decomposer; a matrix power via eigendecomposition fits there
rather than in the visitor.- The single-qubit result can be routed through the existing ZYZ /
U(θ, φ, λ)decomposition
insrc/pyqasm/decomposer.py, so the fractional case reduces to "compute the matrix, then
decompose" and reuses tested code. - Decide the multi-qubit policy explicitly. A fractional power of a two-qubit gate is well
defined mathematically but expensive to synthesise; rejecting it with a clear message is a
reasonable first increment, provided the message says so. - The spec's "not necessarily constant" clause implies a runtime-valued exponent. That cannot
be resolved during unrolling and is out of scope here — reject it with a specific message. - Tests:
tests/qasm3/test_gate.py—pow(0.5) @ xagainst thesxmatrix,pow(0.25) @ x,
pow(1.5) @ z, a fractional power underctrl @, and a clear error for the unsupported
multi-qubit case.
- 主要言語
- Python
- スター
- 29
- フォーク
- 33
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 が 7 日前に担当しました。 オープンenhancement qasm2
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
qBraid/pyqasm#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM対応中かも @Jah-yee が 15 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
qBraid/pyqasm#438 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost対応中かも @tonycoder-hub が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 22/100
qBraid/pyqasm#436 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
521xueweihan/HelloGitHub#4063 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws-samples/sample-per-model-bedrock#409 ·
メンテナーはふだん 1 日以内に返信
-
DuckDB 2.0 breaks to_pyarrow_batches対応中かも @DG47 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ibis-project/ibis#12196 ·
メンテナーはふだん 1 日以内に返信