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

Đang mở
#21 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python

Hướng nghiên cứu

Bắt đầu với examples/triton/rmsnorm/definition.json và so sánh epsilon cố định của nó với launch trong examples/triton/rmsnorm/kernel.py. Cập nhật launch và mã nguồn được nhúng trong examples/triton/rmsnorm/solution_triton.json, sau đó thêm một trường hợp kiểm tra tính đúng đắn BF16 với độ lớn nhỏ; hoàn tất có nghĩa là ví dụ đi kèm khớp với tham chiếu đối với các đầu vào BF16 hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
340
Fork
37
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/SOL-ExecBench

Tất cả issue của NVIDIA/SOL-ExecBench

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.