Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions kernels/layer_norm_fp8.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ def layernorm_quant_kernel(
max_val = tl.max(tl.abs(y_fp32), axis=0)
scale = max_val / 448.0 # 448 is the max value for FP8-E4M3

y_fp8 = (y_fp32 / scale).to(tl.float8e4m3fn)
y_fp8 = (y_fp32 / scale).to(tl.float8e4nv)

# 3. Store the FP8 data and the scale factor
# 3. Store the FP8 data and the per-row scale factor
tl.store(Y_ptr + cols, y_fp8, mask=mask)
if tl.program_id(0) == 0: # Store the scale once for the whole tensor or per row
tl.store(Scale_ptr + row_idx, scale)
tl.store(Scale_ptr + row_idx, scale)

def layernorm_fp8(x, w, b):
M, N = x.shape
Expand Down