From f6af9cce65dfc639b79df484eeb4df2b66745cfc Mon Sep 17 00:00:00 2001 From: Alexander Chaiko Date: Thu, 3 Sep 2026 10:24:26 -0700 Subject: [PATCH] Scale out of place --- vllm/model_executor/models/whisper_causal.py | 28 +++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/vllm/model_executor/models/whisper_causal.py b/vllm/model_executor/models/whisper_causal.py index d76e9b0d4a69..ed04e146b43c 100644 --- a/vllm/model_executor/models/whisper_causal.py +++ b/vllm/model_executor/models/whisper_causal.py @@ -158,13 +158,27 @@ def build( fast_build: bool = False, ) -> AttentionMetadata: new_common_attn_metadata = copy.deepcopy(common_attn_metadata) - new_common_attn_metadata.query_start_loc *= block_pool_size - new_common_attn_metadata.query_start_loc_cpu *= block_pool_size - new_common_attn_metadata.seq_lens *= block_pool_size - if new_common_attn_metadata._seq_lens_cpu is not None: - new_common_attn_metadata._seq_lens_cpu *= block_pool_size - if new_common_attn_metadata._num_computed_tokens_cpu is not None: - new_common_attn_metadata._num_computed_tokens_cpu *= block_pool_size + # Scale out of place: the V1 CPU model runner points every + # `CpuGpuBuffer.gpu` at its `.cpu` tensor, so a device field and its + # `_cpu` counterpart can share storage (`deepcopy` preserves the + # sharing), and in-place scaling would apply `block_pool_size` twice. + new_common_attn_metadata.query_start_loc = ( + common_attn_metadata.query_start_loc * block_pool_size + ) + new_common_attn_metadata.query_start_loc_cpu = ( + common_attn_metadata.query_start_loc_cpu * block_pool_size + ) + new_common_attn_metadata.seq_lens = ( + common_attn_metadata.seq_lens * block_pool_size + ) + if common_attn_metadata._seq_lens_cpu is not None: + new_common_attn_metadata._seq_lens_cpu = ( + common_attn_metadata._seq_lens_cpu * block_pool_size + ) + if common_attn_metadata._num_computed_tokens_cpu is not None: + new_common_attn_metadata._num_computed_tokens_cpu = ( + common_attn_metadata._num_computed_tokens_cpu * block_pool_size + ) new_common_attn_metadata.num_actual_tokens *= block_pool_size new_common_attn_metadata.max_query_len *= block_pool_size new_common_attn_metadata.max_seq_len *= block_pool_size