From ad720aefe909e5a49629944fc45c09f5ee31d857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Crn=C4=8Devi=C4=87?= Date: Fri, 10 Apr 2026 10:09:46 +0200 Subject: [PATCH] [Bugfix] Fix V1 dummy run writing NaN to KV cache null block (#39444) Signed-off-by: Elvir Crncevic Co-authored-by: Claude Sonnet 4 --- vllm/v1/worker/gpu_model_runner.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vllm/v1/worker/gpu_model_runner.py b/vllm/v1/worker/gpu_model_runner.py index 8dcac7bd08..d1ec9126ce 100644 --- a/vllm/v1/worker/gpu_model_runner.py +++ b/vllm/v1/worker/gpu_model_runner.py @@ -5356,12 +5356,18 @@ class GPUModelRunner( attn_metadata: PerLayerAttnMetadata | None = None slot_mappings_by_group, slot_mappings = self._get_slot_mappings( - num_tokens_padded=num_tokens, + num_tokens_padded=num_tokens_padded, num_reqs_padded=num_reqs_padded, num_tokens_unpadded=num_tokens_unpadded, ubatch_slices=ubatch_slices_padded, ) + # Dummy runs have no real slot assignments — fill with -1 so + # concat_and_cache kernels skip the KV write. + if slot_mappings_by_group is not None: + for sm in slot_mappings_by_group.values(): + sm.fill_(-1) + # _dummy_run shares pinned CPU buffers (seq_lens, query_start_loc, # etc.) with execute_model. It must participate in the same event # protocol so that back-to-back dummy/real steps don't overwrite