[FEATURE] Decompose `p`, `phaseshift` and `u1` as `rz` instead of `h; rx; h`
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #470 @tonycoder-hub による — マージ済み
評価
調査の方向性
Start with phaseshift_gate and ONE_QUBIT_ROTATION_MAP in src/pyqasm/maps/gates.py, then read the phaseshift-gate section of docs/gate_decompositions.md and inspect the existing decomposition tests. Verify single-gate unrolling and the CLIFFORD_T rebases for p(pi/4) and p(pi/2). Run the unitary checks for the changed decomposition, including csx and rccx, and confirm they match up to global phase.
索引モデルが issue の本文から書いたものです。
説明
Feature Description
unroll decomposes p, phaseshift and u1 into three gates, h; rx(θ); h. A single rz(θ) gives the same gate up to a global phase. The longer form then grows during rebase, because each h expands again:
| Input | Basis | Output on main |
Output for the same gate written as rz |
|---|---|---|---|
p(0.3) q[0]; |
ROTATIONAL_CX |
5 gates: ry(π/2); rx(π); rx(0.3); ry(π/2); rx(π) |
rz(0.3) |
p(pi/4) q[0]; |
CLIFFORD_T |
5 gates: h; h; t; h; h |
t |
p(pi/2) q[0]; |
CLIFFORD_T |
5 gates: h; h; s; h; h |
s |
Reproduction on main at a742796, Python 3.12:
import pyqasm
from pyqasm.elements import BasisSet
src = 'OPENQASM 3.0;\ninclude "stdgates.inc";\nqubit[1] q;\np(pi/4) q[0];\n'
m = pyqasm.loads(src)
m.rebase(BasisSet.CLIFFORD_T)
print(pyqasm.dumps(m)) # h q[0]; h q[0]; t q[0]; h q[0]; h q[0];
OpenQASM 2 programs that use qelib1.inc unroll p and u1 the same way.
The decomposition is phaseshift_gate. ONE_QUBIT_ROTATION_MAP maps u1, U1, phaseshift and p to it. The csx and rccx decompositions also call it seven times in total.
A related point: #468 adds a p rule to rebase. Unroll rewrites a p gate written by the user before rebase sees it, so that rule only applies to the p gates that pyqasm generates itself.
Done when:
- A single
p(θ),phaseshift(θ)oru1(θ)unrolls to one gate. - Under
CLIFFORD_T,p(pi/4)rebases totandp(pi/2)rebases tos. - The unitary of each changed decomposition, including
csxandrccx, still matches the original up to a global phase.
Implementation (Optional)
One option is to make phaseshift_gate emit rz(θ). gate_decompositions.md documents the current form and needs the same update. rz(θ) and p(θ) differ only by a global phase. That should be safe here, because ctrl @ p resolves to cp before this decomposition runs. This reasoning is not verified against the full test suite.
- 主要言語
- Python
- スター
- 29
- フォーク
- 33
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 16
環境構築
- 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 が 17 日前に担当しました。 オープン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 が 26 日前に担当しました。 オープン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 が 19 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 22/100
qBraid/pyqasm#436 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
BCDA-APS/polar-bits#93 ·
-
infer_audio_type only recognises one MPEG Layer III frame header, so most MP3 files are rejected対応中かも @Steve-20-ai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[BUG] - ssh_config `Match tagged` statement always applies対応中かも @AtharvRG が今日担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
paramiko/paramiko#2715 · コメント 1 件 ·
メンテナーはふだん 9 日以内に返信
-
auto-rejected intake mcp-intake needs-salvage priority:high type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Ikalus1988/MisakaNet#4221 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信