unroll() ignores inv @ on decomposed gates (cphaseshift, cv, pswap)
维护者通常 1 天内回复
评估
调研方向
The bug is in unroll() in pyqasm, which drops the inv @ modifier when decomposing cphaseshift, cv and pswap. Start by reproducing with the snippet in the issue, then find where the decomposition of these gates is emitted and how modifiers are passed through. Done when inv @ G unrolls to the reversed, individually inverted decomposition for these three gates, and a test pins the negated rz/rx angles.
由索引模型根据 Issue 内容生成。
描述
Problem
unroll() drops the inv @ modifier on gates it decomposes, so the inverse comes out as the original gate. Seen with pyqasm 1.3.0 on cphaseshift, cv and pswap.
import pyqasm
for line in ["inv @ cphaseshift(0.5) q[0], q[1];", "cphaseshift(-0.5) q[0], q[1];"]:
m = pyqasm.loads(f"OPENQASM 3.0;\nqubit[2] q;\n{line}")
m.unroll(external_gates=["cnot"])
print(line, "->", " ".join(pyqasm.dumps(m).splitlines()[2:4]))
inv @ cphaseshift(0.5) q[0], q[1]; -> rz(0.25) q[0]; ...
cphaseshift(-0.5) q[0], q[1]; -> rz(-0.25) q[0]; ...
The unrolled inv @ cphaseshift(0.5) is identical to cphaseshift(0.5). inv @ pswap(0.5) likewise unrolls with rz(0.5), and inv @ cv with rx(0.785…) where rx(-0.785…) is expected. No error is raised, so the program silently gets the wrong unitary. qBraid's Braket→OpenQASM 3→Qiskit route hit this (worked around in qBraid/qBraid#1533 by writing negative powers as the gate's adjoint).
Expected
inv @ G unrolls to the inverse of G's decomposition (reversed order, each gate inverted), or raises if that isn't supported.
- 主要语言
- Python
- 星标
- 29
- 派生
- 33
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
qBraid/pyqasm 的其他 Issue
-
dumps() prints the original program when unroll() leaves at most one statement可能已有人在做 @ShiveshDragon 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
维护者通常 1 天内回复
-
enhancement error-handling program-validation
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 43/100
维护者通常 1 天内回复
-
dependencies enhancement
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
docs(contributing): the two things that silently block a PR可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭available documentation good first issue
难度 1/5 1-3 小时 新手友好度 95/100
Nixitov/Riptide-Native#944 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
JTHCode/secretguard#24 ·
维护者通常 1 天内回复
-
area: middleware documentation good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
omarelshamy25x/shamy-hijri#63 ·
维护者通常 1 天内回复