[Kernel] Remove scaled_fp8_quant kernel padding footgun (#6842)

This commit is contained in:
Tyler Michael Smith
2024-07-30 16:37:01 -04:00
committed by GitHub
parent 052b6f8ca4
commit d7a299edaa
3 changed files with 17 additions and 14 deletions

View File

@@ -139,7 +139,7 @@ def apply_fp8_linear(
qinput, x_scale = ops.scaled_fp8_quant(
input,
input_scale,
batch_dim_padding=17,
num_token_padding=17,
use_per_token_if_dynamic=use_per_token_if_dynamic)
per_tensor_weights = (weight_scale.numel() == 1)
@@ -177,8 +177,9 @@ def apply_fp8_linear(
output, _ = torch._scaled_mm(qinput,
weight,
out_dtype=torch.float32)
# Unpad (undo batch_dim_padding)
# Unpad (undo num_token_padding)
output = torch.narrow(output, 0, 0, input.shape[0])
x_scale = torch.narrow(x_scale, 0, 0, input.shape[0])
# DQ
# C = sw * sx * (X * W) + bias