Repository navigation
[Train] Change controller state grafana panel to be state timeline - #66810
pseudo-rnd-thoughts wants to merge 3 commits into
Conversation
Signed-off-by: Mark Towers <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request refactors the tracking of enum metrics (specifically the Ray Train controller state) to use a single-series approach where the gauge value represents a numeric code. This enables the use of Grafana's state timeline panel to visualize controller states over time. The changes include updates to the dashboard configurations, metric definitions, documentation, and tests. Feedback suggests adding validation to EnumMetric initialization to ensure that enum_codes is not empty and that all members of the enum class are mapped, preventing potential runtime KeyErrors.
| codes = list(enum_codes.values()) | ||
| if self.DEFAULT_VALUE in codes or len(set(codes)) != len(codes): | ||
| raise ValueError( | ||
| f"Enum codes must be unique and non-zero, got {enum_codes}." | ||
| ) | ||
| self._enum_codes = enum_codes |
There was a problem hiding this comment.
It is highly recommended to validate that enum_codes is not empty and that all members of the enum class are mapped. This prevents runtime KeyErrors when trying to record an unmapped enum value.
if not enum_codes:
raise ValueError(\"enum_codes must not be empty.\")
codes = list(enum_codes.values())
if self.DEFAULT_VALUE in codes or len(set(codes)) != len(codes):
raise ValueError(
f\"Enum codes must be unique and non-zero, got {enum_codes}.\"
)
first_key = next(iter(enum_codes.keys()))
if isinstance(first_key, Enum):
enum_class = type(first_key)
missing_members = [member for member in enum_class if member not in enum_codes]
if missing_members:
raise ValueError(
f\"All enum members of {enum_class.__name__} must be mapped in enum_codes. Missing: {missing_members}\"
)
self._enum_codes = enum_codesSigned-off-by: Mark Towers <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
…#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]>
…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 pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
Description
The controller state in Anyscale has always looked a bit buggy, mainly because we were trying to represent a one-hot event with a bar chart.
Looking through the type of panels that Grafana supports, state timeline is the exact thing we should be using https://grafana.com/docs/grafana/latest/visualizations/panels-visualizations/visualizations/state-timeline/
This PR updates the panel to use the state-timeline panel type.
As the Ray version specifics the type of panel, not Anyscale, this means that we can update here and Anyscale will be updated and we should have no backward compatibility worries.
It is experimental until demonstrated on Anyscale to be working. Next steps
The motivation for this is that we are adding a new controller state for the hang detector (#66627) which this improvement could utilise.