TECHNOLOGY

Triton compiler hints: alignment promises do not validate tensor addresses

In this article
THE QUICK TAKE

A compiler hint states a property the compiler may use; it does not make misaligned or noncontiguous data satisfy that property.

Distinguish a promise from a measurement

Triton provides operations that communicate facts to the compiler. The assume API permits compilation to assume that a condition is true. This is not a runtime validator that repairs or rejects arbitrary incoming tensor layouts. Before adding such a hint to a kernel optimization, explain why the condition follows from the supported shape, stride and index construction rather than from one observed example.

Read the alignment claim precisely

The multiple_of API describes divisibility information in relation to contiguous groups along a dimension. Do not simplify its meaning into an unrelated statement that every address is identically aligned. The property belongs to the supplied index representation and its grouping. A sliced tensor or changed starting offset can invalidate a previously justified claim even when element dtype, overall shape and nominal allocation alignment remain unchanged.

Keep contiguity separate from divisibility

The max_contiguous API communicates the length of contiguous runs in an index sequence. It does not reorder values or create contiguous storage. Combined hints can enable vectorized memory access, but the actual sequence must satisfy both properties. Check the logical indices and tensor strides together; a visually regular range expression can still address a strided view whose physical memory does not match the intended vectorization premise.

Validate the supported input set

Test representative transposes, slices and tail cases before broadening a wrapper’s accepted layouts. If a hint is valid only for a restricted input family, state that restriction or dispatch other inputs to an appropriate path. Removing validation while retaining the compiler promise changes the call contract. Correctness on a favorable aligned case cannot justify the same promise for every tensor the higher-level application is technically able to pass.

Measure the justified optimization

Compare the hinted and reference implementations on inputs satisfying the stated conditions, then measure the actual generated path and runtime effect. A hint’s presence alone does not establish a speedup. The guides to coalesced memory access and integer address arithmetic provide context. Triton’s specific boundary is compiler trust: assume, divisibility and contiguity hints describe proven properties of an input construction, rather than requesting a transformation that makes an arbitrary input safe or well aligned.

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