Skip to content

[Train] Add RAS history to hang detector - #66228

Merged
matthewdeng merged 5 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:hang-detector/ras-history
Sep 23, 2026
Merged

matthewdeng merged 5 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:hang-detector/ras-history

Conversation

@pseudo-rnd-thoughts

Copy link
Copy Markdown
Member

Description

The hang detector polls NCCL RAS frequently to check if ranks have different numbers of collectives launched. Currently, we log that data regularly, however, this makes the post-mortem analyses difficult. Therefore, this PR adds a circular buffer for recording a history of the NCCL RAS queries and on confirmation are dumped into the diagnostic folder.
To ensure that the history can include RAS queries from before a hang started, the length of the circular buffer is the number of number of polls required for confirmation plus a fixed value.

Related issues

Continuation of #64928

@pseudo-rnd-thoughts pseudo-rnd-thoughts added train Ray Train Related Issue go add ONLY when ready to merge, run all tests labels Sep 17, 2026
@pseudo-rnd-thoughts
pseudo-rnd-thoughts marked this pull request as ready for review September 18, 2026 15:04
@pseudo-rnd-thoughts
pseudo-rnd-thoughts requested a review from a team as a code owner September 18, 2026 15:04

@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 enhances the NCCL RAS hang detector in Ray Train by introducing a circular buffer to record a history of ncclras queries and uploading these diagnostics (along with worker stack traces) to the experiment storage directory upon a confirmed hang. It also updates the NCCLHangError message to point users to these diagnostic files and adds comprehensive unit tests. The review feedback correctly identifies a critical discrepancy between the implementation of dump_ras_query_history and its unit tests regarding file naming conventions and empty history handling, providing a code suggestion to resolve the issue.

@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 using default effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 83571fa. Configure here.

Signed-off-by: Mark Towers <[email protected]>

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

Thanks! One concern is the memory overhead of keeping a buffer of the nccl ras output. Would be good to test that with a substantial number of ranks, measure that before we merge, and have some results in the PR description. Can we also add tests for the dump_worker_stack_trace function, there is no coverage for it right now.

_NCCL_RAS_QUERY_TIMEOUT_S: float = 8.0 # the default ncclras -t value is 5

# Every diagnostic is uploaded to `<experiment_fs_path>/hang_detector/<tool>/`.
_DIAGNOSTICS_DIR: str = "hang_detector"

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.

nit: this might be better placed in ray/train/v2/_internal/constants.py with CHECKPOINT_MANAGER_SNAPSHOT_FILENAME and VALIDATE_STORAGE_MARKER_FILENAME that also fall into the experiment_fs_path.

@pseudo-rnd-thoughts

pseudo-rnd-thoughts commented Sep 22, 2026 •

Copy link
Copy Markdown
Member Author

One concern is the memory overhead of keeping a buffer of the nccl ras output.

Here is a table of the estimated memory usage for a fixed history of 100 polls

variant 64 256 1024 4096 ranks
Current implementation 2.49 MiB 9.77 MiB 39.89 MiB 160.73 MiB
compact re-serialised json string 0.85 MiB 3.37 MiB 13.42 MiB 53.99 MiB
zlib(raw json) 0.06 MiB 0.18 MiB 0.62 MiB 2.40 MiB

zlib will add 5.4ms per poll at 4096 ranks.

I would say we keep to the current implementation and look at the zlib implementation if a customer finds this is an issue.

Signed-off-by: Mark Towers <[email protected]>
@matthewdeng
matthewdeng merged commit ea83aa7 into ray-project:master Sep 23, 2026
6 checks passed
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description
The hang detector polls NCCL RAS frequently to check if ranks have
different numbers of collectives launched. Currently, we log that data
regularly, however, this makes the post-mortem analyses difficult.
Therefore, this PR adds a circular buffer for recording a history of the
NCCL RAS queries and on confirmation are dumped into the diagnostic
folder.
To ensure that the history can include RAS queries from before a hang
started, the length of the circular buffer is the number of number of
polls required for confirmation plus a fixed value.

## Related issues
Continuation of ray-project#64928

---------

Signed-off-by: Mark Towers <[email protected]>
Co-authored-by: Mark Towers <[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