While mid-circuit measurements are already supported as of #101, feed-forward is trickier.
What we need
-
We need to track the probability of each outcome at every mid-circuit measurement (this will also be needed for STIM support). This makes merging different branches trickier. We have to come up with a way to track mid-circuit measurement probabilities through merged entries (e.g. by using a Vec<Vec<_>>) and somehow connect them to the actual measurement gate that produced it. The alternative is to not merge entries with different mid-circuit measurement probabilities, but that will probably lead to branch blow-up.
-
Once we have the above, we need to replace an if-statement such as shown in the snippet below, and replace the outcome if with branching, where each branch is weighed by the respective outcome probability of the used mid-circuit measurement. This will require rewriting the IR and it's genuinely not quite clear to me what the best approach here is.
let m = tab_sum.measure(0);
if m {
tab_sum.x(0);
}
Non-goal
We do not want to support arbitrary if statements. Specifically, it may be fine to have a more or less arbitrary if body, but the condition needs to be based on a single measurement (maybe multiple measurements if it's not too hard). I'm also not quite sure how to best do this, maybe adding a designated statement for it.
While mid-circuit measurements are already supported as of #101, feed-forward is trickier.
What we need
We need to track the probability of each outcome at every mid-circuit measurement (this will also be needed for STIM support). This makes merging different branches trickier. We have to come up with a way to track mid-circuit measurement probabilities through merged entries (e.g. by using a
Vec<Vec<_>>) and somehow connect them to the actual measurement gate that produced it. The alternative is to not merge entries with different mid-circuit measurement probabilities, but that will probably lead to branch blow-up.Once we have the above, we need to replace an if-statement such as shown in the snippet below, and replace the outcome
ifwith branching, where each branch is weighed by the respective outcome probability of the used mid-circuit measurement. This will require rewriting the IR and it's genuinely not quite clear to me what the best approach here is.Non-goal
We do not want to support arbitrary
ifstatements. Specifically, it may be fine to have a more or less arbitraryifbody, but the condition needs to be based on a single measurement (maybe multiple measurements if it's not too hard). I'm also not quite sure how to best do this, maybe adding a designated statement for it.