[MRV2] Collect KV transfer results before the drafter runs (#62041)

Signed-off-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Hill
2026-10-17 10:27:57 -07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 763e3f7c91
commit 0c5dd18e7a
3 changed files with 52 additions and 10 deletions
+8 -3
View File
@@ -2207,6 +2207,12 @@ class GPUModelRunner(LoRAModelRunnerMixin):
pending_aux_output=pending_aux_output,
)
# Collect KV transfer results now; finalize saves after the drafter runs.
defer_kv_finalize = self.speculator is not None
model_runner_output.kv_connector_output = self.kv_connector.post_forward(
finished_req_ids, defer_finalize=defer_kv_finalize
)
mm_inputs: tuple[list[torch.Tensor], torch.Tensor] | None = None
# The encoder runner exists only on the first PP rank, so later ranks
# have no cached embeddings to gather.
@@ -2288,9 +2294,8 @@ class GPUModelRunner(LoRAModelRunnerMixin):
self.req_states.draft_tokens, input_batch
)
# Post-step KV connector related operations.
kv_connector_output = self.kv_connector.post_forward(finished_req_ids)
model_runner_output.kv_connector_output = kv_connector_output
if defer_kv_finalize:
self.kv_connector.finalize_step()
model_runner_output.ec_connector_output = ec_connector_output
return async_output