Add stitched rtlsim liveness threshold override - #1614
Conversation
(cherry picked from commit 0315882)
There was a problem hiding this comment.
Thanks @ollycassidy13!
This looks good, but I feel like maybe we are using it to avoid addressing an underlying issue .
Why was this developed, was it because the simulation was timing out before it had actually finished due to the derived threshold being too low? I'm concerned we're stacking band-aides and it might be better to address the underlying issue here.
Do you have a case where this was triggered that we can work from? The more minimal the better :)
|
Thanks @STFleming. This was not developed to allow a simulation that was falsely timing out to run for longer. The issue I encountered was the opposite: for a rolled MLO graph, the analytical estimate was too conservative, so a stall took millions of idle cycles before the watchdog fired. The watchdog measures cycles without output activity, rather than total simulation duration. In the TinyDeiT case, the 12-iteration FINNLoop estimate was approximately 27.1M cycles, resulting in a derived watchdog of approximately 29.8M cycles. The corresponding RTL FIFO simulation completed in about 333k cycles, with an interval of about 295k cycles. This meant a real deadlock could spend roughly 30M simulated cycles before being reported. The intended use of the override was therefore to select a smaller known-safe threshold - one still comfortably above the measured valid output interval - so genuine stalls fail earlier. It does not make a stalled simulation pass; it only changes when the existing watchdog reports it. The default remains unchanged when the option is unset. The motivating case is the TinyDeiT FINNLoop, which is not especially minimal. |
|
Thanks so much for clarifying @ollycassidy13! Is there any reason why the current Line 150 in c3670d1 LIVENESS_THRESHOLD envvar would break backwards compatibility so would require some thought.
|
|
The reason I added the builder argument was that, in the current |
Ah interesting, thanks @ollycassidy13, is this intended @auphelia? |
Just chiming in with what I found recently. LIVENESS_THRESHOLD reaches none of these:
|
…m-liveness-threshold
|
Thanks for looking into this and all your comments. I traced through the code and I think there's a root cause we should fix rather than adding a config workaround. The underlying issueThe 29.8M vs 333k cycle discrepancy comes from FINNLoop.get_exp_cycles() in finn_loop.py:244-259: The problem is that critical_path_cycles sums all node latencies along the path (see dataflow_performance.py:73), which is explicitly noted as "very pessimistic" - it assumes no overlap between executions. For a pipelined dataflow this is wrong: nodes execute concurrently, so steady-state throughput is limited by max_cycles (the slowest node), not the sum. On LIVENESS_THRESHOLD propagationI see @ollycassidy13 and @merkelmarrow's points that LIVENESS_THRESHOLD isn't propagated throughout the codebase and we should address this. Previously, @fpjentzsch suggested to always check LIVENESS_THRESHOLD and use it if it's higher than the estimate. At the time I was critical of that approach because it could mask estimation bugs. With bigger transformers now, I'm changing my opinion a bit. I'd suggest:
This error message improvement should be added everywhere LIVENESS_THRESHOLD could be used. Proposed fix
Rationale
With a correct estimate, the TinyDeiT case should derive a reasonable threshold automatically. |
|
Thanks, I’ve updated the PR with the proposed fix:
|
Adds a builder config option to override stitched-IP rtlsim liveness thresholds.
This groups the builder config and verification-step environment handling for long MLO simulations.
Change type: Python