Skip to content

[FTD] Implement robust Fast Token Delivery#966

Open
QinYuan2000 wants to merge 101 commits into
mainfrom
new-ftd-smart-buffer
Open

[FTD] Implement robust Fast Token Delivery#966
QinYuan2000 wants to merge 101 commits into
mainfrom
new-ftd-smart-buffer

Conversation

@QinYuan2000

Copy link
Copy Markdown
Collaborator

Summary

This PR implements the robust Fast Token Delivery procedure developed in the thesis.

The original FTD work delivers tokens directly from producers to consumers and uses regeneration and suppression to preserve the token-matching invariant. However, suppression conditions are themselves computed from condition tokens, so building a suppression circuit creates new internal deliveries. The original procedure does not fully resolve these internal deliveries in complex control flow.

This PR implements a suppression construction that resolves these internal deliveries during circuit construction. For each producer-consumer delivery, it reconstructs the relevant control-flow relation, builds a decision graph, derives the Boolean condition under which the consumer is reached, lowers the condition through MUX trees, distributes condition tokens only along paths where they are available, and demotes condition tokens across loop levels when needed.

Main changes

  • Refactor the FTD implementation into:

    • FtdImplementation, for the top-level FTD flow
    • FtdSupport, for shared type, annotation, and attribute utilities
    • FtdSuppression, for the suppression algorithm
  • Implement the new suppression pipeline:

    • producer-consumer local CFG reconstruction
    • decision graph extraction
    • cyclic decision graph decomposition
    • Expression-to-circuit lowering
    • condition-token distribution
    • token demotion across nested loops
    • conditional consumption handling for γ mux inputs
  • Integrate the same post-flattening FTD flow with Straight-to-Queue.

QinYuan2000 and others added 30 commits October 16, 2025 01:23
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.

<img width="200" height="388" alt="linear_search_CFG"
src="https://github.com/user-attachments/assets/d2b59e5e-a8b1-42a9-b51a-141755eeb216"
/>

To fix this, two new attributes were added to `Gate`:
- a boolean expression for the condition
- a list of cofactors, representing the variables used in the condition
expression.

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:
- If there is a single cofactor, the same process as before is used,
- If there are multiple cofactors, a Binary Decision Diagram (BDD) is
built, translated into a circuit, and used as the condition value.

In addition, in `boolVariableToCircuit` function, conditions generated
for gates with multiple exiting blocks do not require channelification.
AyaElAkhras and others added 28 commits April 12, 2026 04:09
When compiling with the `ftd` feature, the default HDL is `vhdl`. If the
HDL is changed to `verilog`, compilation fails due to a missing `noti`
unit. This commit adds support for the `noti` unit to the `verilog-beta`
unit generator.
@QinYuan2000 QinYuan2000 requested a review from AyaElAkhras June 8, 2026 02:24
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.

4 participants