Triton RMSNorm example uses epsilon 1e-6 but definition requires 1e-5

未关闭
#21 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python

调研方向

从 examples/triton/rmsnorm/definition.json 开始,将其中固定的 epsilon 与 examples/triton/rmsnorm/kernel.py 中的 launch 进行比较。更新 examples/triton/rmsnorm/solution_triton.json 中的 launch 和嵌入式源代码,然后添加一个小量级 BF16 正确性用例;完成的标准是,对于有效的 BF16 输入,随附示例与参考结果一致。

由索引模型根据 Issue 内容生成。

描述

Summary

The Triton RMSNorm example does not implement its own problem definition.

Observed mismatch for x = BF16(1e-3) and weight = 1: expected 0.30078125 vs. candidate output 0.70703125.

This is present on current main at commit a9fa0804c793d438e70850c33fe34426e66d53dd.

Minimal reproducer

Use a valid official-shape BF16 row with small finite values and unit weights:

import torch

x = torch.full((1, 4096), 1e-3, dtype=torch.bfloat16, device="cuda")
weight = torch.ones(4096, dtype=torch.bfloat16, device="cuda")

def rmsnorm(x, eps):
    x32 = x.float()
    return (
        x32 * torch.rsqrt(x32.square().mean(-1, keepdim=True) + eps)
        * weight.float()
    ).bfloat16()

print(x[0, 0].item())
print(rmsnorm(x, 1e-5)[0, 0].item())
print(rmsnorm(x, 1e-6)[0, 0].item())
Input:                                      0.00099945068359375
Expected (reference, epsilon = 1e-5):       0.30078125
Observed (Triton candidate, epsilon = 1e-6): 0.70703125

So the concise comparison is: expected 0.30078125 vs. observed 0.70703125.

A randomized (randn * 1e-3).bfloat16() input with batch size 7 produced 26,631 mismatching elements out of 28,672.

This is not reduction-order noise: for a constant row, the output is analytically x / sqrt(x² + eps), and the observed ratio agrees with changing epsilon from 1e-5 to 1e-6.

Expected behavior

The bundled example solution should use the epsilon required by rmsnorm_h4096 for all valid BF16 inputs.

Suggested fix

  1. Change the launch argument in examples/triton/rmsnorm/kernel.py from 1e-6 to 1e-5.
  2. Make the same change in the embedded source inside examples/triton/rmsnorm/solution_triton.json.
  3. Add a small-magnitude BF16 correctness case; unit-scale inputs make epsilon comparatively negligible and can hide this mismatch.
主要语言
Python
星标
340
派生
37
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/SOL-ExecBench 的其他 Issue

查看 NVIDIA/SOL-ExecBench 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。