[Triton] Integrate reorder-loop-loads into LoopUnroll pass#775
Conversation
|
Please refer to PR 763 to add the C++ macro switch. |
|
Thanks for working on this optimization. Could you please avoid modifying the upstream Would it also be possible to move as much of the backend-specific implementation as possible out of upstream Triton-owned directories and into the TLE subtree? If a hook in an upstream-owned file is unavoidable, please keep it minimal and place the TLE-specific code behind the appropriate TLE build guard. This will minimize divergence from upstream and make ownership of the extension explicit. Please update the relevant call sites and tests to use |
Background
In Triton kernels, load operations and compute operations are interleaved after loop unrolling. On some hardware, this interleaving prevents memory access latency from being effectively hidden — because each load's result is immediately consumed by the computation that follows it, leaving the pipeline underutilized.
The ideal approach is to hoist (cluster) the load operations from each unrolled iteration to the front, so that multiple loads can be in-flight simultaneously, thereby exploiting memory system bandwidth and hiding latency.
Design
1. Reorder logic integrated into LoopUnroll
For loops with
tt.reorderattribute:Key helpers:
willFullyUnroll()(static trip count check),collectDepsInBlock()(transitive dep collection),reorderLoadsInRange()(load-first reordering preserving relative order within each group).2. User interface
Added
reorder=Falseparameter totl.range. Whenreorder=Truewithloop_unroll_factorset, thett.reorderattribute is attached to thescf.for, triggering load clustering during unroll.Performance
fused_inv_rope_fp8_quant