[Model Runner V2] Support randomized dummy inputs (#58411)
Signed-off-by: Robert Shaw <robshaw@redhat.com> Co-authored-by: Robert Shaw <robshaw@redhat.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
co-authored by
Robert Shaw
Claude Opus 5.5
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Nick Hill
parent
5addde2a0a
commit
e5e38ba9b7
@@ -805,6 +805,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
skip_eplb: bool = False,
|
||||
is_profile: bool = False,
|
||||
valid_dummy_state_slots: bool = False,
|
||||
randomize_inputs: bool = False,
|
||||
**kwargs,
|
||||
) -> tuple[torch.Tensor | None, torch.Tensor | None]:
|
||||
if skip_attn and not is_profile:
|
||||
@@ -878,6 +879,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
is_profile=is_profile,
|
||||
context_len=context_len,
|
||||
valid_dummy_state_slots=valid_dummy_state_slots,
|
||||
randomize_inputs=randomize_inputs,
|
||||
)
|
||||
self.kv_connector.set_disabled(False)
|
||||
|
||||
@@ -968,7 +970,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
self.pooling_runner.dummy_pooler_run(hidden_states)
|
||||
|
||||
@torch.inference_mode()
|
||||
def profile_run(self) -> None:
|
||||
def profile_run(self, randomize_inputs: bool = False) -> None:
|
||||
if self.supports_mm_inputs and self.is_first_pp_rank:
|
||||
mm_config = self.model_config.multimodal_config
|
||||
if mm_config is not None and not mm_config.skip_mm_profiling:
|
||||
@@ -981,7 +983,10 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
)
|
||||
|
||||
hidden_states, sample_hidden_states = self._dummy_run(
|
||||
self.max_num_tokens, skip_attn=True, is_profile=True
|
||||
self.max_num_tokens,
|
||||
skip_attn=True,
|
||||
is_profile=True,
|
||||
randomize_inputs=randomize_inputs,
|
||||
)
|
||||
|
||||
# Only run sampler/pooler on last PP rank (non-last ranks return None).
|
||||
@@ -1696,6 +1701,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
is_profile: bool = False,
|
||||
context_len: int = 0,
|
||||
valid_dummy_state_slots: bool = False,
|
||||
randomize_inputs: bool = False,
|
||||
) -> ModelRunnerOutput | IntermediateTensors | None:
|
||||
if not dummy_run:
|
||||
# Update the request states.
|
||||
@@ -1814,6 +1820,9 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
# so MoE memory is measured and MoE kernels are exercised.
|
||||
is_padding=not is_profile,
|
||||
)
|
||||
if randomize_inputs:
|
||||
# All-zero input_ids route every token to the same experts.
|
||||
input_batch.input_ids.random_(0, self.vocab_size)
|
||||
if self.pcp_manager is not None:
|
||||
input_batch = self.pcp_manager.prepare_inputs_to_capture(input_batch)
|
||||
if skip_attn_for_dummy_run:
|
||||
|
||||
Reference in New Issue
Block a user