Repository navigation
fix(sc): include generation in step metric windows - #5155
Conversation
Signed-off-by: Yuki Huang <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
Self-review via /review-pr-team: 4 agents covering five specialist roles, an independent devil's-advocate pass, and a comment-editor pass.
Verdict — no findings above the confidence bar. LGTM, no action needed.
Verified clean
- The initial baseline is captured before either generation or training pump starts. Startup ordering
- Each window's end counters become the next window's baseline. Window boundaries
- A failed read clears the old baseline; the next successful read starts a new window without reporting across the failed interval. Recovery
- Other training loops keep their default behavior, and backends without these metrics inherit the updated no-op interface. Interface contract
Validation — Ruff checks, import sorting, formatting, and syntax inspection pass. Unit and GPU tests were not run locally; the reviewed head has no L0/GPU CI execution record.
Generated by Codex (#4999 version)
|
/ok to test 9990d4b |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
LGTM — no qualifying findings.
Reviewed all seven changed files across three review topics and traced the affected callers. The startup snapshot precedes pump creation. The continuous metric windows retain successful end snapshots and discard stale baselines after failed reads, while preserving the default behavior for other training loops.
Validation was source-only. Tests and linters were not run, and the reported nightly/CI results were not independently verified. Upstream Gym restore internals were unavailable in the mounted tree.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
terrykong
left a comment
There was a problem hiding this comment.
LGTM — no action needed.
The fix is right. The old snapshot was taken at the step's first training dispatch (base). So anything generated before that first select() returned was missed. In on-policy runs (min_groups_for_streaming_train equal to the batch size, plus lookahead 0 or a colocated engine), that was the whole step, so vllm/* logged ~0. Other SC setups undercounted: with lookahead ≥ 1 the window missed what was generated while training waited for its batch, and with streaming chunks it missed the first chunk. Now one baseline is taken before the pumps start (_run_pumps), and each step-end read becomes the next step's baseline (get_step_metrics(keep_snapshot=True)). Windows now run back to back, and every token is counted once.
Also confirmed:
- Every backend SC can build (vLLM, SGLang, Megatron, Dynamo) gets the new keyword from the interface default. Only vLLM overrides it. The v1 loops pass no argument and behave as before.
- Nothing starts generation before the new baseline:
restore()only reloads saved state. - Every step, skipped steps included, reaches the step-end read, so no step's window is lost.
- A failed read clears the baseline, and the next read only starts a new one (L885-L887). So no reported number spans the failed gap. The cost is one step with no
vllm/*metrics, which the new test checks. - The 9 related unit tests pass locally on CPU. Reverting either source file, or any single line of the fix, makes at least one of them fail.
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-5155-metric-window.html
Generated by Claude Code
What does this PR do ?
Fix zero vLLM step metrics when SC waits for a complete rollout batch before training. Generation scheduling is unchanged.
What changed
1. Cover generation in the metric window. Take the initial snapshot before starting the pumps and retain each end snapshot as the next baseline. Other training loops keep their existing behavior.
2. Recover after metrics read failures. Re-establish a baseline without emitting deltas across the failed interval.
Validation
Validated the five-step
grpo-qwen3-0.6b-1n8g-megatron-vllm-tp2-single-controller-gym-api8nightly with this staged fix on #5074. All checks pass, and token/request metrics are populated. Thegeneration_tokens > 0check added in #5074 fails without this fix and passes when validated with this fix and multiple vLLM frontends.green: before this PR

pink: after this PR
Ruff checks, import sorting, formatting, and pyrefly pass. Added regression coverage for startup ordering, consecutive windows, and read-failure recovery; unit tests were not run locally.