Rate this Page
★ ★ ★ ★ ★

helion.language.prefetch#

helion.language.prefetch(tensor, index, extra_mask=None)[source]#

Hint that tensor[index] will be read soon by warming the L2 cache.

index and extra_mask follow load() (tiles, integers, slices, hl.arange / integer-tensor gathers). Nothing is returned and nothing is ordered: a prefetch neither waits for earlier stores nor makes later loads see anything, so dropping it never changes a result. Unlike load() it takes no indexing, eviction-policy or cache-modifier config slot, so adding one leaves every load’s tunables where they were.

On NVIDIA GPUs (Triton backend), when the last index is a full slice or a tile of a stride-1 dim and there is no extra_mask, each element of the leading indices issues one cp.async.bulk.prefetch.L2 covering its row segment (sm_90+). Any other prefetch issues prefetch.global.L2 per element (one 128-byte line each). Other targets drop it.

Parameters:
  • tensor (Tensor) – The tensor to prefetch from

  • index (list[object]) – The indices to use to index into the tensor

  • extra_mask (Tensor | None) – The extra mask (beyond automatic tile bounds masking) to apply to the tensor

Return type:

None

Returns:

None