Skip to content

fix(sc): include generation in step metric windows - #5155

Merged
terrykong merged 1 commit into
mainfrom
yukih/fix-sc-generation-metric-windows
Nov 10, 2026
Merged

terrykong merged 1 commit into
mainfrom
yukih/fix-sc-generation-metric-windows

Conversation

@yuki-97

@yuki-97 yuki-97 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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-api8 nightly with this staged fix on #5074. All checks pass, and token/request metrics are populated. The generation_tokens > 0 check 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
image

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.

@yuki-97 yuki-97 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 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.

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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)

@yuki-97
yuki-97 marked this pull request as ready for review November 10, 2026 16:35
@yuki-97

yuki-97 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9990d4b

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

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 terrykong left a comment

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.

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

@terrykong
terrykong merged commit 65f44f1 into main Nov 10, 2026
99 of 101 checks passed
@terrykong
terrykong deleted the yukih/fix-sc-generation-metric-windows branch November 10, 2026 22:18
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.

3 participants