From 24a03915f525b88ebc4c36127c3e9ccf56dc21ee Mon Sep 17 00:00:00 2001 From: Itay Alroy <75032521+itayalroy@users.noreply.github.com> Date: Sat, 7 Mar 2026 02:36:00 +0200 Subject: [PATCH] mla: don't update kv cache on dummy forwards (#36282) Signed-off-by: Itay Alroy --- vllm/model_executor/layers/attention/mla_attention.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vllm/model_executor/layers/attention/mla_attention.py b/vllm/model_executor/layers/attention/mla_attention.py index 926e8892ea..b0e16fa524 100644 --- a/vllm/model_executor/layers/attention/mla_attention.py +++ b/vllm/model_executor/layers/attention/mla_attention.py @@ -905,6 +905,10 @@ def unified_mla_kv_cache_update( the data dependency between them to ensure torch.compile preserves ordering. """ forward_context = get_forward_context() + if forward_context.attn_metadata is None: + # Dummy/profile forwards should not update live KV cache pages. + return torch.empty(0, device=kv_c_normed.device, dtype=kv_c_normed.dtype) + attn_layer = forward_context.no_compile_layers[layer_name] kv_cache = attn_layer.kv_cache[forward_context.virtual_engine]