[FEATURE] Implement a `.merge` method for `QasmModule`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 29
- Forks
- 33
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from qBraid/pyqasm
-
dumps() prints the original program when unroll() leaves at most one statementPossibly taken @ShiveshDragon claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
qBraid/pyqasm#493 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
enhancement error-handling program-validation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 43/100
Maintainers usually reply within 1 day
-
dependencies enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
nolte/kamerplanter#3193 ·
Maintainers usually reply within 1 day
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day