QIR Base profile Compliant QASM Conversions#228
Merged
TheGupta2012 merged 35 commits intoqBraid:mainfrom Jun 12, 2025
Merged
Conversation
…r and Profile (only if imported) with qasm3_to_qir funtion. Validation logic also moved to Profile class
…ed off the profile in use
… abstracted visitor and module classes so both cirq and qasm can use core.py
…cification of the base profile
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
…that does not allow reuse of qubits after measurement, adjusted affected test cases also (reset measured qubits)
…ustom value, changed hardcoded value to base
Member
|
@feelerx could you please resolve merge conflicts in this PR? I feel this has a lot of overlapping changes from the Adaptive PR |
Member
|
Also, better to |
…that does not allow reuse of qubits after measurement, adjusted affected test cases also (reset measured qubits)
Member
|
Thanks @feelerx, lgtm! I think most changes were already completed in #225, I'll let @ryanhill1 take one final look before approving. |
This was
linked to
issues
Jun 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
This PR addresses critical compliance gaps between the current qasm3_to_qir implementation and the QIR Base Profile specification. The changes ensure proper measurement state tracking, correct function usage, and adherence to Base Profile restrictions.
Profile Structure
Each profile is defined as a JSON file with the following structure:
Compliance Issues Identified
Issue: The Base Profile requires tracking which qubits have been measured to enforce the restriction that qubits cannot be used after measurement without reset.
Current State: No measurement tracking implemented
Current implementation lacks:
self._measured_qubits: dict[int, bool] = {}Base Profile Requirement:
qubit_usage.track_measurement_state: truequbit_usage.allow_post_measurement_operations: falseIssue: Current implementation doesn't consistently enforce Base Profile function requirements.
Base Profile Requirements:
pyqir._native.mzfor measurementspyqir._native.resetfor qubit reset operationspyqir._native.if_resultfor conditional branchingCurrent State: Functions are used correctly but without explicit profile validation
Issue: No validation to prevent quantum operations on measured qubits.
Base Profile Restriction:
Missing Reset State Management (MEDIUM)
Issue: Reset operations don't properly clear measurement state tracking.
Expected Behavior: Reset should clear the measured state of qubits to allow future operations.
Changes Made
Added Measurement State Tracking