Repository navigation
[train][3/n] Add the health NodeMonitor: a per-node agent for NodeProbes - #66650
Conversation
acb60b0 to
df7f134
Compare
df7f134 to
a4e74d2
Compare
a4e74d2 to
a73a3e9
Compare
a73a3e9 to
d6e59f5
Compare
d6e59f5 to
6aaab3b
Compare
6aaab3b to
da0568c
Compare
da0568c to
c434b6c
Compare
c434b6c to
561c652
Compare
561c652 to
a04fd1d
Compare
a04fd1d to
09fcf9d
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a node health monitoring system for Ray Train, consisting of NodeMonitor to sample node probes in background threads, NodeMonitorGroup to manage monitor actors across multiple nodes, and a comprehensive test suite. The reviewer feedback highlights critical thread-safety issues in NodeMonitor where dictionary updates from background threads could cause race conditions or runtime errors, suggesting the use of a threading.Lock to synchronize access. Additionally, the reviewer suggests avoiding potential indefinite blocking in NodeMonitorGroup.poll_status when no timeout is specified, and refactoring the actor initialization in NodeMonitorGroup to register the remote class once during initialization rather than dynamically on start.
09fcf9d to
e61ead6
Compare
e61ead6 to
3cfc53b
Compare
…cisions, policies (#66536) ## Description First PR of a stack implementing the [Ray Train Monitoring and Diagnostics REP](https://github.com/ray-project/enhancements/tree/main/reps/2026-08-11-ray-train-monitoring-and-diagnostics). This one adds only the data contracts in a new `ray.train.health` module; nothing is wired into the controller yet. - `probe.py`: `ProbeResult` (named numeric readings, plus when they were taken), `Probe`, and the two probe kinds, named for where they run: `WorkerProbe` (inside each training worker) and `NodeProbe` (on each node, outside the workers). - `state.py`: `HealthState`, what evaluators read: `probe_results`, the latest `ProbeResult` of each probe, keyed by probe name and then world rank or node ID. - `decision.py`: the decisions `Noop`, `Reattempt`, `Evict` and `Diagnose`. `Diagnose.checks` names the health checks to run once. - `evaluator.py`: `Evaluator` (returns one `HealthDecision`, with an optional `on_worker_group_start()` hook). - `check.py`: `HealthCheck` (probes plus the evaluators that decide on their readings; both creators default to none), `PeriodicHealthCheck` (a `HealthCheck` whose probes are polled every `poll_interval_s`), and `HealthConfig` (`inflight_checks`, which are `PeriodicHealthCheck`s that run during training, and `preflight_checks`, which run once before training). Next in the stack: `ControllerProbe` (#66648), `NodeMonitor` (#66650), `HealthManager` (#66649), then `ray.train.health.report()`, the controller integration, and running checks once (diagnostics and pre-flight). See a draft for the REP in: #66247 ```mermaid classDiagram direction LR class HealthConfig { inflight_checks: List~PeriodicHealthCheck~ preflight_checks: List~HealthCheck~ } class HealthCheck { probe_creator() List~Probe~ evaluator_creator() List~Evaluator~ } class PeriodicHealthCheck { poll_interval_s: float } class Probe { <<abstract>> name: str } class WorkerProbe { <<abstract>> poll() ProbeResult } class NodeProbe { <<abstract>> poll() ProbeResult } class ProbeResult { metrics: Dict~str,float~ timestamp_s: float } class HealthState { probe_results: Dict } class Evaluator { <<abstract>> evaluate(state) HealthDecision on_worker_group_start() } class HealthDecision { <<abstract>> reason: str } class Evict { target_nodes: List~str~ } class Diagnose { checks: List~HealthCheck~ } HealthConfig o-- PeriodicHealthCheck : inflight HealthConfig o-- HealthCheck : preflight HealthCheck <|-- PeriodicHealthCheck HealthCheck ..> Probe : creates HealthCheck ..> Evaluator : creates Probe <|-- WorkerProbe Probe <|-- NodeProbe WorkerProbe ..> ProbeResult : returns NodeProbe ..> ProbeResult : returns HealthState o-- ProbeResult : latest per probe, per rank or node Evaluator ..> HealthState : reads Evaluator ..> HealthDecision : returns HealthDecision <|-- Noop HealthDecision <|-- Reattempt HealthDecision <|-- Evict HealthDecision <|-- Diagnose Diagnose o-- HealthCheck : runs once ``` ## Test 1. test with draft PR #66247 with script: https://gist.github.com/liulehui/5d65f0fc9c27298872ec49e454d65ad7 2. example logs: ``` ============================================================================== health: ray.train.health ============================================================================== injected: rank 1 stops calling the collective at step 100 and sleeps (a silent hang) (TrainController pid=25958) [State Transition] SHUTTING_DOWN -> ERRORED. (TrainController pid=26887) Requesting resources: {'GPU': 1} * 4 (TrainController pid=26887) /home/ray/anaconda3/lib/python3.12/site-packages/ray/data/_internal/execution/interfaces/execution_options.py:436: RayDeprecationWarning: `ExecutionOptions.exclude_resources` is deprecated and will be removed after January 2027. Use `ExecutionOptions.label_selector` to constrain Ray Data work to labeled nodes. (TrainController pid=26887) self.exclude_resources = exclude_resources (TrainController pid=26887) [State Transition] INITIALIZING -> SCHEDULING. (TrainController pid=26887) [Health] pre-flight passed on 4 node(s). (TrainController pid=26887) Attempting to start training worker group of size 4 with the following resources: [{'GPU': 1}] * 4 (RayTrainWorker pid=8859, ip=10.0.154.65) Setting up process group for: env:// [rank=0, world_size=4] (TrainController pid=26887) {"asctime":"2026-09-28 10:59:04,061","levelname":"E","message":"Actor with class name: 'PreemptionWatcher' and ID: '527407ea2951e6244aed01d302000000' has constructor arguments in the object store and max_restarts > 0. If the arguments in the object store go out of scope or are lost, the actor restart will fail. See #53727 for more details.","filename":"core_worker.cc","lineno":2465} (TrainController pid=26887) Started training worker group of size 4: (TrainController pid=26887) - (ip=10.0.154.65, pid=8859) world_rank=0, local_rank=0, node_rank=0 (TrainController pid=26887) - (ip=10.0.149.4, pid=8860) world_rank=1, local_rank=0, node_rank=1 (TrainController pid=26887) - (ip=10.0.138.97, pid=8935) world_rank=2, local_rank=0, node_rank=2 (TrainController pid=26887) - (ip=10.0.132.60, pid=8993) world_rank=3, local_rank=0, node_rank=3 (TrainController pid=26887) [State Transition] SCHEDULING -> RUNNING. (TrainController pid=26887) [Health] DIAGNOSE (NO_PROGRESS): 1 of 1 NCCL communicators (0x6b6b31bd2e55f51) made no progress for 20s; running diagnostics before attributing it (TrainController pid=26887) [Health] diagnostic output: /mnt/cluster_storage/nccl_hang_health_1790618333/health_diagnostics/nccl_ras (TrainController pid=26887) [Health] diagnostic output: /mnt/cluster_storage/nccl_hang_health_1790618333/health_diagnostics/nvidia_smi (TrainController pid=26887) [Health] diagnostic output: /mnt/cluster_storage/nccl_hang_health_1790618333/health_diagnostics/stack_traces (TrainController pid=26887) [Health] REATTEMPT (NO_PROGRESS): 1 of 1 NCCL communicators (0x6b6b31bd2e55f51) made no progress for 20s; diagnostics found no hardware fault, so this is software or data (TrainController pid=26887) [FailurePolicy] RAISE (TrainController pid=26887) Source: worker group (TrainController pid=26887) Error count: 1 (max allowed: 0) (TrainController pid=26887) Error: Training failed due to worker errors: (TrainController pid=26887) 1 of 1 NCCL communicators (0x6b6b31bd2e55f51) made no progress for 20s; diagnostics found no hardware fault, so this is software or data (TrainController pid=26887) ray.train.v2.api.exceptions.HealthDecisionError: Training failed due to worker errors: (TrainController pid=26887) 1 of 1 NCCL communicators (0x6b6b31bd2e55f51) made no progress for 20s; diagnostics found no hardware fault, so this is software or data (TrainController pid=26887) [State Transition] RUNNING -> SHUTTING_DOWN. (TrainController pid=26887) Torch process group shutdown timed out after 30 seconds (TrainController pid=26887) [State Transition] SHUTTING_DOWN -> ERRORED. ``` 3. Unit tests and checks on this PR: - `pytest python/ray/train/v2/tests/test_health_contracts.py`: 12 passed. - `pre-commit run` on the changed files: all passed. - `ci/ray_ci/doc/cmd_check_api_param_coverage.py .`: no newly-undocumented public-API parameters. The run in (1) and (2) used the earlier prototype; the release scripts move onto these contracts later in the stack. ## Duplicate check and AI assistance No other open PR adds a Ray Train health module; searching open PRs for "train health probe", "ray.train.health" and "health monitoring train" returns only this stack and the draft #66247. Written with AI assistance (Claude Code); I reviewed every changed line. --------- Signed-off-by: Lehui Liu <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
One NodeMonitor actor per node samples that node's NodeProbes, outside the training workers, so it keeps reporting when a worker on the node hangs or dies. Nothing starts it yet; the HealthManager in the next PR uses it. - NodeMonitor samples each probe in its own daemon thread every poll_interval_s and keeps the latest sample, stamped with when the poll finished if the probe left timestamp_s unset. poll_status() returns the latest samples, plus the probes whose last poll raised; a lock keeps each probe's result and error consistent. A failing probe is logged once and does not stop the others. - NodeMonitorGroup, modeled on WorkerGroup: start(node_ids) starts a num_cpus=0 monitor pinned to each node that has none, shutdown(node_ids) stops some or all, and poll_status(timeout=1s) collects every monitor's samples with ray.wait. A monitor that has not answered is not asked again until it does; one unanswered past health_check_timeout_s, or one that died, carries the error in its status. Polling probes once, for Diagnose and pre-flight checks, comes in a later PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
3cfc53b to
108c855
Compare
pseudo-rnd-thoughts
left a comment
There was a problem hiding this comment.
How does this fit into the flowchart in #66536? Does this sit in the PeriodicHealthCheck in order to return the NodeProbe?
How much this is important to the MVP of the health plane?
this will be used by HealthManager, and it is the actor that holds and issue NodeProbe, note that NodeProbe can be part of the PeriodicHealthCheck, this can also be used by Diagnose HealthDecision to issue a on-demand Probe to run certain command on the node, e.g. |
bea9dc7 to
05fa3d1
Compare
- NodeMonitor samples each probe every poll_interval_s of a ScheduledProbe(probe, poll_interval_s), which the caller builds from the probe's PeriodicHealthCheck, instead of reading Probe.poll_interval_s. - NodeMonitor.run_once(probes, timeout_s) polls each probe once in its own thread and returns within timeout_s; a probe still running is reported as a TimeoutError. - NodeMonitorGroup.run_once(probes, timeout_s=30, node_ids=None) runs it on some or all monitors and waits for their answers. poll_status() and run_once() share one helper that collects the monitors' answers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
| with self._lock: | ||
| self._latest[name] = result | ||
| self._errors.pop(name, None) | ||
| time.sleep(scheduled_probe.poll_interval_s) |
There was a problem hiding this comment.
Hung periodic probes stay silent
Medium Severity
_sample waits forever on probe.poll() with no timeout, so a hung probe never updates _latest or _errors. poll_status then keeps serving the last successful reading, or omits the probe entirely if it never completed, with no error. A stuck node command such as nvidia-smi can look healthy indefinitely.
Reviewed by Cursor Bugbot for commit f816032. Configure here.
To confirm, on a TrainingRun starting, then the HealthCheck will startup. To manage the running of NodeProbes, a NodeMonitorGroup will start with NodeMonitor on each node. When the HealthCheck wants to run a NodeProbe, it passes it to the NodeMonitorGroup which will distribute the call to the NodeMonitor then collect the results when they are ready, and pass it back to the HealthCheck for the evaluators. |
- NodeMonitor.poll_probes(probes) polls probes once on demand, and NodeMonitorGroup.poll_probes_async() / poll_probes() run it on some or all monitors, mirroring execute_async() / execute(). This replaces run_once(). - NodeMonitorGroup.poll_status() is split like WorkerGroup.poll_status(): _poll_monitors_and_collect_errors() and _get_poll_tasks(). - The sampler keeps each probe's latest error without logging it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9a049cf. Configure here.
It waited on every monitor with one ray.get, so a dead or hung monitor lost the other nodes' results or blocked the caller. Callers wait on the per-node refs from poll_probes_async() instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
|
|
||
| probe_results: Dict[str, ProbeResult] = field(default_factory=dict) | ||
| probe_errors: Dict[str, Exception] = field(default_factory=dict) | ||
| error: Optional[Exception] = None |
There was a problem hiding this comment.
Should this even be here, or should it just raise the error directly?
Or clarify that this the monitor_error
- ProbeResult gets an optional error, so a failed poll is still one ProbeResult. NodeMonitorStatus.probe_results holds each probe's latest result, and probe_errors is gone. - Rename NodeMonitorStatus.error to monitor_error. - Name sampler threads NodeMonitor-<probe>-<interval>s. - NodeMonitorGroup's docstring points on-demand probes to poll_probes_async(). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
Rework the HealthManager on top of the merged NodeMonitor (#66650), and keep it simple: - Keep only the latest result of each probe. Windows, Probe.window_size and the private _severity on the decision classes are gone, so this PR no longer changes the public contracts. - A probe in several checks runs once, at the shortest of their poll_interval_s. Two different probe classes with the same name raise ValueError. - Each check runs its evaluators every poll_interval_s of the check. - One poll() per controller tick: collect the NodeMonitors' latest samples, restarting a monitor that reports an error; poll the ControllerProbes that are due; run the evaluators of the checks that are due; and merge their decisions. - reset(node_ids) starts every attempt, including the first, and calls each evaluator's on_worker_group_start(). start() is gone. - A failing evaluator is skipped and logged once until it recovers, instead of being turned off for the rest of the run. A failing probe is logged the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
…67671) ## Description 5th PR of the [Ray Train Monitoring and Diagnostics REP](https://github.com/ray-project/enhancements/tree/main/reps/2026-08-11-ray-train-monitoring-and-diagnostics) stack, after #66536, #66648, #66650 and #66649. `ControllerProbe` (2/n) had nowhere to run. This PR runs it on a `NodeMonitor` on the controller's node, next to the `NodeMonitor`s on the worker nodes, so a slow or hanging probe never blocks the controller. ### How it works - **`NodeMonitor`** samples and polls on demand any probe the same way. A `NodeProbe` gives a `ProbeResult`, and a `ControllerProbe` gives `{key: ProbeResult}`. A poll that raises gives a `ProbeResult` with the `error`. - **`NodeMonitorGroup`** runs a monitor of the `NodeProbe`s on each worker node, with `start_worker_node_monitors(node_ids)` / `shutdown_worker_node_monitors()`, and a monitor of the `ControllerProbe`s on the controller's node, with `start_controller_node_monitor(node_id)`. It polls both kinds in one issue-and-collect loop, as `WorkerGroup` polls its workers. `poll_status()` (in-flight) and `poll_probe_results()` (on-demand) both return a `NodeMonitorGroupPollStatus`, where a monitor that died or did not answer in time has its `monitor_error`. - **`HealthManager.reset()`** starts both. The controller node's monitor always starts, so on-demand `ControllerProbe`s work without an in-flight one; without `ControllerProbe`s it has no sampling threads. One function builds the `HealthState` of both in-flight and on-demand checks, and a failed monitor gives each of its probes its error. As in 4/n, a worker node's failed monitor stops, with its results, until the next `reset()`. While the controller node's monitor fails, each `ControllerProbe` has its error. - **`HealthState`** has two new fields for the `ControllerProbe`s: `controller_probe_results`, `{probe name: {key: ProbeResult}}`, and `controller_probe_errors`, `{probe name: exception}` for each whose latest poll failed. `probe_results` now holds only `WorkerProbe` and `NodeProbe` results. Nothing calls the `HealthManager` yet; the controller integration comes later in the stack. ### In-flight checks <img width="686" height="955" alt="image" src="https://github.com/user-attachments/assets/23b502d2-417d-4008-bc22-dd5bfe2807bb" /> ### On-demand checks <img width="1024" height="895" alt="image" src="https://github.com/user-attachments/assets/e1f4eb22-376d-4f21-bb7d-59a6b0683b60" /> ## Test unit tests --------- Signed-off-by: Lehui Liu <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
) ## Description 6th PR of the [Ray Train Monitoring and Diagnostics REP](https://github.com/ray-project/enhancements/tree/main/reps/2026-08-11-ray-train-monitoring-and-diagnostics) stack, on top of #67671. The `HealthManager` decides on `Reattempt`, `Evict` or `Diagnose`, but nothing acted on its decisions yet. This PR runs its in-flight checks in the Ray Train controller and acts on what they decide. ### How it works - **`RunConfig.health_config`** (Alpha) takes a `HealthConfig`. The controller makes a `HealthManager` of its `inflight_checks`. `preflight_checks` only logs a warning for now. - **`HealthCallback`**, a `WorkerGroupCallback`, calls `HealthManager.reset()` with the worker group's nodes after each attempt starts, and `shutdown()` before the worker group shuts down or aborts. - **The `RUNNING` step** calls `evaluate_inflight_checks()` after it acts on worker errors. Each decision other than a `Noop` first goes to the new `after_health_decision` hook of `ControllerCallback` and `UserCallback`, then: - `Reattempt` restarts the worker group through the failure policy with a `HealthCheckError`, like a worker error, so it counts against `max_failures`. - `Evict` restarts the worker group without going through the failure policy. Every later attempt adds `ray.io/node-id: !in(<evicted nodes>)` to each worker's label selector, so no worker lands on an evicted node. A node is evicted once, so evictions are bounded by the number of nodes. - `Diagnose` is not acted on yet. - **`HealthCheckError`** (DeveloperAPI) is a `WorkerGroupError` that keeps the `decision` behind the restart. WorkerProbes in the controller's `HealthState`, pre-flight checks and `Diagnose` come later in the stack. ### Controller flow ## Related 1. REP: https://github.com/ray-project/enhancements/tree/main/reps/2026-08-11-ray-train-monitoring-and-diagnostics 2. #66536, #66648, #66650, #66649, #67671 ## Test `test_health_e2e` trains on a cluster of two 1-CPU nodes with `max_failures=0` and an evaluator that evicts every node: the second attempt runs on the other node, and the run fails once no node is left to start on. --------- Signed-off-by: Lehui Liu <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>


Description
3rd PR of the Ray Train Monitoring and Diagnostics REP stack. Adds
NodeMonitorandNodeMonitorGroup, oneNodeMonitorper node that samples that node'sNodeProbesNodeMonitoris a plain actor that samples each probe in its own daemon thread everypoll_interval_s. The interval comes with the probe as aScheduledProbe(probe, poll_interval_s), which the caller builds from the probe'sPeriodicHealthCheck.poll_status()returns the latest samples.poll_probes(probes, timeout_s)polls probes once on demand. This is mainly the push direction used byDiagnoseand pre-flight checks, such as annvidia-smisnapshot.NodeMonitorGroup:start(node_ids)starts anum_cpus=0monitor pinned to each node that has none.shutdown(node_ids=None)stops some monitors or all of them.poll_status(timeout)collects every monitor's latest samples withray.wait, likeWorkerGroup.poll_status(): a monitor that has not answered is not asked again until it does, and one unanswered pasthealth_check_timeout_s, or one that died, carries the error in its status.poll_probes_async(probes, node_ids=None)polls probes once on some or all monitors, likeexecute_async(), and returns a ref per node for the caller to wait on.Illustration of Relationship with NodeMonitorGroup and NodeMonitor
Test
unit tests