Skip to content

[rollout, perf] fix: support profiling for rollout via remote command in async mode#5001

Closed
bithighrr wants to merge 5 commits intoverl-project:mainfrom
shenyichong:rollout_profiling
Closed

[rollout, perf] fix: support profiling for rollout via remote command in async mode#5001
bithighrr wants to merge 5 commits intoverl-project:mainfrom
shenyichong:rollout_profiling

Conversation

@bithighrr
Copy link
Contributor

… in async mode

What does this PR do?

fix 4575

Fix the core issue that rollout processes cannot be profiled in async mode. Since rollout (e.g., sglang implementation) runs as an independent process in async mode, profiling cannot be triggered via local function calls. This PR adds remote command interfaces to send start/stop instructions to the rollout process, enabling proper control of profiling workflows and successful collection of performance data from rollout processes.

Checklist Before Starting

  • Search for similar PRs. Paste at least one query link here: ...
  • Format the PR title as [{modules}] {type}: {description} (This will be checked by the CI)
    • {modules} include fsdp, megatron, veomni, sglang, vllm, rollout, trainer, ci, training_utils, recipe, hardware, deployment, ray, worker, single_controller, misc, perf, model, algo, env, tool, ckpt, doc, data, cfg, reward
    • If this PR involves multiple modules, separate them with , like [megatron, fsdp, doc]
    • {type} is in feat, fix, refactor, chore, test
    • If this PR breaks any API (CLI arguments, config, function signature, etc.), add [BREAKING] to the beginning of the title.
    • Example: [BREAKING][fsdp, megatron] feat: dynamic batching

Test

For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.
The newly added feature has been verified successfully in the sglang 0.5.5 environment. Core validation steps and results are as follows:

  1. Add rollout profiling configurations when launching training
python3 -m verl.trainer.main_ppo \
...
    actor_rollout_ref.rollout.name=sglang \
    actor_rollout_ref.rollout.mode=async \
    actor_rollout_ref.rollout.profiler.enable=True \
    actor_rollout_ref.rollout.profiler.tool=torch \
    actor_rollout_ref.rollout.profiler.ranks="[0]" \
    actor_rollout_ref.rollout.profiler.save_path="/path/to/save" \
    actor_rollout_ref.rollout.profiler.tool_config.torch.profile_by_stage=False \
    actor_rollout_ref.rollout.profiler.tool_config.torch.merge_profiles=False \
    actor_rollout_ref.rollout.profiler.tool_config.torch.step_start=1 \
    actor_rollout_ref.rollout.profiler.tool_config.torch.step_end=5 \
    global_profiler.steps='[0, 1, 2]' \
...
  1. Validation Results: The rollout process successfully starts profiling, collects performance data as expected, and outputs performance data files to /path/to/save.

For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.

API and Usage Example

Added three interfaces (start_profile_auto_stop, start_profile, stop_profile) to the BaseRollout class, implemented these interfaces in ServerAdapter, and called them in ActorRolloutRefWorker.rollout_mode to control the rollout profiling workflow.
Added the file verl/utils/profiler/rollout_profile.py, which includes rollout_profile_args and _get_sglang_profile_tags interfaces to encapsulate user-specified parameters for the newly added APIs.

Design & Code Changes

Demonstrate the high-level design if this PR is complex, and list the specific changes.

Checklist Before Submitting

Important

Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.

@CLAassistant
Copy link

CLAassistant commented Jan 21, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces remote command interfaces to enable profiling for rollout processes in async mode, specifically addressing issues with SGLang implementations. The changes include adding new profiling-related functions and methods across verl/utils/profiler/__init__.py, verl/utils/profiler/rollout_profile.py, verl/workers/megatron_workers.py, verl/workers/rollout/base.py, verl/workers/rollout/sglang_rollout/http_server_engine.py, and verl/workers/rollout/sglang_rollout/sglang_rollout.py. The new rollout_profile_args function generates profiling parameters, and abstract methods for profiling control are added to BaseRollout and implemented in ServerAdapter. The integration in ActorRolloutRefWorker allows for starting and stopping profiling based on configuration. Overall, the changes enhance the profiling capabilities for distributed rollout systems.

bithighrr and others added 4 commits January 21, 2026 15:59
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@wuxibin89
Copy link
Collaborator

Support in #4320

@wuxibin89 wuxibin89 closed this Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

verl自带的nsys profiler工具无法捕获rollout阶段的算子信息

3 participants