Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Adjoint invert spec gen via logic separation analysis #190

Merged
merged 15 commits into from
Apr 26, 2023

Conversation

swernli
Copy link
Collaborator

@swernli swernli commented Apr 19, 2023

This change introduces logic separation as an analysis pass that returns the set of stmts within a block and all nested scopes that are non-deterministic due to including operation calls. It uses this analysis pass as the chance to collect any errors related to patterns that prevent separation and therefore adjoint generation. This is used by spec_gen to support adjoint invert and controlled adjoint invert generation. Includes tests for logic separation analysis and adjoint generation. This also includes loop reversal of for-loops over ranges and arrays.

This change introduces logic separation as an analysis pass that returns the set of stmts within a block and all nested scopes that are non-deterministic due to including operation calls. It uses this analysis pass as the chance to collect any errors related to patterns that prevent separation and therefore adjoint generation. This is used by `spec_gen` to support adjoint invert and controlled adjoint invert generation. Includes tests for logic separation analysis and adjoint generation.

Note: This does not yet properly handle reversing for-loop expressions as part of inversion. That will be handled in a follow up PR.
compiler/qsc_passes/src/logic_sep.rs Outdated Show resolved Hide resolved
compiler/qsc_passes/src/logic_sep.rs Outdated Show resolved Hide resolved
compiler/qsc_passes/src/logic_sep.rs Outdated Show resolved Hide resolved
compiler/qsc_passes/src/logic_sep.rs Outdated Show resolved Hide resolved
compiler/qsc_passes/src/logic_sep/tests.rs Outdated Show resolved Hide resolved
compiler/qsc_passes/src/invert_block.rs Outdated Show resolved Hide resolved
swernli and others added 3 commits April 26, 2023 11:22
Co-authored-by: Sarah Marshall <33814365+samarsha@users.noreply.github.com>
Co-authored-by: Sarah Marshall <33814365+samarsha@users.noreply.github.com>
@swernli swernli merged commit 32ae1d9 into main Apr 26, 2023
10 checks passed
@swernli swernli deleted the swernli/logic-sep branch April 26, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants