[Spec Decode] Update extract_hidden_states to use deferred kv_connector clear (#37013)

This commit is contained in:
Fynn Schmitt-Ulms
2026-03-16 14:53:45 +01:00
committed by GitHub
parent 43a73f853b
commit 04bf5a35fa
4 changed files with 34 additions and 69 deletions
+1 -12
View File
@@ -4328,23 +4328,12 @@ class GPUModelRunner(
)
target_hidden_states = [h[:num_scheduled_tokens] for h in aux_hidden_states]
draft_token_ids, drafter_kv_connector_output = self.drafter.propose(
draft_token_ids = self.drafter.propose(
sampled_token_ids=sampled_token_ids,
target_hidden_states=target_hidden_states,
common_attn_metadata=common_attn_metadata,
scheduler_output=scheduler_output,
slot_mappings=slot_mappings,
)
# Combine KVConnectorOutputs or select the non-empty one
if self.kv_connector_output and drafter_kv_connector_output:
self.kv_connector_output = KVConnectorOutput.merge(
self.kv_connector_output, drafter_kv_connector_output
)
else:
self.kv_connector_output = (
self.kv_connector_output or drafter_kv_connector_output
)
next_token_ids, valid_sampled_tokens_count = (
self.drafter.prepare_next_token_ids_padded(
common_attn_metadata,