[FTD] Support Multi-Exit Loops #604
Draft
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.
The previous fast token delivery crashed when running into loops with multiple exits (see example CFG below).
This happened because gates (Mu gates in this case) stored only one block as their condition block, which fails when multiple blocks are needed as conditions.
To fix this, two new attributes were added to
Gate
:For each Mu gate, the loop exit condition is computed by OR-ing the exit conditions of all exiting blocks. The condition of the Mu is then set as the negation of this exit condition (i.e., the loop iteration condition).
For Gamma gates, the condition remains the same as before, taken from the condition block.
In
FtdImplementation.cpp
, whenever the condition value of a gate/loop is needed:In addition, in
boolVariableToCircuit
function, conditions generated for gates with multiple exiting blocks do not require channelification.