﻿# Triton launch grids: derive coverage from the block size actually selected by tuning

Keep Triton callable grid construction coupled to selected meta-parameters so autotuned block sizes cannot silently leave output regions unprocessed.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-triton-launch-grid-autotune-block-coverage/
Language: en

## Treat coverage as a joint contract

The [vector-add tutorial](https://triton-lang.org/main/getting-started/tutorials/01-vector-add.html) computes a program's starting offset from its ID and block size. It also constructs a callable launch grid from the meta-parameter block size. These are linked operations. A kernel can have correct internal indexing while the host launches too few program instances to cover the requested vector under another selected block extent.

## Understand what a configuration can change

The [Config interface](https://triton-lang.org/main/python-api/generated/triton.Config.html) stores kernel meta-parameters as well as compiler settings. The [autotune interface](https://triton-lang.org/main/python-api/generated/triton.autotune.html) evaluates supplied configurations for an argument key. If a candidate changes the amount of logical data processed by each program, the launch construction must follow that candidate. A grid calculated once using an unrelated assumed block size is not automatically correct for all candidate configurations or the later cached selection.

## Keep masking in its proper role

A store mask protects addresses for extra lanes of programs that were actually launched. It cannot execute a program that the host omitted. This distinction explains why a too-large grid can sometimes waste work safely while a too-small grid leaves untouched output even if every existing program has excellent boundary checks. Do not treat masking as a substitute for deriving the total coverage from the effective program-level work extent.

## Diagnose an intermittent tail failure

Imagine initial tests use the largest candidate block size and a fixed grid built for it. Another candidate with a smaller block size needs more programs and can leave a tail uncomputed. Preinitialize output with a distinguishable sentinel, test every candidate directly on a nondivisible problem size, and inspect all expected positions. This catches missing coverage instead of hiding it behind uninitialized memory that occasionally resembles a reasonable numeric result. Then verify final numerical equivalence under the selected configuration.

## Record grid and candidate together

Keep input extent, chosen block meta-parameters, callable grid formula, actual launch dimensions, and tested candidate set. Guides to [kernel launch granularity](/journal/learn-kernel-launch-granularity/) and [GPU acceptance evidence](/journal/gpu-acceptance-evidence/) provide context. Evaluate correctness before accepting a tuning result. A fast candidate that computed less output is a different task, and a cached configuration remains valid only when the wrapper constructs coverage consistent with the configuration's actual work assignment.
