Skip to content

[train][2/n] Add ControllerProbe to ray.train.health - #66648

Merged
matthewdeng merged 3 commits into
masterfrom
ray-train-health/controller-probe
Oct 14, 2026
Merged

matthewdeng merged 3 commits into
masterfrom
ray-train-health/controller-probe

Conversation

@liulehui

@liulehui liulehui commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Second PR of the Ray Train Monitoring and Diagnostics REP stack, on top of #66536. Adds a third probe kind, ControllerProbe, named for where it runs: in the Ray Train controller process.

Some sources already aggregate across the cluster, so one query answers for the whole run. NCCL RAS is the case study: one ncclras query reports every communicator. A ControllerProbe polls such a source once and returns one result per key it chooses (here, per communicator).

  • probe.py: ControllerProbe.poll() -> {key: ProbeResult}. One instance is used for the whole run, so it can keep state between polls (for example the previous snapshot, to compute a delta). poll() takes no arguments for now; a context, such as the run's worker-to-node map, can be added by the first probe that needs it.
  • state.py: HealthState.probe_results also holds ControllerProbe readings, keyed by the probe's own keys.

Nothing polls it yet; that comes with the controller integration.

Difference compared with the REP

The REP has no controller-side probe.

Test

  • pytest python/ray/train/v2/tests/test_health_contracts.py: 14 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.

Duplicate check and AI assistance

Part of the stack started in #66536; no other open PR adds a Ray Train health module. Written with AI assistance (Claude Code); I reviewed every changed line.

🤖 Generated with Claude Code

@liulehui
liulehui marked this pull request as ready for review October 5, 2026 00:32
@liulehui
liulehui requested a review from a team as a code owner October 5, 2026 00:32
@ray-gardener ray-gardener Bot added the train Ray Train Related Issue label Oct 5, 2026
@liulehui
liulehui force-pushed the ray-train-health/controller-probe branch from 07f89f8 to 511b048 Compare October 5, 2026 19:08
@liulehui
liulehui force-pushed the ray-train-health/controller-probe branch 2 times, most recently from 6a72bd9 to c66fdbb Compare October 7, 2026 05:00
@liulehui
liulehui force-pushed the ray-train-health/controller-probe branch 3 times, most recently from 945aa7f to cff77c4 Compare October 7, 2026 18:06
@liulehui
liulehui force-pushed the ray-train-health/controller-probe branch from cff77c4 to 6596fdb Compare October 7, 2026 21:33
@liulehui
liulehui added this pull request to stack #66865 October 8, 2026 21:13
@liulehui
liulehui force-pushed the ray-train-health/controller-probe branch 2 times, most recently from cc0a12a to 522946f Compare October 13, 2026 20:47
Comment thread python/ray/train/health/probe.py Resolved
@liulehui liulehui added the go add ONLY when ready to merge, run all tests label Oct 13, 2026
Base automatically changed from ray-train-health/contracts to master October 13, 2026 22:03
@matthewdeng
matthewdeng requested a review from a team as a code owner October 13, 2026 22:03
liulehui and others added 3 commits October 13, 2026 15:03
A probe kind that runs in the Ray Train controller process instead of on a
worker or node. One poll answers for several keys the probe chooses, for
sources that already aggregate across the cluster, such as NCCL RAS (one
reading per communicator) or NVSentinel (one per node).

- probe.py: ControllerProbe, whose poll() returns {key: ProbeResult}. It
  takes no arguments for now; context such as the run's worker-to-node map
  can be added by the first probe that needs it.
- state.py: HealthState.probe_results also holds ControllerProbe readings,
  keyed by the probe's own keys. ResultKey = Union[int, str] names the key
  type: a world rank, a node ID, or a key a ControllerProbe chose.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
ControllerProbe.poll() returns {node ID, world rank or key: ProbeResult},
so readings about nodes or workers line up with NodeProbe and WorkerProbe
readings in HealthState. Move ResultKey to probe.py, which now uses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
ControllerProbe.poll() returns Dict[Any, ProbeResult], so a probe can key
its readings by whatever it observes. HealthState.probe_results uses Any
keys too, and the ResultKey alias is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
matthewdeng pushed a commit that referenced this pull request Oct 13, 2026
…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]>
@matthewdeng
matthewdeng force-pushed the ray-train-health/controller-probe branch from c66ec18 to c2fda2f Compare October 13, 2026 22:03
@matthewdeng
matthewdeng merged commit de28d20 into master Oct 14, 2026
6 checks passed
@matthewdeng
matthewdeng deleted the ray-train-health/controller-probe branch October 14, 2026 01:20
pseudo-rnd-thoughts pushed a commit that referenced this pull request Nov 10, 2026
…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]>
pseudo-rnd-thoughts pushed a commit that referenced this pull request Nov 12, 2026
)

## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests train Ray Train Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants