Repository navigation
draft: fix(nsys): make profiling work on SingleController and align throughput metrics - #3517
Open
ZhiyuLi-Nvidia wants to merge 1 commit into
Open
ZhiyuLi-Nvidia wants to merge 1 commit into
ZhiyuLi-Nvidia wants to merge 1 commit into
Conversation
…metrics Profiling an SC + TransferQueue run produced empty traces, and enabling it on vLLM generation reliably killed the job. nsys fixes ---------- 1. `single_controller.py` never called `maybe_gpu_profile_step`. Every other algorithm entrypoint does (grpo, ppo, sft, dpo, rm, distillation). Since the nsight config uses `capture-range=cudaProfilerApi`, nsys attached but `cudaProfilerStart` was never issued, so every `.nsys-rep` came out empty. 2. Stop enabling `ray_workers_use_nsight` for vLLM. vLLM hardcodes an always-on nsight config for its internal TP workers (no `capture-range`), so nsys traced cuda,cudnn,cublas from process start for the whole run. That overhead skews ranks until a collective blows the NCCL watchdog: on a 6xGB200 SC run all 24 TP workers aborted on a 600s `_ALLGATHER_BASE` timeout on a 64K-element collective. vLLM offers no override -- the config is built inside a spawned EngineCore process -- so the only safe option is to leave the flag off. Generation is still covered by the outer worker's own profile. 3. Remove `_patch_vllm_nsight_config`, which tried to override that config by rebinding the class method. It cannot work: the rebind happens in the worker actor, while vLLM configures the executor in a spawned subprocess. Confirmed from the runtime-env agent logs of a run where it was active -- 18 workers received vLLM's default `worker_process_%p`, none the intended `vllm_tp_worker_*`. It was silently letting the harmful config through. 4. `stop_gpu_profiling` was unguarded, so a profiling teardown failure aborted the run at the diagnostic call rather than at real work. Now best-effort. Adds NVTX ranges to the TransferQueue hops (`tq_fetch`, `tq_write_back`) and to `prepare_for_training` / `prepare_for_lp_inference`, which the SC loop calls every inner-loop iteration and which were invisible in traces. `wrap_with_nvtx_name` now delegates to `torch.cuda.nvtx.range`, a ContextDecorator that pops in a `finally`, so a raising call cannot leak an unbalanced range and mis-nest every later range in the trace. Docs record two hardware traps: `stop-shutdown` ends the nsys session at the capture range, signalling the profiled workers to exit; and `gpu-metrics-device` is unsupported on some GPUs (GB200), where Ray's nsight plugin fails validation and silently drops the traces of workers that landed on a rejecting node. metrics alignment ----------------- Throughput rates were split across three namespaces: `timing/train/` (8 algorithms), `performance/` (3, via `print_performance_metrics`) and `train/` (distillation). `timing/train/` also mixed rates with durations, so its printout formatted tokens/sec as seconds. All rates now live under `performance/`, leaving `timing/train/` for durations: performance/valid_tokens_per_sec_per_gpu global_valid_toks / step / gpus performance/tokens_per_sec_per_gpu total_num_tokens / step / gpus Both keys are present in all 8 algorithms; five gained a `prefix="performance"` log call. Duplicates removed (distillation's `train/` copy, and a redundant metric with the same formula as the helper's existing key). Per-algorithm guard conditions are preserved -- this is a namespace move, not a behaviour change. BREAKING: `timing/train/valid_tokens_per_sec_per_gpu` is now `performance/valid_tokens_per_sec_per_gpu`. Dashboards keyed on the old path need updating; historical runs keep the old key. Verified on 6xGB200 (SC + TQ, Nemotron-3-Nano-30B-A3B): 24/24 GPUs produced valid non-empty traces (16 trainer + 8 generation, 0.67 GB), zero NCCL watchdog timeouts, and the teardown guard fired as designed. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: zhiyul <[email protected]>
1 task done
This branch has not been deployed
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.
Profiling an SC + TransferQueue run produced empty traces, and enabling it on vLLM generation reliably killed the job.
nsys fixes
single_controller.pynever calledmaybe_gpu_profile_step. Every other algorithm entrypoint does (grpo, ppo, sft, dpo, rm, distillation). Since the nsight config usescapture-range=cudaProfilerApi, nsys attached butcudaProfilerStartwas never issued, so every.nsys-repcame out empty.Stop enabling
ray_workers_use_nsightfor vLLM. vLLM hardcodes an always-on nsight config for its internal TP workers (nocapture-range), so nsys traced cuda,cudnn,cublas from process start for the whole run. That overhead skews ranks until a collective blows the NCCL watchdog: on a 6xGB200 SC run all 24 TP workers aborted on a 600s_ALLGATHER_BASEtimeout on a 64K-element collective. vLLM offers no override -- the config is built inside a spawned EngineCore process -- so the only safe option is to leave the flag off. Generation is still covered by the outer worker's own profile.Remove
_patch_vllm_nsight_config, which tried to override that config by rebinding the class method. It cannot work: the rebind happens in the worker actor, while vLLM configures the executor in a spawned subprocess. Confirmed from the runtime-env agent logs of a run where it was active -- 18 workers received vLLM's defaultworker_process_%p, none the intendedvllm_tp_worker_*. It was silently letting the harmful config through.stop_gpu_profilingwas unguarded, so a profiling teardown failure aborted the run at the diagnostic call rather than at real work. Now best-effort.Adds NVTX ranges to the TransferQueue hops (
tq_fetch,tq_write_back) and toprepare_for_training/prepare_for_lp_inference, which the SC loop calls every inner-loop iteration and which were invisible in traces.wrap_with_nvtx_namenow delegates totorch.cuda.nvtx.range, a ContextDecorator that pops in afinally, so a raising call cannot leak an unbalanced range and mis-nest every later range in the trace.Docs record two hardware traps:
stop-shutdownends the nsys session at the capture range, signalling the profiled workers to exit; andgpu-metrics-deviceis unsupported on some GPUs (GB200), where Ray's nsight plugin fails validation and silently drops the traces of workers that landed on a rejecting node.metrics alignment
Throughput rates were split across three namespaces:
timing/train/(8 algorithms),performance/(3, viaprint_performance_metrics) andtrain/(distillation).timing/train/also mixed rates with durations, so its printout formatted tokens/sec as seconds.All rates now live under
performance/, leavingtiming/train/for durations:performance/valid_tokens_per_sec_per_gpu global_valid_toks / step / gpus
performance/tokens_per_sec_per_gpu total_num_tokens / step / gpus
Both keys are present in all 8 algorithms; five gained a
prefix="performance"log call. Duplicates removed (distillation'strain/copy, and a redundant metric with the same formula as the helper's existing key). Per-algorithm guard conditions are preserved -- this is a namespace move, not a behaviour change.BREAKING:
timing/train/valid_tokens_per_sec_per_gpuis nowperformance/valid_tokens_per_sec_per_gpu. Dashboards keyed on the old path need updating; historical runs keep the old key.Verified on 6xGB200 (SC + TQ, Nemotron-3-Nano-30B-A3B): 24/24 GPUs produced valid non-empty traces (16 trainer + 8 generation, 0.67 GB), zero NCCL watchdog timeouts, and the teardown guard fired as designed.
What does this PR do ?
Add a one line overview of what this PR aims to accomplish.
Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information