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

Implement classically controlled operations #248

Closed
wants to merge 3 commits into from

Conversation

theRoughCode
Copy link
Contributor

@theRoughCode theRoughCode commented Aug 6, 2020

This PR is a first step at implementing classically controlled operations and is based off of work in this PR. It is part of the Q# visualization tool as described in #158.

In this PR, we:

  1. Use the IsConditional flag in the RuntimeMetadata class to check if the given operation is a classically-controlled operation.
  2. Implement the same logic as we do for composite operations (i.e. recursively trace nested operations). In this case we would get 2 operations (one for each conditional branch). Upon exit from the recursive tracer, we add them as Children of the outer condition operation.
  3. Override the logic for ApplyIfElseR with a custom TracerApplyIfElse.

TODO:

  • Implement getting correct classical register
  • Use IsConditional flag in visualizer (JS) to determine if the operation is a classically-controlled operation instead of checking children.
  • Modify classically-controlled tests in visualizer (JS) to use IsConditional instead of IsControlled.

If this logic makes sense, our next steps are to:

  • Override conditional logic for all other variants of ApplyIfElse
  • Perform an IRewriteStep to convert if/else statements to ApplyIfElse
  • Reduce ApplyIfOne and ApplyIfZero to ApplyIfElse.

@theRoughCode theRoughCode self-assigned this Aug 6, 2020
@theRoughCode theRoughCode marked this pull request as draft August 6, 2020 20:16
@theRoughCode
Copy link
Contributor Author

Closing this PR in favour of #290.

@theRoughCode theRoughCode deleted the raphael/classical branch August 20, 2020 18:34
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.

1 participant