Repository navigation
[Train] Retry py-spy with sudo in the NCCL hang detector's stack dump - #67794
Merged
Merged
Conversation
Problem: - The hang detector dumps a worker's stack with an unprivileged `py-spy dump --native`. - In containers with restricted ptrace that call always fails, so the dump has no native frames and cannot show where NCCL is blocked. - The same hosts often allow passwordless sudo, and py-spy under sudo works there. Change: - When the unprivileged py-spy fails and `sudo -n true` succeeds, retry py-spy under `sudo -n env PATH=...`. - The sudo check runs once per process and never prompts. - Without passwordless sudo, the Python-only fallback is unchanged. - This mirrors the dashboard profiler's handling in profile_manager.py. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Marwan Sarieddine <[email protected]>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 8416cd8. Configure here.
Problem: - The sudo retry started a second full py-spy timeout after the first attempt, plus the sudo check, so a dump could outlive the caller's fan-out timeout and be dropped. Change: - Treat the timeout as a budget for the whole dump. - The sudo check and retry only get what the first attempt left. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Marwan Sarieddine <[email protected]>
pseudo-rnd-thoughts
approved these changes
Nov 4, 2026
pseudo-rnd-thoughts
left a comment
Member
There was a problem hiding this comment.
Thanks @marwan116
pseudo-rnd-thoughts
pushed a commit
that referenced
this pull request
Nov 4, 2026
…mp (#67795) ## Problem - py-spy is refused on many workers because ptrace is restricted in containers. Every Anyscale worker is one of them (empty `CapEff`, Yama `ptrace_scope` 1). - The Python-only fallback is therefore the dump users actually see. - It labels each thread with its numeric ident only. The reader has to infer from the frames which one is Ray Train's `TrainingThread(train_func)`, which is the `MonitoringThread`, and which is the actor main thread. - Current output, from a hung Ray Train worker on Anyscale: ``` # Thread 137667459151424 File "/usr/lib/python3.12/threading.py", line 1030, in _bootstrap self._bootstrap_inner() ``` ## Change - `dump_stack_trace` looks up thread names once through `threading.enumerate()` and prints the name next to the ident. - The rest of the dump is unchanged. ``` before: # Thread 137667459151424 after: # Thread 137667459151424 (TrainingThread(train_func)) ``` ## Decisions to confirm - Threads that are not in `threading.enumerate()` (threads not started through `threading`, for example C-created ones) are labelled `unknown`. ## Related - Detector PRs by @pseudo-rnd-thoughts: #64928, #66203, #66629, #66627. - #67794 (sudo retry for py-spy) touches the same function but not these lines. The two apply independently. 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 -v` passes, 117 tests. `pre-commit run --files` on both files passes. 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]>
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
py-spy dump --pid <pid> --native.Permission Denied: Try running again with elevated permissions by going 'sudo env "PATH=$PATH" !!'CapEff: 0000000000000000,/proc/sys/kernel/yama/ptrace_scopeis1, so a child py-spy cannot trace its parent.rayuser there has passwordless sudo, andsudo env PATH=$PATH py-spy dump --pid <pid> --nativesucceeds with native frames.Change
sudo -n truesucceeds, retry assudo -n env PATH=... py-spy dump --pid <pid> --nativewith the same timeout._can_passwordless_sudoinpython/ray/dashboard/modules/reporter/profile_manager.py, run synchronously.dump_stack_traceis split into_run_py_spy(cmd, timeout_s)and_can_passwordless_sudo().Decisions to confirm
sudo -nis used everywhere so it can never prompt for a password.sudo -n truecheck has a 5 s timeout.PATH. A missing binary is not a permission problem.Related
dump_stack_traceand 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 -vpasses, 120 passed, including four newdump_stack_tracesudo tests.AI assistance (Claude Code) was used for this PR.
🤖 Generated with Claude Code