[Perf][Kernel] Initialize NVFP4 padding in quant kernel (#53568)

Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Roberto L. Castro
2026-09-01 09:49:07 -07:00
committed by GitHub
co-authored by Codex mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent cdefd9d499
commit 514c7314a0
3 changed files with 91 additions and 27 deletions
+3 -7
View File
@@ -57,13 +57,9 @@ def create_fp4_scale_tensor(
rounded_m = round_up(m, 128)
scale_n = n // block_size
rounded_n = round_up(scale_n, 4)
# Must be zero-initialized: the swizzled scale buffer is padded to
# (round_up(m, 128), round_up(scale_n, 4) // 4) but the NVFP4 quant
# kernel does not write every padded element that the downstream
# NVFP4 GEMM reads. torch.empty leaves those padded scale factors
# uninitialized, which corrupts dequantization and causes a severe
# Blackwell NVFP4 decode throughput/output-length regression.
return torch.zeros(
# The NVFP4 quant kernel explicitly zeroes every padded scale entry,
# so no separate zero-initialization kernel is required here.
return torch.empty(
(rounded_m, rounded_n // 4), device=device, dtype=torch.int32
)
else: