TECHNOLOGY

Triton num_stages scope: a loop annotation differs from the launch configuration

In this article
THE QUICK TAKE

Identical num_stages values at different configuration scopes are not interchangeable descriptions of compiler scheduling; identify the actual annotated loop and loads.

Identify where the setting is applied

The Triton range API exposes loop-level compiler attributes, including num_stages. The Config API separately includes a kernel configuration field with the same name. A performance report that records only the number loses this scope distinction. Before comparing tuning results, identify whether a wrapper changed a launch configuration or attached an attribute to a particular loop in the source.

Read the documented load distinction

The range documentation explicitly distinguishes its loop attribute from the kernel argument: the latter pipelines loads feeding dot operations, while the loop attribute attempts to pipeline most, though not every, load in that loop. This does not promise identical coverage for all code. A loop containing arithmetic inputs and another auxiliary load can therefore present a different scheduling opportunity depending on which interface supplies the setting. Treat the documentation as version-specific guidance and inspect the installed compiler’s result.

Separate pipelining from unrolling

The language implementation represents loop stage count and unroll factor as separate attributes. Pipelining overlaps work from iterations; unrolling changes the represented loop body. They can interact, but changing one is not simply another spelling of changing the other. Keep each selected attribute in the experiment record rather than describing all additional in-flight work or code growth as a single stage-count increase.

Diagnose a misleading tuning comparison

Imagine a refactor moves a stage setting from the launch options into an inner tl.range. The visible number stays unchanged, but the target loads and surrounding loop scope can differ. Compare generated scheduling, resource use, and numerical output under the same workload before attributing a speed change to compiler randomness. This experiment does not assume that more stages always help: extra live state and target-specific scheduling can change the operating tradeoff.

Record the full scheduling choice

Keep source loop identity, annotation values, launch configuration, compiler revision, target device, and measured resource usage. Guides to GPU asynchronous copy stages and inference evaluation provide context. Verify the actual scheduled path before reporting a tuning winner. A reproducible claim names the scope and observed execution, because the same option label at different abstraction boundaries cannot establish equivalent pipeline behavior or equal demand on GPU resources.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles