tilelang.transform.disable_pipeline_for_irregular_loop¶
Disable software pipelining for loops with irregular exits.
A T.Pipelined loop whose body contains continue / break cannot be
software-pipelined: InjectSoftwarePipeline emits the stage-1 statements
of the last trip as an epilogue after the loop, and the loop exit goes with
them, producing CUDA that nvcc rejects (a continue statement may only be
used within a loop). Moving the exit back into the loop would not be
enough either: with num_stages=1 a continue also skips the copy
issued for the next trip, and after an early break the epilogue would
still run the last trips.
This pass therefore strips the pipeline annotations (num_stages,
tl_pipeline_order, tl_pipeline_stage) from any loop whose body
contains a loop exit targeting that loop, so PipelinePlanning leaves it
as a plain sequential loop and it compiles exactly like T.serial. This
is the same rule TVM applies in AnnotateIrregularLoop, which rejects
software_pipeline_stage on a loop containing continue_loop /
break_loop, and mirrors the fallback already used by
PipelinePlanning for targets without async-copy support.
A loop exit inside a nested loop targets that nested loop, so nested
For / While bodies are not attributed to the loop being checked
(same as TargetedLoopBreakDetector in src/transform/unroll_loop.cc,
the check added for fully unrolled loops in #3078).
This pass must run before PipelinePlanning in every backend pipeline,
and before warp specialization in the CUDA pipeline: warp specialization
rewrites a T.Pipelined loop with a TMA copy into a producer/consumer
structure with barriers, and a taken exit would skip the consumer arrive
for that iteration, deadlocking the producer on a barrier that is never
released. Stripping the annotations first makes
ProducerConsumerWarpSpecialized skip such loops entirely (it only
rewrites loops carrying a num_stages annotation); the opt-in
AutoWarpSpecialization pass does not require num_stages (its
ScopeStages falls back to 1), so it separately declines kernels
containing tl.loop_break, tirx.continue_loop, or
tirx.break_loop in PreprocessIR (CheckCalls in
src/cuda/transform/auto_schedule/preprocess_ir.cc). Together, both
warp-specialization paths leave irregular loops sequential.
Functions¶
Create a TVM pass that disables software pipelining for irregular loops. |
Module Contents¶
- tilelang.transform.disable_pipeline_for_irregular_loop.DisablePipelineForIrregularLoop()¶
Create a TVM pass that disables software pipelining for irregular loops.
Loops whose body contains
continue/breaktargeting the loop itself lose their pipeline annotations and are lowered as plain sequential loops, instead of producing invalid CUDA with a loop exit in the software-pipeline epilogue.Note
This pass must be applied before PipelinePlanning, while the
T.Pipelinedloop still carries itsnum_stages/tl_pipeline_order/tl_pipeline_stageannotations, and before warp specialization in the CUDA pipeline (see the module docstring).- Returns:
A TVM PrimFunc pass.