Skip to content

RL diagnostics: documents_seen, weights_ready document-count version, reward/model_version staleness metrics#557

Closed
jlamypoirier wants to merge 2 commits into
jlp_documents_seenfrom
jlp_rl_model_version
Closed

RL diagnostics: documents_seen, weights_ready document-count version, reward/model_version staleness metrics#557
jlamypoirier wants to merge 2 commits into
jlp_documents_seenfrom
jlp_rl_model_version

Conversation

@jlamypoirier

@jlamypoirier jlamypoirier commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Claude Sonnet 5, on behalf of @jlamypoirier.

Summary

Extracted from #553. Stacked on #559 (documents_seen / num_documents tracking), which this
PR depends on: the model version broadcast below is documents_seen, and staleness is
computed as documents_seen - model_version. Base will retarget to main once #559 merges.

  • Document-count model version. weights_ready now carries document_count
    (= documents_seen) alongside the existing step, so consumers can measure staleness in
    documents (DeepSpeed-aligned). Keeping step makes this backward-compatible.
    TrainerCallback.run_begin / step_end gain documents_seen alongside step.
  • reward and per-token model_version. Two optional per-token fields threaded through the
    RL streaming schema and data pipeline (reusing TokenDataDocument/TokenDataBatch); both
    optional and guarded on presence. reward is the raw reward (distinct from the group-relative
    advantage). The shared policy-gradient loss logs mean/max/min of each when present (GRPO and
    GSPO, via the shared _data_metric_definitions/_register_data_metrics). Staleness is
    documents_seen − model_version, derivable from the logged version stats.

Paired PipelineRL changes (raw-reward forwarding + document-count model version) are in a
separate PR against PipelineRL's fast-llm branch.

Tests

  • tests/data/test_streaming.py (schema round-trip for the new fields) and
    tests/layers/test_lm_losses.py (reward/model_version metric registration, single-process and
    distributed) pass on CPU: 584 passed / 21 skipped (lm_losses), 87 passed (streaming + lm_head).

Caveats

  • The GPU end-to-end integration test (tests/models/test_streaming.py::test_model_streaming,
    which exercises documents_seen + the weights_ready document_count path) was not run
    here (no GPU) — worth running in CI before merge.
  • The per-token model_version consumer and its metric are in place, but the producer
    (tagging tokens with the active version inside vLLM's output path) is a separate,
    cluster-validated follow-up; until it lands, the model_version/staleness metrics simply don't
    populate.

jlamypoirier and others added 2 commits July 8, 2026 16:30
The `weights_ready` event now carries `document_count` (= documents_seen)
alongside the existing `step` (= completed step). Consumers stamp
`document_count` onto rollouts so staleness is measured in documents,
aligning with DeepSpeed's document clock, while `step` remains available
for logging. Keeping `step` makes the change backward-compatible.

Threads `documents_seen` through the `TrainerCallback.run_begin` /
`step_end` hooks (a training-progress counter alongside `step`).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add two optional per-token fields to the RL streaming schema and thread
them through the data pipeline alongside `advantages` /
`old_log_probabilities` (reusing `TokenDataDocument`/`TokenDataBatch`):
- `reward`: the raw (un-normalized) reward, a per-rollout scalar broadcast
  per-token — distinct from the group-relative `advantage`.
- `model_version`: the model version each token was generated under
  (documents-seen units), one per token, for staleness diagnostics.

Both are optional (absent when the producer does not send them), so the
batch/target plumbing guards on presence.

The shared policy-gradient loss logs mean/max/min of each supplied field
when `metrics != none` (GRPO and GSPO), registered only when the data is
present. Staleness is `documents_seen - model_version`, derivable from the
logged version stats and `documents_seen`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jlamypoirier

Copy link
Copy Markdown
Collaborator Author

Claude Sonnet 5, on behalf of @jlamypoirier: closing this — it bundled two commits
(weights_ready document-count broadcast + reward/per-token model_version) that turn out to have
no code dependency on each other. Split into two fully independent PRs instead:

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.

1 participant