Skip to content

Commit f286857

Browse files
feat: Add debugger flag that can be turned on via RAY_DEBUG=legacy (#1312)
Signed-off-by: Guyue Huang <[email protected]> Signed-off-by: Guyue Huang <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 73c8725 commit f286857

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

docs/debugging.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ Note that you can jump between breakpoints across all workers with this process.
6868

6969
![Ray Debugger Extension Step 4](./assets/ray-debug-step4.png)
7070

71-
## Debug the Driver Script
71+
## Debug with legacy Ray debugger
7272

73-
By default, setting breakpoints in the driver script (outside of `@ray.remote`) will not pause program execution when using Ray. To enable pausing at these breakpoints, set the environment variable to `RAY_DEBUG=legacy`:
73+
To use legacy ray debugger, you can use two ways
74+
1. In general, set `RAY_DEBUG=legacy` and add `--ray-debugger-external` to your `ray start` command
75+
2. If you are using `ray.sub` in a slurm cluster, you can simply set `RAY_DEBUG=legacy` before `sbatch ray.sub`, the script can detect this environment variable and attach `--ray-debugger-external` automatically.
7476

75-
```sh
76-
RAY_DEBUG=legacy uv run ....
77-
```
77+
After you start ray with these changes, you can add `breakpoint` to your code. When you run the program, it will stop at where breakpoints are inserted. Then you can use a separate terminal to attach to the header node via `bash <JOB_ID>-attach.sh` (this script should automatically be generated by `ray.sub`), and run `ray debug` to see all the breakpoints. You can enter any breakpoint and interactively debug. Please refer to [Ray documentation](https://docs.ray.io/en/latest/ray-observability/user-guides/debug-apps/ray-debugging.html) for more info on this debugging approach.

ray.sub

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ RAY_CLIENT_SERVER_PORT=${RAY_CLIENT_SERVER_PORT:-10001}
6464
#REDIT_SHARD_PORTS=${REDIT_SHARD_PORTS:-"random"} ??
6565
DASHBOARD_PORT=${DASHBOARD_PORT:-8265} # Also used by debugger
6666
DASHBOARD_AGENT_LISTEN_PORT=${DASHBOARD_AGENT_LISTEN_PORT:-52365}
67+
RAY_DEBUGGER_ARGS=
68+
if [ "${RAY_DEBUG:-}" = "legacy" ]; then
69+
RAY_DEBUGGER_ARGS="--ray-debugger-external"
70+
fi
6771

6872
# Setting ulimit is recommended by ray best practices page
6973
# @ https://docs.ray.io/en/latest/cluster/vms/user-guides/large-cluster-best-practices.html
@@ -276,8 +280,9 @@ ray start --head \
276280
--dashboard-agent-grpc-port=$((${DASHBOARD_AGENT_GRPC_PORT} + 1)) \
277281
--dashboard-agent-listen-port=$((${DASHBOARD_AGENT_LISTEN_PORT} + 1)) \
278282
--metrics-export-port=$((${METRICS_EXPORT_PORT} + 1)) \
283+
$RAY_DEBUGGER_ARGS \
279284
\
280-
--block
285+
--block
281286
EOFINNER
282287
chmod +x /launch-head.sh
283288
@@ -375,8 +380,9 @@ ray start --address "$ip_head" \
375380
--dashboard-agent-grpc-port=${DASHBOARD_AGENT_GRPC_PORT} \
376381
--dashboard-agent-listen-port=${DASHBOARD_AGENT_LISTEN_PORT} \
377382
--metrics-export-port=${METRICS_EXPORT_PORT} \
383+
$RAY_DEBUGGER_ARGS \
378384
\
379-
--block
385+
--block
380386
EOFINNER
381387
382388
count=0

0 commit comments

Comments
 (0)