In a Triton kernel, a constexpr parameter supplies a value at compile time. Marking the block size as tl.constexpr lets the compiler specialize and optimize the generated GPU code for that size. section 2.4 section 2.2.10
Specialization affects compilation and caching. Triton caches compiled binaries using constexpr values and coarse properties of other arguments. Changing BLOCK_SIZE triggers a fresh compile; subsequent calls with the same specialization can reuse the binary. section 2.2.10
Vector length versus block size
For vector addition, n_elements is a runtime integer, while BLOCK_SIZE is a compile-time constant. Keeping the length at runtime allows a binary to be reused across input sizes; marking it constexpr would require a separate binary for each distinct length. A block-size sweep instead triggers compilation for new block sizes. section 2.2.10
When benchmarking steady-state performance, discard the first call and usually several early calls as warmup. The first call includes CPU-side compilation, which can otherwise dominate the measurement. Repeat warmup when testing a new specialization. section 2.2.10



