Blocked Triton RMSNorm forward overflows int32 row offsets

Author: arcusbuildsCreated Sep 22, 2026Updated Sep 23, 2026

Describe the bug

_block_rms_norm_forward_kernel leaves tl.program_id(0) as int32 before multiplying it by BLOCK_ROW and row strides. This is the default RMSNorm forward path when n_cols <= 256 and n_rows >= 32768.

For n_cols=256, block 524288 begins at row 2^23; its row offset is 2^23 * 256 = 2^31 elements. With int32 address arithmetic this wraps, causing incorrect reads and writes.

Reproduce

The arithmetic boundary can be demonstrated without a large allocation:

python
import torch

row_idx = torch.tensor(2**23, dtype=torch.int32)
row_stride = torch.tensor(256, dtype=torch.int32)
assert (row_idx * row_stride).item() == -(2**31)
assert row_idx.to(torch.int64).mul(row_stride).item() == 2**31

A full kernel repro uses a bf16 tensor of shape (2**23 + 16, 256), sets only the final row to one, and runs LigerRMSNormFunction.apply(..., row_mode=False). Input plus output require about 8.6 GB of free VRAM.

Context

PR #1482 fixes this by casting the program ID to tl.int64, matching the other RMSNorm kernels.

This is the same pointer-arithmetic safeguard merged in PR #804. Related reports: #1335 and #1296.

Versions

Observed by source inspection on current main. The prepared regression was run on an NVIDIA RTX 2000 Ada Generation Laptop GPU with 8 GB VRAM; the full allocation was skipped because only 7,956 MiB was free.