Skip to content

Commit 9b4e978

Browse files
Merge pull request deepseek-ai#969 from youkaichao/rmsnorm
act_quant_kernel
2 parents 82f6008 + adecc0e commit 9b4e978

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

inference/kernel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def act_quant_kernel(x_ptr, y_ptr, s_ptr, BLOCK_SIZE: tl.constexpr, scale_fmt: t
2323
pid = tl.program_id(axis=0)
2424
offs = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
2525
x = tl.load(x_ptr + offs).to(tl.float32)
26-
amax = tl.max(tl.abs(x), 1e-4)
26+
amax = tl.max(tl.abs(x)) # reduction
27+
amax = tl.maximum(amax, 1e-4) # clamp to 1e-4
2728
s = amax / 448.
2829
if scale_fmt == "ue8m0":
2930
exp = tl.math.ceil(tl.math.log2(s))

0 commit comments

Comments
 (0)