Skip to content

docs(skills): add cross-engine rollout-perf contributor skill - #4556

Open
joyang-nv wants to merge 8 commits into
mainfrom
joyang/rollout-perf-skill
Open

joyang-nv wants to merge 8 commits into
mainfrom
joyang/rollout-perf-skill

Conversation

@joyang-nv

@joyang-nv joyang-nv commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Adds rollout-perf, a contributor skill for diagnosing and optimizing rollout (generation) performance on every generation backend: vLLM, SGLang, TensorRT-LLM, Megatron inference and Dynamo. It covers batch GRPO-style training and multi-turn agentic (NeMo Gym) rollouts. It also adds a stdlib-only helper that reads a run's metrics.json and driver log.

Why

Generation is often most of a GRPO/DAPO step. Some of our CI tests run vLLM eager with no recorded reason.

For example, dapo-nanov3.5-30BA3B-4n8g-automodel and its router-replay variant (#4458) were run as a same-window A/B on cw_dfw: 4n8g H100, frozen container rl.70859871.sqsh, identical code. The only change was enforce_eager: true → enforce_eager=false, cudagraph_mode=PIECEWISE, fuse_allreduce_rms=false.

non-R3 before → after R3 before → after
Generation per step (median of 20 paired steps) 325.1 → 100.6 s (−69%) 330.0 → 104.1 s (−68%)
Total step time (sum of 20 steps) 8198 → 3204 s (−61%) 8353 → 3307 s (−60%)
Validation (3 runs) 944 → 197 s 957 → 191 s
Setup (includes compile and capture) 313 → 334 s 312 → 335 s
Slurm wall 152 → 65 min (−57%) 155 → 67 min (−57%)
Mean generated tokens per sample 5355 → 5383 5394 → 5397
token_mult_prob_error median / gen_kl_error mean 1.016 / 0.00086 → 1.016 / 0.00084 1.010 / 0.00037 → 1.010 / 0.00036

The per-step generation ratio stayed between 0.30 and 0.33 across all 40 paired steps. The non-R3 test failed its pre-existing step-20 token_mult_prob_error gate in both arms (5.7e8 before, 1.056 after); that failure is the one #4459 addresses. The recipe change itself will come in a separate PR.

Changes

  • skills/rollout-perf/SKILL.md (discovered through the shared .claude/skills and .agents/skills links):
    • How to diagnose the regime (generation-bound, decode-tail-bound, prefill-heavy, eager, or KV-bound) from metrics.json and the vLLM engine log.
    • The levers for each regime. The graph mode is chosen by A/B against eager, starting from vLLM's default FULL_AND_PIECEWISE. PIECEWISE-only was a workaround for the vLLM 0.20 FULL-graph accuracy bug, and on vLLM 0.29 it is no longer a rule. When Inductor-compiled kernels break logprob parity, the fallback is compilation_config.backend: eager.
    • What not to use: frozen MTP drafters, prefix caching under R3, precision changes, and JIT caches on shared Lustre.
    • A same-window A/B through tools/launch (CODE_SNAPSHOT_DIRNAME, EXTRA_SCRIPT_ARGS), checked against the engine log.
    • Correctness gates (token_mult_prob_error, gen_kl_error, generation length, accuracy against step-0 noise).
    • How to land the change: comment in the recipe, set NUM_MINUTES from the measured wall time, and adjust checkpoint_must_save_by.
  • skills/rollout-perf/rollout_perf_report.py: diagnoses one run, or compares two runs paired by step. Standard library only.
  • skills/testing/SKILL.md: the nightly-test checklist now points to the skill.

Testing

  • Ran the helper on four real runs (dapo-nanov3.5-30BA3B-4n8g-automodel ± R3, eager and PIECEWISE) in both modes. Its output matches the analysis above. It reads the effective cudagraph_mode from the engine line ('cudagraph_mode': <CUDAGraphMode.PIECEWISE: 1>) and skips the Overrides: echo.
  • Exercised the edge cases: missing timing, zero step times, a zero baseline value, and runs with different step counts.
  • ruff check and ruff format pass. The script has the 2026 copyright header and runs on Python 3.9+ (from __future__ import annotations).
  • A separate reviewer checked the doc's config keys, log formats and metric names against the code (vllm_worker.py, tools/launch, code_snapshot.sh, ray.sub, loss_functions.py).

Update: cw_dfw A/B sweep (second commit)

The skill guidance now reflects same-window A/Bs on 13 cw_dfw tests (vLLM 0.29, H100):

  • FULL_AND_PIECEWISE vs PIECEWISE. Across 11 tests, FULL_AND_PIECEWISE won 6 (2–17% faster generation) and PIECEWISE won 5. The PIECEWISE wins:
    • dapo-nanov3.5-30BA3B-4n8g-automodel: same speed, but token_mult_prob_error spiked on 6/20 steps instead of 1/20.
    • grpo-qwen3.5-35ba3b-2n8g-megatron-ep16tp2-fp8: FULL graphs left fewer Mamba cache blocks than max_num_seqs, so vLLM failed at startup.
    • grpo-math-qwen3-30ba3b-megatron-tp4-32k, dapo-qwen2.5-7b.v2 and grpo-minimax-m3: FULL_AND_PIECEWISE gave more token_mult_prob_error spikes or a higher median, for at most 3% speed (dapo-qwen2.5-7b.v2 was 3% slower).
  • Hybrid Mamba tests already on FULL_AND_PIECEWISE (Nano-v3, Super): PIECEWISE was 1.5–2× slower in generation and gave the same token_mult_prob_error.
  • Inductor vs backend: eager. On grpo-gspo-deepscaler-1.5b-8K, Inductor raised the median token_mult_prob_error from 1.013 to 1.040 and failed the gen_kl_error gate. With backend: eager, generation was still 48% faster and the gates passed.

The recipe changes are in a separate PR.

Update: cross-engine rewrite (third commit)

Review feedback: the first version covered only vLLM CUDA-graph mode. The skill is now engine-neutral. Its core is the process; engine-specific knobs live in reference files.

  • SKILL.md describes the process:
    1. Characterize the workload.
    2. Find where the time goes, using a regime table: refit-bound, decode-tail-bound, prefill-heavy, feeder-bound, tail-bound and startup-bound.
    3. Prove the effective config from each engine's own log lines.
    4. Pick a lever from a ranked list.
    5. A/B it.
    6. Gate it.
    7. Land it.
  • references/levers.md covers nine levers. For each one it gives the NeMo-RL key in every backend, graded evidence and traps. The levers are:
    • CUDA graphs;
    • scheduler token budget;
    • prefix/KV reuse and session affinity;
    • parallel layout;
    • admission cap and memory;
    • kernels and collectives;
    • frontend, tokenizer and harness;
    • speculative decoding;
    • startup.
  • references/engines.md covers each backend:
    • how the NeMo-RL config reaches the engine, including precedence and silently dropped keys (for example, SGLang's disable_radix_cache is declared but not forwarded);
    • the log lines that prove what ran;
    • which metrics reach NeMo-RL (SGLang, TRT-LLM and Megatron report none);
    • known landmines;
    • how to onboard a new backend.
  • references/measurement.md covers:
    • evidence grades A–D;
    • which metric supports which claim;
    • correctness gates for training and for eval/agentic runs;
    • the A/B protocol (at least 3 runs per arm for engine claims);
    • comparison scopes and the provenance to record;
    • how to decompose a gap before tuning.
  • The helper now:
    • parses effective settings from vLLM, SGLang, TRT-LLM, Megatron and Dynamo startup lines, keyed on each engine's anchor lines;
    • prints the step-phase breakdown (refit, logprobs, training) and the vLLM queue/KV stats;
    • accepts several runs per arm in --base / --treat, and warns when an arm has fewer than 3 runs.

The evidence for the cross-engine levers comes from an internal multi-turn SWE-agent rollout benchmark (Nemotron Nano V3.5; vLLM, SGLang, TRT-LLM, Megatron inference and Dynamo; 3–5 runs per profile) and from the H100 nightly A/B sweep. Every number carries its evidence grade.

Update: generalizing across engines (fourth commit)

  • levers.md now opens with "Applying a lever to any engine": a five-step method and a matrix. For every lever, the matrix gives:

    • the engine-independent mechanism;
    • the engine-neutral signal that the lever applies;
    • the concept terms that locate the knob in any engine;
    • the semantics that differ between engines;
    • the proof that the setting took effect.

    This applies to backends not listed here, and to upgraded engines whose knobs were renamed.

  • The helper maps each backend's startup lines onto engine-neutral settings: CUDA graphs, prefix reuse, token budget, chunked prefill, admission cap, memory fraction and KV capacity. It diagnoses against those, so the same rules fire for every backend. Settings a backend doesn't log are reported as unproven.

  • Validated on real H100 CI logs from SGLang (grpo-qwen2.5-math-1.5b-instruct-2n8g-fsdp2tp1-sglang), Megatron (grpo-llama3.2-1b-instruct-1n8g-megatron_generation), Dynamo (grpo-nanov3-30ba3b-3n8g-megatron-dynamo-swe1) and the vLLM A/B runs.

    • The SGLang test is refit-heavy: refit is 32% of the step against 24% for generation.
    • The Dynamo test is async, with generation almost fully overlapped.
    • In both cases the diagnosis correctly points away from engine knobs.

Report validation

The helper reports inclusive timing percentiles, discloses unequal step coverage before comparing common steps, and compares exposed (non-overlapped) generation when both arms are async. Timing percentiles describe per-step medians across runs, not pooled run tails. Engine config dumps cannot populate another engine's settings, and driver config echoes do not establish engine identity.

  • 13 CPU regression checks pass in tests/unit/tools/test_rollout_perf_report.py; six reproduce failures in the previous helper.
  • Command: uv run --no-project --with pytest pytest --confcutdir=tests/unit/tools -q tests/unit/tools/test_rollout_perf_report.py. The isolated invocation avoids the unrelated Ray/GPU unit-test conftest.
  • Ruff lint and format checks pass. Local Markdown targets and both skill discovery links resolve.
  • Replayed existing Nano DAPO baseline/repeat artifacts: 20 paired steps, generation median 324.4 → 101.1 seconds; single-run diagnosis also parsed the real vLLM 0.29 log. This validates report execution, not a new benchmark or a passing training gate.
  • Backend reference defaults were checked against the merged main: TRT-LLM rc28, MCore graph-count autotuning, prefix caching enabled and recompute KV mode. Historical rc21/rc24 observations remain explicitly versioned. The Nano DAPO pre-existing gate failure is documented.

Follow-ups

A read-only audit of the 185 tests that cw_dfw runs (nightly, release and performance) found 24 tests running vLLM eager. Switching the 15 that have CI timing to CUDA graphs is estimated to save about 630–870 GPU-hours per suite run. Each recipe change will come as its own PR with a same-window A/B, following this skill.

🤖 Generated with Claude Code

@joyang-nv joyang-nv added the CI:L0 Run doctests and unit tests label Oct 7, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

joyang-nv and others added 2 commits October 7, 2026 20:33
Add a contributor skill for diagnosing and optimizing rollout (generation)
performance in recipes and CI tests. It covers:
- reading the bottleneck from metrics.json and the vLLM log;
- the validated levers by regime (PIECEWISE CUDA graphs for hybrid Mamba
  models, replica count over TP for tail-bound decode, prefix reuse for
  prefill-heavy runs);
- a same-window A/B through tools/launch;
- logprob-consistency and accuracy gates;
- setting NUM_MINUTES from the measured wall time.

rollout_perf_report.py is a stdlib-only helper that prints the diagnosis for
one run or a paired-step comparison for two. The testing skill now points
nightly-test authors to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
- Graph mode depends on the vLLM version. PIECEWISE-only was a workaround for
  the vLLM 0.20 FULL-graph accuracy bug. On vLLM 0.29, decide by A/B, starting
  from the default FULL_AND_PIECEWISE.
- Record the exceptions found in the sweep:
  - dapo-nanov3.5: FULL_AND_PIECEWISE was no faster and had more
    token_mult_prob_error spikes.
  - qwen3.5-fp8: FULL graphs left fewer Mamba cache blocks than max_num_seqs,
    so vLLM failed at startup.
- Record that backend: eager fixes logprob regressions caused by
  Inductor-compiled kernels (gspo-deepscaler).
- A/B commands now cover the eager, FULL_AND_PIECEWISE and PIECEWISE arms.
- Recipes should delete enforce_eager: true rather than set it to false,
  because minimize-check rejects keys that repeat a default.
- Add the measured nightly results table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
@joyang-nv
joyang-nv force-pushed the joyang/rollout-perf-skill branch from 77e0375 to 1d603d6 Compare October 7, 2026 12:34
joyang-nv and others added 2 commits October 7, 2026 20:45
…he cw_dfw sweep

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
Rewrite the rollout-perf skill around an engine-neutral process:
characterize the workload, find where the time goes, prove the
effective engine configuration, pick a lever, A/B it, gate it, land it.

The engine-specific detail moves into reference files:
- references/levers.md: nine levers, each with its NeMo-RL key for vLLM,
  SGLang, TRT-LLM, Megatron inference and Dynamo, graded evidence and
  traps.
- references/engines.md: per backend, how the config reaches the engine,
  the log lines that prove what ran, which metrics reach NeMo-RL, and
  known landmines.
- references/measurement.md: evidence grades, metric scopes, correctness
  gates, the A/B protocol, comparison scopes, provenance and gap
  decomposition.

The helper now:
- parses effective settings from each backend's startup lines;
- reports the step-phase breakdown and vLLM queue/KV stats;
- compares several runs per arm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
@joyang-nv joyang-nv changed the title docs(skills): add rollout-perf contributor skill docs(skills): add cross-engine rollout-perf contributor skill Oct 8, 2026
Each lever is now an engine-independent mechanism. levers.md gives a
method and a matrix for applying any lever to a backend, including one
not covered here or an upgraded engine whose knobs were renamed. The
matrix covers:
- the mechanism;
- the engine-neutral signal that the lever applies;
- the concept terms that locate its knob;
- the semantics that differ between engines;
- the proof that the setting took effect.

The helper now maps each backend's startup lines onto engine-neutral
settings: CUDA graphs, prefix reuse, token budget, chunked prefill,
admission cap, memory fraction and KV capacity. It diagnoses against
those settings, so the same rules apply to vLLM, SGLang, TRT-LLM,
Megatron inference and Dynamo. Settings that a backend does not log
are reported as unproven.

Checked against real H100 CI logs:
- SGLang grpo-qwen2.5-math-1.5b-instruct-2n8g-fsdp2tp1-sglang;
- Megatron grpo-llama3.2-1b-instruct-1n8g-megatron_generation (adds
  MCore's CUDA-graph capture lines);
- Dynamo grpo-nanov3-30ba3b-3n8g-megatron-dynamo-swe1;
- the vLLM A/B runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
fujial-code pushed a commit that referenced this pull request Oct 15, 2026
…ecipes

dapo-qwen2.5-7b.v2 (16n8g) and grpo-minimax-m3-32n8g-automodel-cp8ep128-
noncolocated ran vLLM with enforce_eager: true. Same-window A/Bs on cw_dfw
H100, with eager, PIECEWISE and FULL_AND_PIECEWISE arms sharing one
container and one code snapshot:

- dapo-qwen2.5-7b.v2: generation per step 165 -> 74 s (-55%), wall
  204 -> 156 min. token_mult_prob_error spikes went 4/20 -> 5/20; the CI
  eager run spiked on 7/20. FULL_AND_PIECEWISE was slower (161 min) and
  spiked on 8/20 steps.
- minimax-m3: generation per step 521 -> 266 s (-49%), wall 82 -> 58 min.
  token_mult_prob_error spikes went 0/5 -> 2/5, within eager noise (the CI
  eager run spiked on 1/5). FULL_AND_PIECEWISE was 3% faster in wall time
  (7% in generation) but raised the median token_mult_prob_error.

check_metrics passes in every arm and gen_kl_error is unchanged. minimax
NUM_MINUTES drops from 240 to 120, and checkpoint_must_save_by drops to
01:45. The MiniMax-M3 guide now describes the graph setting and notes that
its reference curves were produced in eager mode.

The GB200 child dapo-qwen2.5-7b-16n4g-fsdp2cp2.v2 now pins
enforce_eager: true, so its behaviour is unchanged until it gets its own
A/B.

The recipe comments cite the rollout-perf skill (#4556).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
fujial-code pushed a commit that referenced this pull request Oct 15, 2026
…ecipes

dapo-qwen2.5-7b.v2 (16n8g) and grpo-minimax-m3-32n8g-automodel-cp8ep128-
noncolocated ran vLLM with enforce_eager: true. Same-window A/Bs on cw_dfw
H100, with eager, PIECEWISE and FULL_AND_PIECEWISE arms sharing one
container and one code snapshot:

- dapo-qwen2.5-7b.v2: generation per step 165 -> 74 s (-55%), wall
  204 -> 156 min. token_mult_prob_error spikes went 4/20 -> 5/20; the CI
  eager run spiked on 7/20. FULL_AND_PIECEWISE was slower (161 min) and
  spiked on 8/20 steps.
- minimax-m3: generation per step 521 -> 266 s (-49%), wall 82 -> 58 min.
  token_mult_prob_error spikes went 0/5 -> 2/5, within eager noise (the CI
  eager run spiked on 1/5). FULL_AND_PIECEWISE was 3% faster in wall time
  (7% in generation) but raised the median token_mult_prob_error.

check_metrics passes in every arm and gen_kl_error is unchanged. minimax
NUM_MINUTES drops from 240 to 120, and checkpoint_must_save_by drops to
01:45. The MiniMax-M3 guide now describes the graph setting and notes that
its reference curves were produced in eager mode.

The GB200 child dapo-qwen2.5-7b-16n4g-automodel-cp2.v2 now pins
enforce_eager: true, so its behaviour is unchanged until it gets its own
A/B.

The recipe comments cite the rollout-perf skill (#4556).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
Signed-off-by: fujial <[email protected]>
@fujial-code
fujial-code requested a review from yuki-97 November 5, 2026 05:59
@terrykong terrykong added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L0 Run doctests and unit tests labels Nov 5, 2026

@jinglinglingling jinglinglingling left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. The engine references match the code; two issues need fixing before merge.

Scope: the full diff at head 23b8499.

Checked:

  • Metric names, async GRPO timing keys, the SGLang whitelist, the vLLM and TRT-LLM config paths, and the token_mult_prob_error definition all match the code.

Remaining comments are on:

  • Fix the max_new_tokens cap check for multi-turn and NeMo Gym runs.
  • Update the Nano V3.5 evidence, which #4569 withdrew.

Non-blocking

  • Open a follow-up issue for the silently dropped SGLang keys.

The main CI test jobs have not run on this head. Validation here covered source inspection, the 13 unit tests run locally, and a repro with a hand-built metrics.json. The helper was not run on real CI logs, and no GPU training was run.

Generated by Claude

Comment on lines +366 to +372
cap = max_new_tokens or (
int(config["max_new_tokens"]) if "max_new_tokens" in config else None
)
hits = None
if max_gen and cap:
hits = sum(v >= cap for v in max_gen.values()) / len(max_gen)
print(f"steps whose longest sample hit max_new_tokens={cap}: {hits:.0%}")

@jinglinglingling jinglinglingling Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bug: the max_new_tokens cap check misreads multi-turn runs and never runs on NeMo Gym runs.

train/max_gen_tokens_per_sample sums tokens over all turns (rollouts.py L1271, L1633), but max_new_tokens caps one turn. So a sample with 4 turns × 600 tokens "hits" a 1024 cap and "Decode-tail-bound" fires. Gym runs log turns_per_sample/mean and max_gen_tokens_per_turn/max instead (rollouts.py L3346–3369), so this check and the multi-turn branch of prefill_heavy (L431–433) never run there.

Suggest fix: compare the cap with the per-turn max, read turns from either key, and add tests for both cases.

turns = series(metrics, TURNS) or series(metrics, "train/turns_per_sample/mean")
...
per_turn_max = series(metrics, "train/max_gen_tokens_per_turn/max")
multi_turn = bool(turns) and med(turns.values()) > 1
cap_series = per_turn_max or ({} if multi_turn else max_gen)
if cap_series and cap:
    hits = sum(v >= cap for v in cap_series.values()) / len(cap_series)

Comment on lines +80 to +84
H100 nightly A/Bs, eager → graphs (grade C). The PR reports unchanged
logprob metrics for these comparisons, with one explicit exception to gate
passing: the Nano V3.5 DAPO test failed its pre-existing step-20
`token_mult_prob_error` gate in both arms. PR #4459 addresses that gate; the
speedup alone does not establish that the test passes.

@jinglinglingling jinglinglingling Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Nano V3.5 DAPO evidence here is out of date.

#4569 withdrew Nano's graph change after a rerun found much larger token_mult_prob_error spikes under PIECEWISE (tracked in #4777, still open). On main the recipe, now dapo-nanov3.5-30BA3B-4n8g-automodel-ep8.yaml, still runs eager. This paragraph and the −69% row (L94) still present it as a clean win.

Suggest fix: drop the Nano row, change "9 H100 nightly tests" to 8 in SKILL.md L142, and reword:

Suggested change
H100 nightly A/Bs, eager → graphs (grade C). The PR reports unchanged
logprob metrics for these comparisons, with one explicit exception to gate
passing: the Nano V3.5 DAPO test failed its pre-existing step-20
`token_mult_prob_error` gate in both arms. PR #4459 addresses that gate; the
speedup alone does not establish that the test passes.
H100 nightly A/Bs, eager → graphs (grade C). Every shipped arm passed the
test's own `check_metrics` (#4569). Exception: on the Nano V3.5 DAPO test, a
later rerun found much larger intermediate `token_mult_prob_error` spikes
under PIECEWISE, so its graph change was withdrawn and the test still runs
eager (#4777).

Comment on lines +86 to +89
Declared but **not forwarded**: `disable_radix_cache`, `enable_nccl_nvls`,
`disable_custom_all_reduce`, `enable_dp_attention`, `enable_mixed_chunk`,
`num_continuous_decode_steps`, `enable_torch_compile` and `sglang_kwargs`.
Setting them has no effect until the whitelist is extended.

@jinglinglingling jinglinglingling Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking: existing code silently drops these keys; this PR did not introduce that.

They are declared in sglang/config.py but missing from the ServerArgs whitelist in sglang_worker.py (L525–546).

Suggest fix: open a follow-up issue to forward them or reject them at config validation, and link it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants