[MRV2] Keep warmup out of the EPLB load stats (#56716)
Signed-off-by: almogtavor <almogtavor@gmail.com> Co-authored-by: Itay Alroy <75032521+itayalroy@users.noreply.github.com>
This commit is contained in:
co-authored by
Itay Alroy
parent
f43d7e1a0f
commit
87e7dce3a7
@@ -49,10 +49,12 @@ def step_eplb_after(*, is_dummy: bool = False) -> Callable:
|
||||
def decorator(fn: Callable) -> Callable:
|
||||
@wraps(fn)
|
||||
def wrapper(self: Any, *args, **kwargs) -> Any:
|
||||
result = fn(self, *args, **kwargs)
|
||||
if kwargs.get("skip_eplb", False):
|
||||
return result
|
||||
# The router kernel records load before step() is reached.
|
||||
with self.eplb.suppress():
|
||||
return fn(self, *args, **kwargs)
|
||||
|
||||
result = fn(self, *args, **kwargs)
|
||||
is_profile = kwargs.get("is_profile", False) if is_dummy else False
|
||||
self.eplb.step(is_dummy=is_dummy, is_profile=is_profile)
|
||||
return result
|
||||
@@ -91,6 +93,24 @@ class EPLBController:
|
||||
self.suppressed = False
|
||||
self._has_registered_models = False
|
||||
|
||||
@contextmanager
|
||||
def suppress(self) -> Iterator[None]:
|
||||
"""Keep warmup forwards from stepping EPLB or recording expert load."""
|
||||
should_record = (
|
||||
self.state.should_record_tensor if self.state is not None else None
|
||||
)
|
||||
was_suppressed = self.suppressed
|
||||
was_recording = should_record.clone() if should_record is not None else None
|
||||
self.suppressed = True
|
||||
if should_record is not None:
|
||||
should_record.fill_(False)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if should_record is not None and was_recording is not None:
|
||||
should_record.copy_(was_recording)
|
||||
self.suppressed = was_suppressed
|
||||
|
||||
def prepare_load(self) -> None:
|
||||
self.state = None
|
||||
self._has_registered_models = False
|
||||
|
||||
Reference in New Issue
Block a user