RIFLA: Support emitting constant Result arrays#3277
Draft
swernli wants to merge 4 commits into
Draft
Conversation
This change supports the emission of constant `Result` arrays for Adaptive RIFLA QIR generation. To do so, we needed the compiler to see arrays of result values as "dynamic constant" expressions, which required a change to how `Result` values are handled during RCA and Partial Eval. Previously, any `Result` value coming back from an intrinsic operation was treated a dynamic variable, even though they are really just identifiers. This updates that logic to recognized results as identifiers, the same way qubits are identifiers, and moves the source of dynamic variables in RCA to the actual comparison of results rather than being inherent to the result itself. To make sure this quality propagates across function call boundaries appropriately, RCA was updated to differentiate between call arguments that are static vs dynamic constant vs dynamic variable, where previously it only checked for dynamic variable and treated constant and static as the same. In addition, this also includes an update to RCA that adds a new capability to recognize when a static `Result` value (`One` or `Zero`) is used as the output from a dynamic expression, since that cannot be emitted into QIR. The new check detects this at analysis time so the error is visible in the editor before the user tries to emit QIR (if applicable).
Collaborator
Author
|
Converting to draft for now. I found some test holes, new corner cases, and existing bugs that I'd like to get cleaned up and resolved first. |
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.
This change supports the emission of constant
Resultarrays for Adaptive RIFLA QIR generation. To do so, we needed the compiler to see arrays of result values as "dynamic constant" expressions, which required a change to howResultvalues are handled during RCA and Partial Eval. Previously, anyResultvalue coming back from an intrinsic operation was treated a dynamic variable, even though they are really just identifiers. This updates that logic to recognized results as identifiers, the same way qubits are identifiers, and moves the source of dynamic variables in RCA to the actual comparison of results rather than being inherent to the result itself. To make sure this quality propagates across function call boundaries appropriately, RCA was updated to differentiate between call arguments that are static vs dynamic constant vs dynamic variable, where previously it only checked for dynamic variable and treated constant and static as the same.In addition, this also includes an update to RCA that adds a new capability to recognize when a static
Resultvalue (OneorZero) is used as the output from a dynamic expression, since that cannot be emitted into QIR. The new check detects this at analysis time so the error is visible in the editor before the user tries to emit QIR (if applicable).