[ROCM] Optimized deepseek-r1 model with rmsnorm + fp8 quant fusion (#12689)

should be clean after https://github.com/sgl-project/sglang/pull/13017 landed
This commit is contained in:
yctseng0211
2025-11-11 18:59:10 +08:00
committed by GitHub
parent ea10a9d165
commit 4a78031a71
6 changed files with 331 additions and 22 deletions

View File

@@ -263,19 +263,32 @@ def aiter_w8a8_block_fp8_linear(
input_scale: Optional[torch.Tensor] = None,
bias: Optional[torch.Tensor] = None,
) -> torch.Tensor:
assert input_scale is None
# assert input_scale is None
input_2d = input.view(-1, input.shape[-1])
output_shape = [*input.shape[:-1], weight.shape[0]]
q_input, x_scale = aiter_per1x128_quant(input_2d, quant_dtype=aiter.dtypes.fp8)
# if input_scale not None, input is quanted
if input_scale is not None:
q_input = input_2d
x_scale = input_scale
else:
q_input, x_scale = aiter_per1x128_quant(input_2d, quant_dtype=aiter.dtypes.fp8)
output = gemm_a8w8_blockscale(
q_input, weight, x_scale, weight_scale, dtype=input.dtype
q_input,
weight,
x_scale,
weight_scale,
dtype=torch.bfloat16 if input_scale is not None else input.dtype,
)
if bias is not None:
output += bias
return output.to(dtype=input_2d.dtype).view(*output_shape)
return output.to(
dtype=torch.bfloat16 if input_scale is not None else input_2d.dtype
).view(*output_shape)
def triton_w8a8_block_fp8_linear(