[Bugfix][Pooling] Handle multimodal cache misses without crashing (#58975)

Signed-off-by: linchaoying6 <linchaoying6@jd.com>
Co-authored-by: linchaoying6 <linchaoying6@jd.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Chaoying
2026-10-02 10:14:33 -04:00
committed by GitHub
co-authored by linchaoying6 OpenAI Codex
parent 443dccd3c9
commit 592c6f3fbc
21 changed files with 525 additions and 17 deletions
+8
View File
@@ -323,6 +323,14 @@ class LLMEngine:
engine_core_timestamp=outputs.timestamp,
iteration_stats=iteration_stats,
)
mm_processor_cache = self.renderer.mm_processor_cache
if mm_processor_cache is not None:
for engine_core_output in outputs.outputs:
if engine_core_output.mm_cache_miss_hashes:
for mm_hash in engine_core_output.mm_cache_miss_hashes:
mm_processor_cache.invalidate(mm_hash)
self.output_processor.update_scheduler_stats(outputs.scheduler_stats)
# 3) Abort any reqs that finished due to stop strings.
+19
View File
@@ -16,6 +16,7 @@ from vllm.outputs import (
CompletionOutput,
PoolingOutput,
PoolingRequestOutput,
RequestError,
RequestOutput,
SamplingMask,
)
@@ -304,6 +305,7 @@ class RequestState:
stop_reason: int | str | None,
kv_transfer_params: dict[str, Any] | None = None,
ec_transfer_params: dict[str, Any] | None = None,
error: RequestError | None = None,
) -> RequestOutput | PoolingRequestOutput | None:
finished = finish_reason is not None
final_only = self.output_kind == RequestOutputKind.FINAL_ONLY
@@ -342,6 +344,7 @@ class RequestState:
external_req_id,
[self._new_pooling_output(pooling_output)],
finished,
error=error,
)
output = self._new_completion_output(new_token_ids, finish_reason, stop_reason)
@@ -369,6 +372,7 @@ class RequestState:
finished: bool,
kv_transfer_params: dict[str, Any] | None = None,
ec_transfer_params: dict[str, Any] | None = None,
error: RequestError | None = None,
) -> RequestOutput | PoolingRequestOutput:
# If prompt embeds were used, put placeholder prompt token ids
prompt_token_ids = self.prompt_token_ids
@@ -385,6 +389,7 @@ class RequestState:
num_cached_tokens=self.num_cached_tokens,
prompt_token_ids=prompt_token_ids,
finished=finished,
error=error,
)
assert self.logprobs_processor is not None
if self.output_kind == RequestOutputKind.DELTA:
@@ -715,6 +720,19 @@ class OutputProcessor:
if engine_core_output.spec_decode_metrics is not None:
req_state.spec_decode_metrics = engine_core_output.spec_decode_metrics
request_error = None
if (
req_state.detokenizer is None
and engine_core_output.mm_cache_miss_hashes
and finish_reason == FinishReason.ERROR
):
request_error = RequestError(
code="multimodal_cache_miss",
message="Multi-modal processor cache miss.",
retryable=True,
)
pooling_output = EMPTY_CPU_TENSOR
if pooling_output is None:
assert req_state.detokenizer is not None
assert req_state.logprobs_processor is not None
@@ -742,6 +760,7 @@ class OutputProcessor:
stop_reason,
kv_transfer_params,
ec_transfer_params,
error=request_error,
):
if req_state.streaming_input:
request_output.finished = False
+12
View File
@@ -42,6 +42,18 @@ class LateInteractionRunner:
self._query_uses.clear()
self._doc_query_keys.clear()
def release_queries(self, query_keys: Iterable[str]) -> None:
query_keys = set(query_keys)
for query_key in query_keys:
self._query_cache.pop(query_key, None)
self._query_uses.pop(query_key, None)
self._doc_query_keys = {
req_id: query_key
for req_id, query_key in self._doc_query_keys.items()
if query_key not in query_keys
}
def register_request(
self, req_id: str, pooling_params: PoolingParams | None
) -> None:
+4
View File
@@ -1012,6 +1012,10 @@ class GPUModelRunner(LoRAModelRunnerMixin):
if self.pooling_runner is not None:
self.pooling_runner.clear()
def release_late_interaction_query_cache(self, query_keys: list[str]) -> None:
if self.pooling_runner is not None:
self.pooling_runner.release_late_interaction_query_cache(query_keys)
@torch.inference_mode()
def profile_cudagraph_memory(self) -> int:
"""Estimate the GPU memory required to capture CUDA graphs."""
@@ -98,6 +98,9 @@ class PoolingRunner:
def clear(self) -> None:
self.late_interaction_runner.clear()
def release_late_interaction_query_cache(self, query_keys: list[str]) -> None:
self.late_interaction_runner.release_queries(query_keys)
def _get_pooling_metadata(
self,
input_batch: InputBatch,
+3
View File
@@ -993,6 +993,9 @@ class GPUModelRunner(
self.encoder_cache.clear()
self.late_interaction_runner.clear()
def release_late_interaction_query_cache(self, query_keys: list[str]) -> None:
self.late_interaction_runner.release_queries(query_keys)
def _get_positions(self, num_tokens: Any):
if isinstance(num_tokens, int):
if self.uses_mrope:
+7
View File
@@ -143,6 +143,13 @@ class WorkerBase:
if callable(reset_fn):
reset_fn()
def release_late_interaction_query_cache(self, query_keys: list[str]) -> None:
release_fn = getattr(
self.model_runner, "release_late_interaction_query_cache", None
)
if callable(release_fn):
release_fn(query_keys)
def get_model(self) -> nn.Module:
raise NotImplementedError