liveBook · Manning

Tl.load

As explained in GPU Programming with Triton

tl.load is Triton's operation for loading values from memory through pointer expressions, with optional per-element masking.

tl.load reads values from global memory using pointer expressions. Adding a vector of offsets to a base pointer forms addresses for a block of elements in one call; loaded values arrive in on-chip registers for computation. section 2.2.7

x = tl.load(x_ptr + offsets, mask=mask)

A masked vector load uses the same offsets to select elements and to avoid out-of-bounds accesses. section 2.2.7

Use a mask to handle partial blocks safely:

  • Mark valid indices so loads skip positions outside the array, such as the tail of the final vector block. section 2.4
  • For incomplete matrix tiles, masked input values need an explicit other=0.0 when they feed tl.dot; otherwise, their values are undefined. section 5.8.1

Vector addition

Each Triton program adds its offsets to the input base pointers, loads its slice of both vectors with a mask, and computes the corresponding output values. section 2.2.7

How GPU Programming with Triton covers it

How deep it goes
Explains pointer offsets, vector loads, and masking, but does not detail the instruction-level implementation.
Examples
Uses masked vector-addition loads and matrix edge tiles with K=70 and BLOCK_K=32.
What it assumes
Assumes base pointers, offsets, and masks; explains how offsets form block addresses and masks protect array bounds.
What you can do after
Apply tl.load in Triton to fetch offset-based blocks while masking out-of-range elements.
How it connects
Connects pointer arithmetic and masks to global memory, registers, tl.store, and Triton kernels.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of GPU Programming with Triton. The section links point to the parts of the book it draws on.