Repository navigation
[Train] Name threads in the NCCL hang detector's Python-only stack dump - #67795
Merged
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
pseudo-rnd-thoughts
approved these changes
Nov 4, 2026
pseudo-rnd-thoughts
left a comment
Member
There was a problem hiding this comment.
Thanks for fixing that @marwan116
pseudo-rnd-thoughts
pushed a commit
that referenced
this pull request
Nov 4, 2026
…#67794) ## Problem - The NCCL hang detector dumps a hung worker's stack with an unprivileged `py-spy dump --pid <pid> --native`. - In containers with restricted ptrace that call always fails. The dump then has no native frames, so it cannot show where NCCL is blocked. - py-spy reports: `Permission Denied: Try running again with elevated permissions by going 'sudo env "PATH=$PATH" !!'` - Verified on an Anyscale worker: `CapEff: 0000000000000000`, `/proc/sys/kernel/yama/ptrace_scope` is `1`, so a child py-spy cannot trace its parent. - The `ray` user there has passwordless sudo, and `sudo env PATH=$PATH py-spy dump --pid <pid> --native` succeeds with native frames. ## Change - Try the unprivileged py-spy first, as today. - If it fails and `sudo -n true` succeeds, retry as `sudo -n env PATH=... py-spy dump --pid <pid> --native` with the same timeout. - Otherwise fall through to the Python-only dump, with py-spy's own error message. - This mirrors `_can_passwordless_sudo` in `python/ray/dashboard/modules/reporter/profile_manager.py`, run synchronously. - `dump_stack_trace` is split into `_run_py_spy(cmd, timeout_s)` and `_can_passwordless_sudo()`. ``` py-spy dump --native ──fail──> sudo -n true ok? ──yes──> sudo -n env PATH=... py-spy dump --native └──no──> Python-only dump (as today) ``` ## Decisions to confirm - The sudo check is cached per process, since the hung worker may dump more than once. - `sudo -n` is used everywhere so it can never prompt for a password. - The `sudo -n true` check has a 5 s timeout. - sudo is not tried when py-spy is not on `PATH`. A missing binary is not a permission problem. - The timeout is a budget for the whole dump. The sudo check and retry only get what the first attempt left, so the fan-out timeout still holds. ## Related - Detector PRs by @pseudo-rnd-thoughts: #64928, #66203, #66629, #66627. - Companion PR #67795 adds thread names to the Python-only fallback; the two touch different parts of `dump_stack_trace` and apply independently. Duplicate-work check: `gh pr list -R ray-project/ray --search "nccl_ras OR hang detector"` and `--search "py-spy sudo"` returned nothing related (only the unrelated Grafana PRs #66958 and #66810). Tests: `python -m pytest python/ray/train/v2/tests/test_nccl_ras_callback.py -v` passes, 120 passed, including four new `dump_stack_trace` sudo tests. AI assistance (Claude Code) was used for this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Marwan Sarieddine <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
Problem: - py-spy is refused on most containerised workers, so the Python-only fallback is the dump users actually read. - The fallback labels each thread with its numeric ident only. - The reader has to infer from the frames which thread is Ray Train's training thread, the monitoring thread, or the actor main thread. Change: - Each thread header carries the thread's name next to its ident. - Threads not started through threading are labelled unknown. - A unit test covers a named thread and the main thread. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116
force-pushed
the
marwan/train-nccl-ras-thread-names
branch
from
November 4, 2026 14:22
a674dd4 to
cdd2578
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CapEff, Yamaptrace_scope1).TrainingThread(train_func), which is theMonitoringThread, and which is the actor main thread.Change
dump_stack_tracelooks up thread names once throughthreading.enumerate()and prints the name next to the ident.Decisions to confirm
threading.enumerate()(threads not started throughthreading, for example C-created ones) are labelledunknown.Related
Duplicate-work check:
gh pr list -R ray-project/ray --search "nccl_ras OR hang detector"and a search for "thread name" with "nccl_ras" found no PR making this change (only the Grafana and user-guide PRs #66958, #66810, #67068 and the sibling #67794).Test:
python -m pytest python/ray/train/v2/tests/test_nccl_ras_callback.py -vpasses, 117 tests.pre-commit run --fileson both files passes.AI assistance (Claude Code) was used for this PR.
🤖 Generated with Claude Code