Tiny extract ModelRunnerOutput (#15400)
This commit is contained in:
@@ -268,6 +268,12 @@ class RankZeroFilter(logging.Filter):
|
||||
return True
|
||||
|
||||
|
||||
@dataclass
|
||||
class ModelRunnerOutput:
|
||||
logits_output: Union[LogitsProcessorOutput, PPProxyTensors]
|
||||
can_run_graph: bool
|
||||
|
||||
|
||||
class ModelRunner:
|
||||
"""ModelRunner runs the forward passes of the models."""
|
||||
|
||||
@@ -2726,7 +2732,7 @@ class ModelRunner:
|
||||
pp_proxy_tensors: Optional[PPProxyTensors] = None,
|
||||
reinit_attn_backend: bool = False,
|
||||
split_forward_count: int = 1,
|
||||
) -> Tuple[Union[LogitsProcessorOutput, PPProxyTensors], bool]:
|
||||
) -> ModelRunnerOutput:
|
||||
self.forward_pass_id += 1
|
||||
|
||||
with get_global_expert_distribution_recorder().with_forward_pass(
|
||||
@@ -2753,7 +2759,7 @@ class ModelRunner:
|
||||
pp_proxy_tensors: Optional[PPProxyTensors],
|
||||
reinit_attn_backend: bool = False,
|
||||
split_forward_count: int = 1,
|
||||
) -> Tuple[Union[LogitsProcessorOutput, PPProxyTensors], bool]:
|
||||
) -> ModelRunnerOutput:
|
||||
mode_check = (
|
||||
forward_batch.forward_mode.is_cpu_graph
|
||||
if self.device == "cpu"
|
||||
@@ -2771,7 +2777,7 @@ class ModelRunner:
|
||||
skip_attn_backend_init=skip_attn_backend_init,
|
||||
pp_proxy_tensors=pp_proxy_tensors,
|
||||
)
|
||||
return ret, can_run_graph
|
||||
return ModelRunnerOutput(logits_output=ret, can_run_graph=can_run_graph)
|
||||
|
||||
# For MLP sync
|
||||
if forward_batch.global_num_tokens_cpu is not None:
|
||||
@@ -2819,7 +2825,7 @@ class ModelRunner:
|
||||
):
|
||||
forward_batch.post_forward_mlp_sync_batch(ret)
|
||||
|
||||
return ret, can_run_graph
|
||||
return ModelRunnerOutput(logits_output=ret, can_run_graph=can_run_graph)
|
||||
|
||||
def _preprocess_logits(
|
||||
self, logits_output: LogitsProcessorOutput, sampling_info: SamplingBatchInfo
|
||||
|
||||
Reference in New Issue
Block a user