Feature/Implement Qubit Register Consolidation#222
Feature/Implement Qubit Register Consolidation#222TheGupta2012 merged 10 commits intoqBraid:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Hi @vinayswamik , the changes look good!
A point to consider for the design -
Consolidation of qubits inside the qasm operations should be done as a "finalize" step. Presently, you are updating the qubit identifiers directly during the unroll / validate phase and subsequently adding the __PYQASM_QUBITS__ declaration. While it works for the test cases, this transformation logic should be separated in a new step.
A cleaner approach would be to refactor the transformation of statements (which you have done inside each of reset, barrier, etc.) as part of the _qubit_register_consolidation method. It should read the unrolled statements and transform the qubits for each of them, possibly utilizing the Qasm3Transformer module. I only see self._get_pyqasm_device_qubit_index being utilized in your changes and can be decoupled from the visitor code.
Yeah,I thought about doing all the changes in My suggestion would be move all the current code in ( And also we can do consolidation with/without providing |
Yea, that's a good point, the branches might exist in the code even after |
09b7670 to
f03b840
Compare
|
Besides the minor comment fix, changes lgtm @vinayswamik ! Once the CI fix is merged, can you rebase as well? Should be good to merge post that |
- Added a new parameter `device_qubits` to `QasmVisitor` and `QasmModule` to manage qubit consolidation. - Introduced methods for qubit index mapping and register consolidation to ensure compatibility with device constraints. - Updated measurement, barrier, and gate operations to utilize the new device qubit logic. - Added unit tests to validate the functionality of qubit consolidation and error handling for exceeding device qubit limits.
update test case
- Added `consolidate_qubits` parameter to `QasmVisitor`, `QasmModule`, and related methods to support qubit consolidation and device constraints. - Updated the `load` and `loads` functions to accept new parameters for better integration with device specifications. - Implemented transformation logic for qubit register mapping in statements to align with device qubit indices. - Enhanced unit tests to validate the new functionality, including error handling for exceeding device qubit limits and ensuring correct unrolling of QASM programs.
- Introduced a new `span` attribute in the `Variable` class to capture the span of variables. - Refactored `load` and `loads` functions to accept additional keyword arguments for improved flexibility. - Updated various parts of the codebase to utilize the new `span` attribute during variable creation and validation. - Enhanced unit tests to ensure proper handling of the new functionality and validate error messages related to variable definitions.
064e607 to
06a921d
Compare
Summary of changes
Implement device qubit(
__PYQASM_QUBITS__) support in QasmVisitor and QasmModuledevice_qubitstoQasmVisitorandQasmModuleto manage qubit consolidation._get_pyqasm_device_qubit_indexmethod for qubit index mapping and_qubit_register_consolidationto ensure compatibility with device constraints.Closes #187