Skip to content

[Health][Train] Add Health Events and Exporter - #67544

Open
pseudo-rnd-thoughts wants to merge 2 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:health/ray-events
Open

pseudo-rnd-thoughts wants to merge 2 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:health/ray-events

Conversation

@pseudo-rnd-thoughts

@pseudo-rnd-thoughts pseudo-rnd-thoughts commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Description

@liulehui has implemented the first health API classes (probes, evaluators and more) for the REP for Monitoring and Diagnostics. This PR adds the Ray events that export what they find, plus a HealthEventExporter that emits new, updated, resolved and stopped findings.

TL;DR

This PR adds one exportable HealthEvent to Ray's event pipeline, with three possible bodies: a finding (what a checker saw), a checker-disabled notice (where Ray went blind) and a decision (what Ray did about it). Together they let Anyscale dashboards show a training run's health story end to end, and any future checker plugs in without a new event type or a new Anyscale parser.

Motivation

The monitoring and diagnostics REP adds a health API to Ray Train: probes that observe, evaluators that judge, and a HealthManager that acts. Today their output stops at logs. Our first exporter, the NCCL-hang event in #66937, was built for one detector only. Repeating that pattern would mean a new event type and a new Anyscale parser per checker.

This PR replaces it with one generic contract. Any checker built on the health API, including user-written probes and evaluators, gets an export signal for free. That lets Anyscale build one observability dashboard that explains silent hangs, disabled checks and automatic restarts or evictions.

The three bodies

Every HealthEvent shares one envelope (checker_name, a per-checker sequence, observed_at) and carries exactly one body.

Body Question it answers Identity and lifecycle Example
HealthFinding What is wrong right now? finding_id; NEW → UPDATED → RESOLVED or STOPPED; each event is a full snapshot "2 NCCL communicators stalled", with typed NcclHangFinding details
HealthCheckerDisabled Where can we no longer see? checker_name; one final event, after its open findings are STOPPED ncclras missing → DEPENDENCY_UNAVAILABLE
HealthDecision What did Ray do about it? decision_id; one event; points at the finding_ids it acts on EVICT node X and restart, or DIAGNOSE ranks 3–5

Why three bodies, not one

The three are different things with different identities and lifecycles, so merging them would leave most fields meaningless for any one event and make consumers guess.

  • Silence is ambiguous without CheckerDisabled. No findings can mean healthy or blind. A dashboard must tell those apart before anyone trusts a green run.
  • Decisions are not findings. One decision can merge several evaluators and act on several findings. Referencing finding_ids keeps the cause-and-effect link without copying finding data.
  • One envelope, not three event types. All three ride one HEALTH_EVENT type, one aggregator allowlist entry and one ordering key. A new checker adds a typed details message, or uses custom for user checkers, rather than a new event type.

Style rules the schema follows:

  • Findings are full snapshots, so the newest event per finding_id is the current state, and a dropped event is harmless.
  • Every finding closes, so dashboards never show a stuck "open" issue.
  • Changes are additive only; readers ignore unknown fields and map unknown enums to UNSPECIFIED.
  • Evidence (RAS report, py-spy dump) is attached once and capped at 32 KB per text artifact.
  • The exporter enforces these rules, so checkers can't break them, and an export failure never fails a training run.

Status and asks

  • [Train] Add export events for the Ray Train NCCL Hang Detector #66937 closes once this merges; the NCCL hang detector is the first producer of HealthFinding.
  • The Anyscale consumer for NCCL RAS findings is in progress. The rest of the health API only just merged into Ray, so no other Anyscale work has started.
  • Export is opt-in: events flow only with RAY_enable_ray_event on and HEALTH_EVENT listed in RAY_ENABLE_PYTHON_RAY_EVENT_TYPES.
  • Ask for reviewers: agree the envelope plus three bodies now. Every later checker builds on it, and after merge it can only change additively.

AI assistance (Claude Code) was used to draft this description.

@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 health event export framework for Ray, adding the HealthEventBuilder and HealthEventExporter classes to serialize and emit health findings, checker shutdowns, and decisions. It also defines the events_health_event.proto schema and integrates these events into the dashboard aggregator. Feedback on the changes includes adding a safety check for uninitialized Ray nodes to prevent potential AttributeErrors, and dynamically allocating ports in the test suite to avoid conflicts during parallel CI runs.

if not ray.is_initialized():
logger.warning("Ray is not initialized; health events will not be emitted.")
return
node = ray._private.worker.global_worker.node

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.

medium

Accessing ray._private.worker.global_worker.node directly without checking if it is None can lead to an AttributeError (e.g., in unit tests or during early initialization phases where the node is not yet fully initialized on the worker). Add a guard to return early if node is None.

Suggested change
node = ray._private.worker.global_worker.node
node = ray._private.worker.global_worker.node
if node is None:
logger.warning("Ray node is not initialized; health events will not be emitted.")
return

cluster = ray_start_cluster
cluster.add_node(
env_vars={
"RAY_DASHBOARD_AGGREGATOR_AGENT_EVENTS_EXPORT_ADDR": f"http://127.0.0.1:{_HEALTH_EVENT_PORT}",

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.

medium

Avoid using a hardcoded port (_HEALTH_EVENT_PORT) for the test server, as it can cause port conflicts and test flakiness in parallel CI runs. Instead, leverage the dynamically allocated port from the httpserver fixture by using httpserver.port. You can also remove the custom httpserver_listen_address fixture on lines 22-24 to let the server bind to a random free port automatically.

Suggested change
"RAY_DASHBOARD_AGGREGATOR_AGENT_EVENTS_EXPORT_ADDR": f"http://127.0.0.1:{_HEALTH_EVENT_PORT}",
"RAY_DASHBOARD_AGGREGATOR_AGENT_EVENTS_EXPORT_ADDR": f"http://127.0.0.1:{httpserver.port}",

@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

Reviewed by Cursor Bugbot for commit d6c05e8. Configure here.

@pseudo-rnd-thoughts pseudo-rnd-thoughts added train Ray Train Related Issue core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests labels Oct 29, 2026

@liulehui liulehui 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.

Can we have some example in the description to illustrate how platform should utilize these information?

CLUSTER_LIFECYCLE = 4;
AUTOSCALER = 5;
JOBS = 6;
RAY_TRAIN = 7;

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.

I feel this list is all for core source,
maybe we should create a oneof saying APP/WOKRLOAD, and ray train is one of the app/workload.

// "nccl_hang_detector", a probe or evaluator `name`, or "health_manager".
string checker_name = 1;
// Strictly increasing per checker instance; orders the events.
uint64 sequence = 2;

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.

if we have the timestamp, do we still need to sequence?

uint64 sequence = 2;
// When the observation behind the event was made (e.g. when the poll's
// `ncclras` query returned). RayEvent.timestamp is when the event was built.
google.protobuf.Timestamp observed_at = 3;

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.

I think RayEvent already has event_id and timestamp?

}

// An issue found by a checker.
message HealthFinding {

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.

not sure we want to put state machine in the Proto. what will backend do with this field?

string finding_id = 1;
State state = 2;
// When the underlying issue began (may be earlier than the NEW event).
google.protobuf.Timestamp started_at = 3;

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 this duplicated with the observed at?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core 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.

2 participants