Skip to content

Conversation

guyueh1
Copy link
Contributor

@guyueh1 guyueh1 commented Oct 8, 2025

What does this PR do ?

If user set RAY_DEBUG=legacy before running ray.sub, the debug mode will be turned on and user can attach to breakpoints via ray debug.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

Summary by CodeRabbit

  • New Features
    • Legacy debug mode now automatically enables external debugger support for both head and worker start commands. No extra steps are required; the appropriate argument is injected before the blocking startup flag. This streamlines attaching external debuggers during development and troubleshooting. Applies uniformly across nodes, improving parity with legacy tooling and reducing setup friction.

Signed-off-by: Guyue Huang <guyueh@nvidia.com>
@guyueh1 guyueh1 requested a review from a team as a code owner October 8, 2025 17:00
@guyueh1 guyueh1 requested review from a team and removed request for a team October 8, 2025 17:00
@guyueh1 guyueh1 added the CI:L0 Run doctests and unit tests label Oct 8, 2025
Copy link
Contributor

coderabbitai bot commented Oct 8, 2025

📝 Walkthrough

Walkthrough

Introduces RAY_DEBUGGER_ARGS, set to "--ray-debugger-external" when RAY_DEBUG="legacy", and injects it into the ray start commands for head and worker nodes before the --block flag. Includes minor formatting updates within the same script.

Changes

Cohort / File(s) Summary of Changes
Ray start script updates
ray.sub
Added RAY_DEBUGGER_ARGS conditional on RAY_DEBUG="legacy"; inserted $RAY_DEBUGGER_ARGS into both head and worker ray start commands before --block; minor formatting adjustments.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Script as ray.sub
  participant Ray as ray start

  User->>Script: Invoke ray start (head/worker)
  Script->>Script: Check RAY_DEBUG
  alt RAY_DEBUG="legacy"
    Script->>Script: Set RAY_DEBUGGER_ARGS="--ray-debugger-external"
  else
    Script->>Script: Set RAY_DEBUGGER_ARGS=""
  end
  Script->>Ray: Start with args + $RAY_DEBUGGER_ARGS + --block
  Ray-->>User: Process runs (blocked)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the primary change by noting the addition of a debugger flag toggled via RAY_DEBUG=legacy, making it clear and immediately informative for reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Test Results For Major Changes ✅ Passed The PR only introduces a conditional debugger flag in a shell script, which is a small, non-breaking tweak without broader numeric or performance implications, so it does not qualify as a major change that would mandate documented test results. Given the limited scope, the absence of explicit testing information in the description is acceptable under the check’s guidance. Therefore the custom check passes.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ray.sub (1)

67-70: Quote RAY_DEBUG in the condition and rely on existing docs
Documentation for RAY_DEBUG=legacy already exists in docs/debugging.md. Guard against unset variables by quoting in the condition:

- if [ $RAY_DEBUG = "legacy" ]; then
+ if [ "$RAY_DEBUG" = "legacy" ]; then

Optionally set a default or emit a warning when RAY_DEBUG is unset.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57046a4 and 9fe5d7b.

📒 Files selected for processing (1)
  • ray.sub (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: sphinx-build / Build docs
  • GitHub Check: Lint check
  • GitHub Check: Lint check
  • GitHub Check: Post submodule check comment / Comment on PR
  • GitHub Check: Post automodel integration comment / Comment on PR
🔇 Additional comments (2)
ray.sub (2)

283-285: LGTM: Debugger args correctly positioned before --block.

The $RAY_DEBUGGER_ARGS is correctly inserted before the --block flag, ensuring proper command structure for the head node.

Note: Line 285 has a trailing space after --block, which is a minor formatting issue but does not affect functionality.


383-385: LGTM: Debugger args correctly positioned before --block.

The $RAY_DEBUGGER_ARGS is correctly inserted before the --block flag for worker nodes, maintaining consistency with the head node configuration.

Note: Line 385 has a trailing space after --block, which is a minor formatting issue but does not affect functionality.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Guyue Huang <140554423+guyueh1@users.noreply.github.com>
@terrykong
Copy link
Contributor

@guyueh1 for my education, what does this change enable that you couldn't do with https://docs.nvidia.com/nemo/rl/latest/debugging.html ?

@guyueh1
Copy link
Contributor Author

guyueh1 commented Oct 12, 2025

@terrykong this is an alternative way, won't enable more than the vscode debugger; it is just a way to run ray debug even without IDE. The way to debug is

  1. Set RAY_DEBUG=legacy before starting the job (ray.sub)
  2. Add breakpoint() to your code
  3. When the job has started, use another terminal to connect to the header node via bash <job-id>-attach.sh and run ray debug interactively. You will be able to see and attach to the breakpoint and use PDB-style commands to debug.

@terrykong
Copy link
Contributor

oh interesting, so before when i set RAY_DEBUG=legacy uv run examples/run_grpo_math.py i was only able to get a breakpoint into the driver and needed to use the distributed debugger for breakpointing into actors/tasks, but you're saying when adding this to the head/worker startup args, you can breakpoint into actors as well?

if so, that's awesome. do you think you could update https://github.com/NVIDIA-NeMo/RL/blob/main/docs/debugging.md with this new method?

@terrykong terrykong self-requested a review October 12, 2025 05:30
Signed-off-by: Guyue Huang <guyueh@nvidia.com>
@guyueh1 guyueh1 added the documentation Improvements or additions to documentation label Oct 14, 2025
@guyueh1 guyueh1 requested a review from a team as a code owner October 14, 2025 17:31
@guyueh1
Copy link
Contributor Author

guyueh1 commented Oct 14, 2025

@terrykong yes, you need to set both RAY_DEBUG=legacy and --ray-debugger-external , then you can breakpoint into actors from header in a separate terminal that spins ray debug (also refer to verl's doc)

I have updated our doc.

@terrykong
Copy link
Contributor

@jgerh to review

@terrykong terrykong requested a review from jgerh October 15, 2025 16:46
Copy link
Contributor

@jgerh jgerh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completed tech pubs review and left a few copyedits and suggested text revisions.

@guyueh1 guyueh1 added CI:L0 Run doctests and unit tests and removed CI:L0 Run doctests and unit tests labels Oct 16, 2025
@guyueh1
Copy link
Contributor Author

guyueh1 commented Oct 20, 2025

@terrykong i think this is ready for merge, if L0 test is enough

@terrykong terrykong enabled auto-merge (squash) October 21, 2025 05:00
@terrykong terrykong merged commit f286857 into NVIDIA-NeMo:main Oct 21, 2025
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L0 Run doctests and unit tests documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants