-
Notifications
You must be signed in to change notification settings - Fork 503
Give each rollout cell a health checker driven by its own state #2111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import asyncio | ||
| import dataclasses | ||
| import logging | ||
| from collections.abc import Callable | ||
| from dataclasses import dataclass | ||
| from typing import Any, Literal | ||
|
|
||
|
|
@@ -18,6 +19,13 @@ | |
| StateServing, | ||
| StateUninitialized, | ||
| ) | ||
| from miles.utils.ft_utils.health_checker import ( | ||
| ActiveAndEpoch, | ||
| BaseHealthChecker, | ||
| NoopHealthChecker, | ||
| SimpleHealthChecker, | ||
| SimpleHealthCheckerConfig, | ||
| ) | ||
| from miles.utils.pydantic_utils import FrozenStrictBaseModel | ||
| from miles.utils.workers.launch_gate import GATE_PORT_NAME, activate_launch_gate | ||
| from miles.utils.workers.worker_provider.base import BaseWorkerProvider | ||
|
|
@@ -46,8 +54,35 @@ class ServerCell: | |
| args: Any | ||
| meta: ServerCellMetadata | ||
| router_api_client: SGLangRouterApiClient | ||
| global_health_checker_activeness: Callable[[], ActiveAndEpoch] = lambda: ActiveAndEpoch(active=True, epoch=0) | ||
| _health_checker: BaseHealthChecker = dataclasses.field(init=False) | ||
| _state: CellState = dataclasses.field(default_factory=StateUninitialized) | ||
|
|
||
| def __post_init__(self) -> None: | ||
| self._health_checker = create_rollout_cell_health_checker( | ||
| args=self.args, | ||
| name=f"rollout-cell-{self.meta.cell_id}", | ||
| get_api_client=lambda: self.api_client, | ||
| get_activeness=self._get_health_checker_active_and_epoch, | ||
| ) | ||
| self._health_checker.start() | ||
|
|
||
| def _get_health_checker_active_and_epoch(self) -> ActiveAndEpoch: | ||
| controller_active_and_epoch = self.global_health_checker_activeness() | ||
| cell_active = isinstance(self._state, (StatePendingWeights, StateServing)) | ||
| return ActiveAndEpoch( | ||
| active=cell_active and controller_active_and_epoch.active, epoch=controller_active_and_epoch.epoch | ||
| ) | ||
|
|
||
| def __del__(self) -> None: | ||
| assert isinstance(self._state, StateDisposed), ( | ||
| f"ServerCell {self.meta.cell_id} was garbage collected without dispose() ({self._state=}); " | ||
| "every cell must be disposed so its health checker task is stopped" | ||
| ) | ||
|
|
||
| async def cancel_inflight_health_probe(self) -> None: | ||
| await self._health_checker.cancel_inflight_probe() | ||
|
|
||
| @property | ||
| def is_uninitialized(self) -> bool: | ||
| return isinstance(self._state, StateUninitialized) | ||
|
|
@@ -122,9 +157,7 @@ async def _tick_when_initializing(self) -> None: | |
|
|
||
| async def mark_weights_ready(self) -> None: | ||
| assert isinstance(self._state, StatePendingWeights), f"{self._state=}" | ||
|
|
||
| await self._register_with_router(addr_info=self._state.addr_info) | ||
|
|
||
| self._mark_serving() | ||
|
|
||
| async def _register_with_router(self, addr_info: CellAddrInfo) -> None: | ||
|
|
@@ -136,6 +169,8 @@ async def _register_with_router(self, addr_info: CellAddrInfo) -> None: | |
| ) | ||
|
|
||
| async def dispose(self) -> None: | ||
| self._health_checker.stop() | ||
|
|
||
| match self._state: | ||
| case StateServing(): | ||
| await self._unregister_from_router() | ||
|
|
@@ -211,3 +246,21 @@ async def check_weights(self, action: str, allow_quant_error: bool, selector: st | |
|
|
||
| def compute_nodes_per_engine(*, num_gpus_per_engine: int, num_gpus_per_node: int) -> int: | ||
| return max(1, num_gpus_per_engine // num_gpus_per_node) | ||
|
|
||
|
|
||
| def create_rollout_cell_health_checker( | ||
| *, | ||
| args: Any, | ||
| name: str, | ||
| get_api_client: Callable[[], SGLangApiClient], | ||
| get_activeness: Callable[[], ActiveAndEpoch], | ||
| ) -> BaseHealthChecker: | ||
| if "rollout" not in args.ft_components: | ||
| return NoopHealthChecker() | ||
|
|
||
| config = SimpleHealthCheckerConfig.from_args(args, prefix="rollout_health_check") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Restore the rollout-specific failure threshold default. This checker reads the shared default of 3, so with the 30s rollout interval a dead engine is not reported unhealthy until roughly the third failed poll (~90s), instead of the previous first-failure contract (~30s). Please keep the trainer heartbeat default at 3, but make the rollout prefix default to 1. |
||
|
|
||
| async def _check() -> None: | ||
| await get_api_client().health_generate(timeout=config.timeout) | ||
|
|
||
| return SimpleHealthChecker(name=name, check_fn=_check, get_activeness=get_activeness, config=config) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Please make a failed cell initialization retryable.
add_cellpublishes the cell before awaitingcell.init(), so a transient failure leaves a same-hashStateUninitializedcell that subsequent reconciliation treats as converged. This permanently prevents a non-colocated rollout replacement from initializing. Please dispose the cell on failure and only insert it after successful initialization.