[Perf][DSV4.1] Optimize MegaMoE staging and NVFP4 cache gathers (#57604)

Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Woosuk Kwon
2026-09-18 12:57:19 -07:00
committed by GitHub
co-authored by Codex
parent 23e26e0588
commit 50d812b66a
5 changed files with 130 additions and 62 deletions
@@ -584,7 +584,11 @@ def dequantize_and_gather_k_cache_triton(
num_reqs = seq_lens.shape[0]
NUM_WORKERS = 128
if k_cache.shape[-1] == V41_NVFP4_BYTES_PER_TOKEN:
_dequantize_and_gather_k_nvfp4_kernel[(num_reqs, NUM_WORKERS)](
# Keep short gathers unchanged; cap total workers for multi-request chunks.
num_workers = min(
max(128, 2048 // max(1, num_reqs)), max(128, out.shape[1] - offset)
)
_dequantize_and_gather_k_nvfp4_kernel[(num_reqs, num_workers)](
out,
out.stride(0),
out.stride(1),