Skip to content

[train][1/n] Add ray.train.health contracts: probes, health state, decisions, policies - #66536

Merged
matthewdeng merged 9 commits into
masterfrom
ray-train-health/contracts
Oct 13, 2026
Merged

matthewdeng merged 9 commits into
masterfrom
ray-train-health/contracts

Conversation

@liulehui

@liulehui liulehui commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

First PR of a stack implementing the Ray Train Monitoring and Diagnostics REP. 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 PeriodicHealthChecks 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

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
Loading

Test

  1. test with draft PR [DRAFT] add Ray Train health / monitoring / diagnostics #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 https://github.com/ray-project/ray/issues/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.

  1. 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.

@liulehui
liulehui force-pushed the ray-train-health/contracts branch 3 times, most recently from 33f0fd7 to a4dc0c5 Compare September 28, 2026 21:32
@liulehui liulehui changed the title [train] Add ray.train.health contracts: probes, health state, decisions, policies [train][1/n] Add ray.train.health contracts: probes, health state, decisions, policies Sep 28, 2026
@liulehui
liulehui marked this pull request as ready for review September 28, 2026 21:39
@liulehui
liulehui requested a review from a team as a code owner September 28, 2026 21:39
@liulehui liulehui added the go add ONLY when ready to merge, run all tests label Sep 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new health monitoring framework under 'ray.train.health', defining core abstractions for health decisions, policies, probes, and state tracking, along with associated unit tests. The feedback suggests enhancing 'HealthState.results' to support instance-level probe names and to explicitly validate that the probe class subclasses a supported concrete probe type (raising a 'TypeError' if not). This change requires importing 'NodeProbe' in 'state.py'. Additionally, the reviewer recommends adding unit tests to verify these new behaviors.

Comment thread python/ray/train/health/state.py Resolved
Comment thread python/ray/train/health/state.py Resolved
@liulehui
liulehui force-pushed the ray-train-health/contracts branch 2 times, most recently from d94216f to ca1a0d4 Compare September 29, 2026 00:40
@liulehui
liulehui requested a review from a team as a code owner September 29, 2026 00:40
@ray-gardener ray-gardener Bot added the train Ray Train Related Issue label Sep 29, 2026

@matthewdeng matthewdeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General recommendation is that we should aim to be as restrictive as possible in this version of the API. It will be easier for us to expand rather than restrict it over time.

Comment thread python/ray/train/health/probe.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
Comment thread python/ray/train/health/policy.py Resolved
Comment thread python/ray/train/health/policy.py Resolved
Comment thread python/ray/train/health/check.py Outdated
Comment on lines +53 to +54
probe_creator: Optional[ProbeCreator] = None
evaluator_creator: Optional[EvaluatorCreator] = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be optional or required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can both optional but not at the same time (NOOP), added a __post__init__ for validation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just default to a func that returns empty list instead?

Comment thread python/ray/train/health/policy.py Outdated
Attributes:
probe_creator: Builds the policy's probes, once per run.
evaluator_creator: Builds the policy's evaluators, once per run.
preflight: Also run the policy's ``OnDemandProbe``s on every candidate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a scenario where OnDemandProbes are defined here but not used for preflight?

@liulehui liulehui Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a OnDemand Probe that needs to be run both at preflight and midtrain.
user should create:
a PreflightHealthPolicy contains that ProbeA
a midTrainingHealthPolicy contains that ProbeA
and pass HealthConfig(policies=[PreflightHealthPolicy(), midTrainingHealthPolicy()])

Comment thread python/ray/train/health/decision.py Resolved
@liulehui
liulehui force-pushed the ray-train-health/contracts branch from ca1a0d4 to c8b882b Compare September 30, 2026 04:23

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the example, you have ClusterProbe and OnDemandProbe that don't exist here. Do the types of probes help? Can't everything be done with just the superclass rather than users inherit from one of the probe subclasses in here

Could you produce a UML diagram of the classes as its not clear here or in the REP how the classes are combined together

Comment thread python/ray/train/health/decision.py Resolved
Comment thread python/ray/train/health/decision.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
@liulehui

liulehui commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Reviewing the example, you have ClusterProbe and OnDemandProbe that don't exist here. Do the types of probes help? Can't everything be done with just the superclass rather than users inherit from one of the probe subclasses in here

  1. we need a way to indicate where are those Probe will run, e.g. from worker process, node level or controller level. so we will have ControllerProbe, NodeProbe, WorkerProbe , similar to ControllerCallback, WorkerGroupCallback, WorkerCallback
  2. removed OnDemandProbe, right now they are just a not poll on interval probe.
  3. renamed ClusterProbe to ControllerProbe, will send it out as a separate PR.

Could you produce a UML diagram of the classes as its not clear here or in the REP how the classes are combined together

sure, updated the PR description with the UML diagram.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 cdab83d. Configure here.

Comment thread python/ray/train/health/decision.py Resolved

@matthewdeng matthewdeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice nice, thanks for adding the mermaid diagram, made it very easy to review

Comment thread python/ray/train/health/decision.py Resolved
Comment thread python/ray/train/health/policy.py Outdated

probe_creator: Optional[ProbeCreator] = None
evaluator_creator: Optional[EvaluatorCreator] = None
preflight: bool = False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should preflight be an attribute of the HealthPolicy or the Probe itself?

My gut feeling is that we might want to somehow unify preflight with Diagnose since they run once, whereas the Probe interface currently has a poll_interval_s attribute, which doesn't actually apply for these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think preflight should be an attribute of Policy and now the HealthCheck. But I moved it off from both so that HealthCheck is now just probes + evaluators, and when it runs is set by where it's placed:

  1. HealthConfig.checks: run periodically while training runs
  2. explictly specify HealthConfig.preflight_checks: run once on each node before training starts
  3. Diagnose(checks=[...]): run once, whenever HealthDecision is Diagnose.

So pre-flight and Diagnose share one shape: run a set of checks once.

On poll_interval_s: I kept it on Probe so each probe can sample at its own rate. The docstring now says it only applies when the probe is polled periodically and is unused when it's polled once. That seemed simpler than a separate probe type or mixin, which would make probe authors decide up front how their probe will be used.

Comment thread python/ray/train/health/policy.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
Comment on lines +58 to +65
@abc.abstractmethod
def poll(self) -> ProbeResult:
"""Poll this worker once.

Returns:
The result.
"""
raise NotImplementedError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the same in WorkerProbe and NodeProbe -- upstream to Probe for now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept poll() on each subclass: ControllerProbe (ray-project/ray#66648 · [train][2/n] Add ControllerProbe…) returns {key: ProbeResult} rather than one ProbeResult, this is because some tool like NVSentinel and NcclRas already has the global view. the key here is either NodeIdStr or rank id.

shared Probe.poll() would have to be overridden with a different return type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some research, I think for controller probe, we still want to keep {key: ProbeResult} in the beginning, which can support NVSentinel, NVRx, NcclRas.

We can extend it the return type later if we see if cannot be covered.

Comment thread python/ray/train/health/state.py Resolved

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good. I just have a couple more questions about the class names. Otherwise, LGTM

Comment thread python/ray/train/health/check.py Resolved
Comment thread python/ray/train/health/check.py Resolved
Comment thread python/ray/train/health/check.py Resolved
Comment thread python/ray/train/health/check.py Resolved
Comment thread python/ray/train/health/decision.py Resolved
Comment thread python/ray/train/health/decision.py Resolved
Comment thread python/ray/train/health/probe.py Resolved
Comment thread python/ray/train/health/state.py Resolved
liulehui and others added 5 commits October 7, 2026 14:31
…ns, policies

First layer of the Ray Train Monitoring and Diagnostics stack. Adds the data
contracts only; nothing is wired into the controller yet.

- probe.py: ProbeResult (metrics and a timestamp), Probe, WorkerProbe and
  NodeProbe.
- state.py: HealthState, the latest ProbeResult per probe, keyed by world
  rank or node ID.
- decision.py: Action, Noop, Reattempt, Evict, Diagnose.
- policy.py: Evaluator, HealthPolicy, HealthConfig.

All public classes are PublicAPI(alpha).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
…strings

- Rename HealthPolicy to HealthCheck (policy.py -> check.py): probes and the
  evaluators that decide on their readings. HealthConfig.policies becomes
  checks, and the preflight flag moves out of the check into
  HealthConfig.preflight_checks, so where a check runs is set by where it is
  placed.
- Diagnose takes checks instead of probes, so the evaluators that decide on
  a one-off poll come with it.
- Evict is keyword-only and target_nodes is required, so Evict(["n1"]) no
  longer evicts nothing.
- Remove HealthState.results(); evaluators read probe_results by
  Probe.probe_name().
- poll_interval_s stays on Probe and only applies when the probe is polled
  periodically.
- Docstrings describe the interfaces only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
liulehui and others added 2 commits October 7, 2026 14:31
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
@liulehui
liulehui force-pushed the ray-train-health/contracts branch from 30d6ff1 to e99d7a3 Compare October 7, 2026 21:33
Comment thread python/ray/train/health/check.py Outdated
Comment on lines +70 to +71
mid_training_checks: List[HealthCheck] = field(default_factory=list)
preflight_checks: List[HealthCheck] = field(default_factory=list)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean to have poll_interval_s for a Probe in a preflight check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after our discussion, changed to
PeriodicProbe: a Probe + poll_interval_s
OnDemandProbe: for a run once Probe, later we can add stop_worker as an attribute.

Comment thread python/ray/train/health/check.py Resolved
Comment thread python/ray/train/health/decision.py Resolved
@liulehui
liulehui added this pull request to stack #66865 October 8, 2026 21:13
- Add PeriodicProbe(probe, poll_interval_s) and OnDemandProbe(probe), and
  remove poll_interval_s from Probe. A HealthCheck's probe_creator returns
  wrapped probes.
- Move Evaluator to evaluator.py.
- HealthCheck creators default to returning an empty list.
- Rename HealthConfig.mid_training_checks to inflight_checks.
- Remove Diagnose.target_ranks and target_nodes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
Comment thread python/ray/train/health/check.py Outdated
Comment on lines +33 to +36
inflight_checks: Checks that run during training. Their probes must be
wrapped in ``PeriodicProbe``.
preflight_checks: Checks that run once on each node before training
starts. Their probes must be wrapped in ``OnDemandProbe``.

@matthewdeng matthewdeng Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a code smell here if these constraints are defined in the requirements and not the interface itself.

Could we simplify it by removing these interfaces and moving it to the HealthCheck instead? I'm curious if poll_interval_s needs to be an attribute of the actual Probe itself or the HealthCheck.

class HealthCheck:
    probe_creator: Callable[[], List[Probe]]
    evaluator_creator: Callable[[], List[Evaluator]]

class PeriodicHealthCheck(HealthCheck):
    poll_interval_s: float 

class HealthConfig:
    inflight_checks: List[PeriodicHealthCheck]
    preflight_checks: List[HealthCheck]

class Diagnose(HealthDecision):
    checks: List[HealthCheck]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. l am good first keep it in HealthCheck, if later we found the need that each probe needs its own frequency we can then added there.

Remove PeriodicProbe and OnDemandProbe. A PeriodicHealthCheck polls its
probes every poll_interval_s, and HealthConfig.inflight_checks takes
PeriodicHealthChecks, so the constraint lives in the types. probe_creator
returns plain probes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
@matthewdeng
matthewdeng merged commit 133b360 into master Oct 13, 2026
6 checks passed
@matthewdeng
matthewdeng deleted the ray-train-health/contracts branch October 13, 2026 22:03
matthewdeng pushed a commit that referenced this pull request Oct 14, 2026
## Description

Second 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 #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](https://claude.com/claude-code)

---------

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 5, 2026
## Description

1st PR of a new [Ray Train Monitoring and Diagnostics
REP](https://github.com/ray-project/enhancements/tree/main/reps/2026-08-11-ray-train-monitoring-and-diagnostics)
stack for Worker level integration with Ray Train V2. Adds `WorkerProbe`
support to the Ray Train `WorkerGroup`, mirroring what
`NodeMonitorGroup` does for `NodeProbe`s.

Each train worker samples its `WorkerProbe`s in their own daemon threads
every `poll_interval_s`, and keeps the latest samples on its
`TrainContext`.
- The probes come in through a `WorkerGroupCallback`'s
`before_init_train_context`, as `worker_probes`.
- `poll_status()` returns the latest samples as
`WorkerStatus.probe_results`, so they ride the poll the controller
already makes.

`WorkerGroup`:
- `poll_probes_async(probes, timeout_s, ranks=None)` polls probes once
on some or all workers. Each worker runs them in a `ThreadRunner`
started through `execute_async`, so `poll_status()` keeps answering
meanwhile.
- `poll_probe_results()` returns `{probe name: {world rank:
ProbeResult}}` once every worker answered or the timeout passed, and
`None` until then, like `NodeMonitorGroup.poll_probe_results()`. A
worker that did not answer, or whose actor failed, carries the error in
its results.

Wiring these results into the `HealthManager` comes in a later PR.

Illustration of how periodic and on-demand probes flow through the
WorkerGroup

periodic:
<img width="793" height="452" alt="image"
src="https://github.com/user-attachments/assets/3217844a-3ba2-421f-bc47-2acfdc22c87a"
/>

on demand:
<img width="579" height="441" alt="image"
src="https://github.com/user-attachments/assets/810829cd-272e-41e7-a404-9170b79653aa"
/>


## Related:

1. REP:
https://github.com/ray-project/enhancements/tree/main/reps/2026-08-11-ray-train-monitoring-and-diagnostics
2. #66536 



## 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 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.

4 participants