added adaptive profile support for qbraid_qir#225
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
TheGupta2012
left a comment
There was a problem hiding this comment.
Hi @feelerx, thanks so much for working on this!
Your initial code looks good and I've given some comments on the overall design. Once your updates are completed, can you also add tests for the verification of adaptive profiles?
…r and Profile (only if imported) with qasm3_to_qir funtion. Validation logic also moved to Profile class
|
The PR is quite close @feelerx , thanks for the great work! Besides that, could you also add an entry to the |
TheGupta2012
left a comment
There was a problem hiding this comment.
Changes look good, thanks for the work!
There was a problem hiding this comment.
We might need to update MANIFEST.in to also include json files from qbraid_qir/qasm3/profiles
Edit: Actually maybe not. Might be fine to not include
|
@ryanhill1 this lgtm, can you approve as well? |
| """ | ||
|
|
||
|
|
||
| # profile/__init__.py |
There was a problem hiding this comment.
| # profile/__init__.py |
qbraid_qir/qasm3/profiles/core.py
Outdated
| return cls._profiles[name] | ||
|
|
||
| @classmethod | ||
| def list_profiles(cls) -> List[str]: |
There was a problem hiding this comment.
| def list_profiles(cls) -> List[str]: | |
| def list_profiles(cls) -> list[str]: |
qbraid_qir/qasm3/visitor.py
Outdated
| initialize_runtime: bool = True, | ||
| record_output: bool = True, | ||
| external_gates: list[str] | None = None, | ||
| external_gates: Optional[List[str]] = None, |
There was a problem hiding this comment.
| external_gates: Optional[List[str]] = None, | |
| external_gates: Optional[list[str]] = None, |
|
|
@ryanhill1 yeah I think that makes sense, most likely Cirq could benefit from the profiles too. |
@TheGupta2012 core.py is unique to qasm3. The other 2 json files aren't. Should I move only the 2 of them? |
|
Maybe we want to create abstract |
… abstracted visitor and module classes so both cirq and qasm can use core.py
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """ |
There was a problem hiding this comment.
This doesn't really have much relevance inside the profiles, let's move it to qbraid_qir/abstract.py
There was a problem hiding this comment.
Or qbraid_qir/profiles.py for more clarity
ryanhill1
left a comment
There was a problem hiding this comment.
Still a few things that will need tweaking down the road, and some other organizational things that could be improved, but for now this is OK. Can address those things later. Main functionality is there, so will approve this
remove comment
Summary of changes
Adaptive Execution Profile
The Adaptive Execution Profile (adaptive_profile.json) enables:
Key differences from qbraid_qir custom Profile:
Profile Structure
Each profile is defined as a JSON file with the following structure:
{ "profile_name": "ProfileName", "version": "1.0.0", "description": "Profile description", "capabilities": { "feature_name": { "enabled": true, "description": "Feature description", "additional_options": "..." } }, "required_functions": { "quantum_intrinsics": ["function_list"], "runtime_functions": ["function_list"] }, "restrictions": { "restriction_category": { "setting": "value" } }, "validation_rules": { "rule_category": { "rule_name": "rule_value" } }, "compliance_checks": [ { "rule_id": "PROFILE_001", "description": "Rule description", "severity": "error|warning|info", "check_type": "check_category" } ] }Compliance Issues Identified
Issue: Custom profile uses pyqir._native.* functions while adaptive profile requires qis.* functions.
Custom Profile
Adaptive Profile:
Impact: Native functions don't provide the adaptive execution semantics required for conditional branching and qubit reuse.
Issue: Base profile doesn't track which qubits have been measured.
Adaptive Profile Addition:
Impact: Without tracking, post-measurement operations can't be properly validated or optimized.
Issue: Custom profile records output bit-by-bit, losing register structure.
Custom Profile:
Adaptive Profile:
Impact: Register structure is lost, making it difficult for adaptive runtimes to process results correctly.
Issue:Custom profile doesn't validate qubit usage patterns for adaptive execution.
Adaptive Profile Addition:
Impact: No validation of post-measurement qubit operations, which may be restricted in some execution environments.
Issue: Custom profile always emits barriers when applicable.
Adaptive Profile Addition:
Impact: Some adaptive runtimes may not support or need explicit barrier operations.