[FEATURE] Implement a `.merge` method for `QasmModule`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with the existing QasmModule class and its .unroll(device_qubits) method, since the merge depends on how they consolidate registers into __PYQASM_QUBITS__ and __PYQASM_CLASSICAL__. Decide how the default device_qubits should be chosen and how gates and operation history from both modules combine. Done means a new merged module comes back with consolidated registers, with the original modules left unchanged, and tests cover merging two modules that use different register layouts.
由索引模型根据 Issue 内容生成。
描述
Feature Description
Implement a.merge() method with automatic unrolling and register consolidation.
- Purpose:
Merge twoQasmModuleobjects into a single module, handling all register consolidation and unrolling transparently. - Consolidation & Unrolling:
- All register consolidation and unrolling is performed automatically during the merge.
- Uses the existing
.unroll(device_qubits)method to ensure both modules are unrolled and consolidated before merging.
- User Experience:
- The user only needs to call
.merge()on one module, passing the other as an argument. - No manual unrolling or consolidation is required.
- The user only needs to call
- Output:
- Returns a new, merged module (preferred for immutability).
- All qubit and classical registers are consolidated into
__PYQASM_QUBITS__and__PYQASM_CLASSICAL__.
Implementation (Optional)
- Unroll and Consolidate Both Modules:
- Call
.unroll(device_qubits=...)on both modules before merging. - If
device_qubitsis not specified, use a default large enough to hold all qubits. - This ensures all registers are consolidated and unrolled.
- Call
- Merge Gates and Operation History:
- Append gates from the second module after the first.
- Combine operation history lists.
- Consolidate the Merged Module (Optional, but Safe):
- If the merge could introduce new registers (unlikely if both are already consolidated), perform a final consolidation.
- This step is mostly redundant but ensures robustness.
- Return the New Module:
- Return a new
QasmModulewith the merged content.
- Return a new
- 主要语言
- Python
- 星标
- 29
- 派生
- 33
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 15
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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
维护者通常 1 天内回复
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM可能已有人在做 @Jah-yee 于 16 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 1 天内回复
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost可能已有人在做 @tonycoder-hub 于 9 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 22/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
pgvector/pgvector-python#169 ·
-
ChaosEngine: backup-remote doctor row passes while consumer mode hides bot memory from git可能已有人在做 @MohabMohie 今天认领。 未关闭agentic
难度 2/5 1-3 小时 新手友好度 76/100
ShaftHQ/SHAFT_ENGINE#7263 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 87/100
huggingface/smolagents#3045 ·
维护者通常 1 天内回复