Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@bamarsha
Copy link
Contributor

@bamarsha bamarsha commented Aug 27, 2020

Infers the minimum required runtime capabilities of each callable in the compilation, and adds the @Microsoft.Quantum.Core.Capability attribute to it, containing its capability ("QPRGen0", "QPRGen1", or "Unknown"). The inference is run as a rewrite step for libraries only, because executables have an execution target with a fixed runtime capability, so labeling is not needed. The attribute will be used later to verify that executables can't call library functions/operations with a capability that is too high.

The existing code for capability diagnostics was refactored, so both inference and verification can use the same code. The inference algorithm finds syntactic patterns in statements and expressions that imply a runtime capability. These patterns can be converted into either an inferred capability (by taking the max of all required capabilities), or diagnostics (by selecting patterns that imply a capability that is too high for the current execution target).

For now, inference only looks at the source code of callables individually - it doesn't find references or use the call graph, so the actual capability may be higher than what is currently inferred.

Part of issue #586.

@bamarsha bamarsha changed the title Add local capability inference Add callable-local runtime capability inference Aug 27, 2020
@bamarsha bamarsha marked this pull request as ready for review August 27, 2020 18:45
Copy link
Contributor

@cesarzc cesarzc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for addressing the comments Sarah.

@bamarsha bamarsha merged commit 8527504 into feature/capability-inference Sep 1, 2020
@bamarsha bamarsha deleted the samarsha/capability-inference branch September 1, 2020 19:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants