[BugFix] Avoid prematurely freeing cached mm encoder outputs (#45347)

Signed-off-by: Roger Wang <hey@rogerw.io>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
Nick Hill
2026-06-12 15:39:40 -07:00
committed by GitHub
parent e3e31e54b0
commit 1a369783e9
2 changed files with 182 additions and 3 deletions
+8 -3
View File
@@ -1808,9 +1808,14 @@ class Scheduler(SchedulerInterface):
# we know we're done with the encoder input. Cross Attention
# KVs have been calculated and cached already.
self.encoder_cache_manager.free_encoder_input(request, input_id)
elif start_pos + num_tokens <= request.num_computed_tokens:
# The encoder output is already processed and stored
# in the decoder's KV cache.
elif (
start_pos + num_tokens
<= request.num_computed_tokens - request.num_output_placeholders
):
# The encoder output is already processed and stored in the
# decoder's KV cache, and progress is far enough past the
# placeholder range that no pending draft-token rejection can
# roll num_computed_tokens back into it.
self.encoder_cache_manager.free_encoder_input(request, input_id)
def update_draft_token_ids(self, draft_token_ids: DraftTokenIds) -> None: