Skip to content

[perf] feat: add profiler post hook, fix behaviors and allow comprehensive torch profiler - #7408

Merged
wuxibin89 merged 18 commits into
verl-project:mainfrom
ETOgaosion:feat/perf_with_post_hook
Aug 19, 2026
Merged

wuxibin89 merged 18 commits into
verl-project:mainfrom
ETOgaosion:feat/perf_with_post_hook

Conversation

@ETOgaosion

@ETOgaosion ETOgaosion commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

  1. add profiler post hook, current torch profiler API works with:
    actor_rollout_ref.actor.profiler.enable=True
    actor_rollout_ref.actor.profiler.ranks=${profile_ranks}
    actor_rollout_ref.actor.profiler.all_ranks=${profile_ranks_all}
    actor_rollout_ref.actor.profiler.tool_config.torch.discrete=${profile_discrete}
    actor_rollout_ref.actor.profiler.tool_config.torch.contents=${profile_contents}
    actor_rollout_ref.actor.profiler.tool_config.torch.schedule.skip_first=${profile_schedule_skip_first}
    actor_rollout_ref.actor.profiler.tool_config.torch.schedule.wait=${profile_schedule_wait}
    actor_rollout_ref.actor.profiler.tool_config.torch.schedule.warmup=${profile_schedule_warmup}
    actor_rollout_ref.actor.profiler.tool_config.torch.schedule.active=${profile_schedule_active}
    actor_rollout_ref.actor.profiler.tool_config.torch.schedule.repeat=${profile_schedule_repeat}
    actor_rollout_ref.actor.profiler.finish_hook_cmd="hdfs upload ${profile_save_path}"
    actor_rollout_ref.actor.profiler.finish_hook_ranks=${profile_ranks}

    // same with rollout/ref/critic
    global_profiler.tool=torch
    global_profiler.steps=${profile_steps}
    global_profiler.save_path=${profile_save_path}
    global_profiler.relocate_results=True    // for rollout and nsys profiler, relocate results to profile_save_path
  1. fix behaviors and allow comprehensive torch profiler.

Now torch profiler discrete mode creates:

image

When discrete=False, the actors' profiling results fused to actor-rollout-ref_train_step1_rank0-of-16_pid10256_20260814122731089.json

For compute log probs:

image

For Rollout:

image

For trainer:

image

For discrete=False:

image

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, fully_async, one_step_off
    • 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.

API and Usage Example

Demonstrate how the API changes if any, and provide usage example(s) if possible.

# Add code snippet or script demonstrating how to use this

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.

@ETOgaosion
ETOgaosion marked this pull request as ready for review August 14, 2026 06:05
ETOgaosion and others added 16 commits August 14, 2026 14:05
`ranks` are global GPU ranks (as in training roles). A tp>1 engine must
profile its whole replica, so filter during trace relocation to keep only
the requested GPUs: e.g. tp=2 ranks=[0,8] -> only GPU 0 and 8 in save_path,
their tp-mates (1, 9) stay in the per-replica sub-directory. Relocated
traces are named by absolute global rank (rollout-replica<n>-globalrank<g>_)
so files line up with the configured ranks.

Assisted-by: Cursor
Co-authored-by: Cursor <cursoragent@cursor.com>
@ETOgaosion
ETOgaosion force-pushed the feat/perf_with_post_hook branch from 594fad6 to 7093712 Compare August 14, 2026 06:11
@ETOgaosion
ETOgaosion force-pushed the feat/perf_with_post_hook branch from d6f1f28 to bfae285 Compare August 14, 2026 10:13
@ETOgaosion
ETOgaosion requested a review from HollowMan6 as a code owner August 17, 2026 04:25
# `ranks` in the rollout profiler config are global GPU ranks (as in the training roles);
# map them to the replica that owns them so e.g. ranks=[0, 8] with tp=8 profiles the replicas
# holding global ranks 0 and 8 (replicas 0 and 1), not replica indices 0 and 8.
self.replica_world_size = (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we really need to profile rollout(vllm/sglang) in RL framework? Maybe prometheus metrics is a better option.

@wuxibin89
wuxibin89 merged commit 9097cc4 into verl-project:main Aug 19, 2026
81 of 107 checks passed
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.

2 participants