Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[BUG] Missing `ccx` decomposition in `rebase` for `ROTATIONAL_CX` and `CLIFFORD_T`

已关闭
#467 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #468 来自 @tonycoder-hub —— 已合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
57/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend, compilers

调研方向

Start with decomposition_rules.py and trace how rebase handles ccx, c3x, id, and p for the ROTATIONAL_CX and CLIFFORD_T bases; the issue reports that unroll retains ccx. Add regression coverage for the reported gates and run the project tests. Done when the requested gates rebase successfully and the regressions pass.

由索引模型根据 Issue 内容生成。

描述

bug
Environment
  • pyqasm version: 1.3.0 (also main at 62b012e)
  • Python version: 3.11.16
  • OS: Ubuntu 22.04.5 LTS (WSL2)
What happened?

rebase(BasisSet.ROTATIONAL_CX) and rebase(BasisSet.CLIFFORD_T) raise RebaseError on a program with a single ccx. validate() and unroll() accept the same program, and the unrolled program still contains the ccx.

How can we reproduce the issue?
import pyqasm
from pyqasm.elements import BasisSet

module = pyqasm.loads("""OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
ccx q[0], q[1], q[2];
""")
module.validate()
module.rebase(BasisSet.ROTATIONAL_CX)

Output:

pyqasm.exceptions.RebaseError: Gate 'ccx' is not supported in the 'BasisSet.ROTATIONAL_CX set'.

The user guide says there is "complete conversion support for the BasisSet.ROTATIONAL_CX basis set". When we tried every qelib1 gate on its own, ROTATIONAL_CX rejected three of them: ccx, id, and c3x (reported as Gate 'p' is not supported). Interestingly, cswap can be rebased successfully because it is already expanded into simpler gates, whereas ccx remains as a single gate after unrolling.

What should happen?

ccx should be decomposed into both ROTATIONAL_CX and CLIFFORD_T, while c3x should be decomposed into ROTATIONAL_CX. The id gate can simply be removed in either case.

Suggestions (Optional)

The issue appears to come from missing decomposition rules in decomposition_rules.py. ccx is retained by unroll, while c3x is expanded into gates including p, which is also missing from the target basis and decomposition rules.

One possible fix is to add the missing rules for ccx, id, and p, along with support for selecting a third qubit in the decomposition rules.

We prototyped this approach. The resulting circuits match their original unitaries up to global phase, all 1,011 existing tests pass, and five new regression tests fail before the change and pass afterward.

主要语言
Python
星标
29
派生
33
平均合并
1 天 22 小时
30 天内合并 PR
15

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

qBraid/pyqasm 的其他 Issue

查看 qBraid/pyqasm 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。