-
Notifications
You must be signed in to change notification settings - Fork 18
Fix 217: Merge function for Qasm Modules #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
👋 Hey there! It looks like the changelog might need an update. Please take a moment to edit the
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
||
assert "qubit[3] __PYQASM_QUBITS__;" in merged_text | ||
assert "measure __PYQASM_QUBITS__[2];" in merged_text | ||
assert "barrier __PYQASM_QUBITS__" in merged_text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert "barrier __PYQASM_QUBITS__" in merged_text | |
assert "barrier __PYQASM_QUBITS__[0]" in merged_text |
merged_text = str(merged) | ||
|
||
assert "qubit[3] __PYQASM_QUBITS__;" in merged_text | ||
assert "measure __PYQASM_QUBITS__[2];" in merged_text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing the structure of the measurement statements? I believe the merged qasm should be like -
OPENQASM 3.0;
include "stdgates.inc";
qubit[3] __PYQASM_QUBITS__;
// Module A
bit[1] ca;
h __PYQASM_QUBITS__[0];
barrier __PYQASM_QUBITS__[0];
ca[0] = measure __PYQASM_QUBITS__[0];
// Module B
bit[2] cb;
x __PYQASM_QUBITS__[1];
cb[1] = measure __PYQASM_QUBITS__[1];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the verification functions from the tests/utils.py
file? We have already implemented a lot of robust checks in that file which you are implementing from scratch
Summary of changes
Fixes issue 217 by adding a merge function, so two QasmModule objects can be combined into one. The merge function unrolls both modules and creates a single qubit declaration. This function appends the second QasmModule object with the correct index offsets and returns a Qasm3Module.
The test_merge.py file is added, which has a few examples of merging two modules, using the merge function.