RL diagnostics: documents-seen clock, model-version broadcast, reward + per-token model_version, data-wait#553
Open
jlamypoirier wants to merge 4 commits into
Open
RL diagnostics: documents-seen clock, model-version broadcast, reward + per-token model_version, data-wait#553jlamypoirier wants to merge 4 commits into
jlamypoirier wants to merge 4 commits into
Conversation
jlamypoirier
added a commit
that referenced
this pull request
Jul 8, 2026
Coarse review fixes for PR #553: - Extract the shared GRPO/GSPO metric LossDef list into LanguageModelPolicyGradientLoss._policy_metric_definitions(*extra); GSPO passes its num_segments def. Removes ~13 duplicated lines, order-preserving. - Add a GSPO-metrics subtest to _run_lm_loss_distributed so compute_gspo_metrics' vocab-parallel group all-reduce path is exercised. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reintroduce the per-step document count and cumulative documents-seen metrics on the static-schedule path, independent of `docs_per_step`. `ScheduleRunner` exposes the whole-step DP-summed document count (`num_documents_in_batch`, the loss-normalization divisor) as `_num_documents_in_batch`, set once per step in `_preprocess_data`; it is `None` when the data carries no document counts (non-RL runs). The trainer accumulates it into `_documents_seen` every step (persisted in checkpoint metadata) and logs `num_documents` + `documents_seen` when available. `Wandb` lazily declares `training/documents_seen` as an alternative `step_metric` for `training/*` on the first log that carries it, so it can be used as a cross-run x-axis without affecting non-RL runs. The global `wandb.log(step=...)` step is unchanged, so both axes remain available. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
The schedule runner already timed how long it blocked on the data loader but only warned past a threshold and discarded the value. Accumulate it into the step metrics as `data_wait_time_ms` (0 when never starved), so input starvation is visible in the training logs and W&B. 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>
2a41809 to
eadbdef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Opus 4.8, on behalf of @jlamypoirier.
Summary
Consolidates the remaining RL diagnostics on the Fast-LLM trainer side so the trainer is a single,
reliable source of truth for GSPO/GRPO runs — logged from the exact tensors each step trained on.
The config unification + GSPO/GRPO policy metrics landed separately in #555; this PR is rebased on
top of it and adds the document clock, the version broadcast, the reward / per-token-version data, and
the data-wait timer. Paired PipelineRL changes (raw-reward forwarding + document-count model version)
live in a separate PR against PipelineRL's
fast-llmbranch. Backward-compatible with the current producer.Changes
documents_seen/num_documents. Reimplemented onmain, independent ofdocs_per_step, fromthe per-step DP-summed document count (the loss-normalization divisor). Persisted in checkpoint
metadata. Offered as an alternative W&B x-axis via a lazily-declared
define_metric(RL runs only;the global step is unchanged).
weights_readynow carriesdocument_count(=documents_seen)alongside the existing
step, so consumers can measure staleness in documents (DeepSpeed-aligned).Keeping
stepmakes this backward-compatible.rewardand per-tokenmodel_version. Two optional per-token fields threaded through the RLstreaming schema and data pipeline (reusing
TokenDataDocument/TokenDataBatch); both optional andguarded on presence.
rewardis the raw reward (distinct from the group-relativeadvantage). Theshared policy-gradient loss logs mean/max/min of each when present (folded into the
PolicyMetricsLevelmetric set from Unify policy-loss metrics config and add GSPO metrics #555). Staleness is
documents_seen − model_version, derivable from the logged stats.data_wait_time_ms. The schedule runner already timed data-loader waits but discarded the value;it is now logged as an input-starvation metric.
Tests
(
test_policy_data_metrics), and the streaming schema round-trips the new fields (test_streaming_dataset).main); CI validates the full suite.