From c9611215195eaaaa49a9ef6b65c1b28abd15e8ed Mon Sep 17 00:00:00 2001 From: Tianyu Guo Date: Wed, 23 Sep 2026 17:25:32 +0800 Subject: [PATCH] [Bugfix] Disable prefix caching for encoder-only before model config hooks (#58287) Signed-off-by: Tianyu Guo --- vllm/config/vllm.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/vllm/config/vllm.py b/vllm/config/vllm.py index 8be154d3ed..e1c80be67b 100644 --- a/vllm/config/vllm.py +++ b/vllm/config/vllm.py @@ -1340,6 +1340,19 @@ class VllmConfig: self._resolve_mm_encoder_only() + if self.is_mm_encoder_only and self.cache_config.enable_prefix_caching: + # Such an instance publishes encoder embeddings and runs no language + # model, so it holds no KV cache for prefix caching to reuse and its + # coordinator would have no group to manage. Disable before + # `try_verify_and_update_config` so model config hooks (e.g. the + # hybrid mamba hook setting `mamba_block_size`) already see prefix + # caching as disabled. + logger.info( + "Disabling prefix caching: this instance runs the " + "multi-modal encoder only." + ) + self.cache_config.enable_prefix_caching = False + if self.performance_mode != "balanced": logger.info_once("Performance mode set to '%s'.", self.performance_mode) @@ -2089,16 +2102,6 @@ class VllmConfig: self._post_init_kv_transfer_config() self._verify_aux_output_compatibility() - if self.is_mm_encoder_only and self.cache_config.enable_prefix_caching: - # Such an instance publishes encoder embeddings and runs no language - # model, so it holds no KV cache for prefix caching to reuse and its - # coordinator would have no group to manage. - logger.info( - "Disabling prefix caching: this instance runs the " - "multi-modal encoder only." - ) - self.cache_config.enable_prefix_caching = False - # Hybrid KV cache manager (HMA) runtime rules: # - Explicit enable (--no-disable-kv-cache-manager): error if runtime # disables it