Skip to content

[BugFix] Defer encoder cache eviction while entries are referenced by in-flight requests - #45199

Closed
ywang96 wants to merge 1 commit into
vllm-project:mainfrom
ywang96:fix-encoder-cache-deferred-eviction
Closed

ywang96 wants to merge 1 commit into
vllm-project:mainfrom
ywang96:fix-encoder-cache-deferred-eviction

Conversation

@ywang96

@ywang96 ywang96 commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

No description provided.

… in-flight requests

The scheduler requests eviction of GPU-resident encoder outputs based on
its own bookkeeping of request progress, which can be stale by the time
the worker acts on it:

- Under async scheduling, num_computed_tokens is advanced speculatively
  and rolled back when draft tokens are rejected, so an entry freed as
  "fully consumed" can be needed again on the next step.
- The spec-decode drafter reads a +1-shifted window and can need an entry
  one step longer than the target model.
- Entries are keyed by content hash and shared across concurrent requests,
  so one request's completion can evict an entry another request needs.

Any of these races crashes the engine with
"AssertionError: Encoder cache miss" in _gather_mm_embeddings,
killing all in-flight requests (issue vllm-project#38551).

Fix: EncoderCache now tracks which in-flight requests reference each
mm_hash. A scheduler-requested eviction of a still-referenced entry is
deferred until the last referencing request is removed; unreferenced
entries are evicted eagerly as before. Memory overhead is bounded by the
encoder outputs of in-flight requests (unlike full retention, which is
unbounded). Encoder-decoder models (e.g. Whisper) keep eager eviction
since the scheduler only frees their entries once provably dead.

The same policy is applied to both the new gpu/ worker architecture
(EncoderCache was already request-aware) and the legacy gpu_model_runner
(via a tracker sharing the existing encoder_cache dict).

FIX vllm-project#38551

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Roger Wang <hey@rogerw.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant