[Model Runner V2] Gather multimodal embeddings before draft model postprocess (#37932)
Signed-off-by: Giancarlo Delfin <gdelfin@inferact.ai>
This commit is contained in:
@@ -1162,23 +1162,12 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
|||||||
copy_event=self.output_copy_event,
|
copy_event=self.output_copy_event,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Postprocess results and update request states.
|
|
||||||
# NOTE: This is intentionally done after creating the AsyncOutput,
|
|
||||||
# ensuring that `copy_event` is recorded before calling postprocess.
|
|
||||||
# This sequencing may slightly reduce latency as async D2H copy does not
|
|
||||||
# need to wait for the postprocess to finish.
|
|
||||||
self.postprocess(
|
|
||||||
input_batch, sampler_output.sampled_token_ids, num_sampled, num_rejected
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.speculator is not None:
|
|
||||||
assert self.sampler is not None
|
|
||||||
mm_inputs: tuple[list[torch.Tensor], torch.Tensor] | None = None
|
mm_inputs: tuple[list[torch.Tensor], torch.Tensor] | None = None
|
||||||
if self.speculator.supports_mm_inputs:
|
if self.speculator is not None and self.speculator.supports_mm_inputs:
|
||||||
# Get cached multimodal embeddings for draft forward.
|
# Get cached multimodal embeddings for draft forward.
|
||||||
prefill_lens = self.req_states.prefill_len.np[
|
# NOTE: This is done here because postprocess updates
|
||||||
input_batch.idx_mapping_np
|
# num_computed_prefill_tokens.
|
||||||
]
|
prefill_lens = self.req_states.prefill_len.np[input_batch.idx_mapping_np]
|
||||||
computed_prefill_lens = self.req_states.num_computed_prefill_tokens[
|
computed_prefill_lens = self.req_states.num_computed_prefill_tokens[
|
||||||
input_batch.idx_mapping_np
|
input_batch.idx_mapping_np
|
||||||
]
|
]
|
||||||
@@ -1191,6 +1180,17 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
|||||||
computed_prefill_lens + 1, # +1 to consider the skew in eagle
|
computed_prefill_lens + 1, # +1 to consider the skew in eagle
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Postprocess results and update request states.
|
||||||
|
# NOTE: This is intentionally done after creating the AsyncOutput,
|
||||||
|
# ensuring that `copy_event` is recorded before calling postprocess.
|
||||||
|
# This sequencing may slightly reduce latency as async D2H copy does not
|
||||||
|
# need to wait for the postprocess to finish.
|
||||||
|
self.postprocess(
|
||||||
|
input_batch, sampler_output.sampled_token_ids, num_sampled, num_rejected
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.speculator is not None:
|
||||||
|
assert self.sampler is not None
|
||||||
draft_tokens = self.speculator.propose(
|
draft_tokens = self.speculator.propose(
|
||||||
input_batch,
|
input_batch,
|
||||||
attn_metadata,
|
attn_metadata,
|
||||||
|
|||||||
Reference in New Issue
Block a user