[Bugfix] Disable prefix caching for encoder-only before model config hooks (#58287)
Signed-off-by: Tianyu Guo <guoty@inferact.ai>
Tianyu Guo committed
Sep 23, 2026 at 17:25 UTC
c9611215195eaaaa49a9ef6b65c1b28abd15e8ed
1 file changed
+13
-10
vllm/config/vllm.py
+13
-10
@@ -1340,6 +1340,19 @@ class VllmConfig:
1340
1341
self._resolve_mm_encoder_only()
1342
1343
+ if self.is_mm_encoder_only and self.cache_config.enable_prefix_caching:
1344
+ # Such an instance publishes encoder embeddings and runs no language
1345
+ # model, so it holds no KV cache for prefix caching to reuse and its
1346
+ # coordinator would have no group to manage. Disable before
1347
+ # `try_verify_and_update_config` so model config hooks (e.g. the
1348
+ # hybrid mamba hook setting `mamba_block_size`) already see prefix
1349
+ # caching as disabled.
1350
+ logger.info(
1351
+ "Disabling prefix caching: this instance runs the "
1352
+ "multi-modal encoder only."
1353
+ )
1354
+ self.cache_config.enable_prefix_caching = False
1355
+
1356
if self.performance_mode != "balanced":
1357
logger.info_once("Performance mode set to '%s'.", self.performance_mode)
1358
@@ -2089,16 +2102,6 @@ class VllmConfig:
2102
self._post_init_kv_transfer_config()
2103
self._verify_aux_output_compatibility()
2104
2092
- if self.is_mm_encoder_only and self.cache_config.enable_prefix_caching:
2093
- # Such an instance publishes encoder embeddings and runs no language
2094
- # model, so it holds no KV cache for prefix caching to reuse and its
2095
- # coordinator would have no group to manage.
2096
- logger.info(
2097
- "Disabling prefix caching: this instance runs the "
2098
- "multi-modal encoder only."
2099
- )
2100
- self.cache_config.enable_prefix_caching = False
2101
-
2105
# Hybrid KV cache manager (HMA) runtime rules:
2106
# - Explicit enable (--no-disable-kv-cache-manager): error if runtime
2107
# disables it