This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
Add callable-local runtime capability inference #593
Merged
bamarsha
merged 23 commits into
feature/capability-inference
from
samarsha/capability-inference
Sep 1, 2020
Merged
Add callable-local runtime capability inference #593
bamarsha
merged 23 commits into
feature/capability-inference
from
samarsha/capability-inference
Sep 1, 2020
Conversation
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
cesarzc
reviewed
Aug 31, 2020
cesarzc
reviewed
Aug 31, 2020
cesarzc
reviewed
Aug 31, 2020
cesarzc
reviewed
Aug 31, 2020
cesarzc
approved these changes
Sep 1, 2020
Contributor
cesarzc
left a comment
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.
Looks good! Thanks for addressing the comments Sarah.
7 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Infers the minimum required runtime capabilities of each callable in the compilation, and adds the
@Microsoft.Quantum.Core.Capabilityattribute 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.