Skip to content

Split data-loader wait from preprocessing in schedule metrics#567

Merged
jlamypoirier merged 2 commits into
mainfrom
jlp_fix_data_wait_metric
Jul 15, 2026
Merged

Split data-loader wait from preprocessing in schedule metrics#567
jlamypoirier merged 2 commits into
mainfrom
jlp_fix_data_wait_metric

Conversation

@jlamypoirier

Copy link
Copy Markdown
Collaborator

Claude Opus 4.8 authored this PR.

Problem

training.data_wait_time_ms (added in #564) reads near-zero (~19 ms) in the RL/streaming trainer while the DeepSpeed reference reports the true stream-block time (~4.2 s) — off by ~200×.

#564 timed next(context.data_iterator) inside _get_forward_input, but context.data_iterator is the _preprocess_data generator. So the metric clocked the raw loader block plus CPU preprocessing (share_batch_data / preprocess_batch, i.e. GPU transfer and batch prep). And in the RL path the loader is drained into a buffer before the schedule runs, so the generator's raw next() returns instantly and only preprocessing (~19 ms) is left to measure.

Fix

Move all timing into _preprocess_data, splitting it into two metrics:

  • data_wait_time_ms — times only the raw next(data_iterator) pulls (time blocked on the data loader = input starvation).
  • data_preprocessing_time_ms (new) — the generator's own active runtime (share_batch_data + preprocess_batch), with the clock paused across each yield so schedule compute between micro-batches is excluded.

Both are logged to the terminal (| data wait: … | data preprocessing: …). All timing is gated on context.metrics is not None, so there is no overhead off logging steps.

_get_forward_input no longer times anything. The data_batch_warn_time_ms warning and its config field are removed — the wait is now logged explicitly every step, so a threshold warning is redundant.

Notes

  • No behavior change to training; metrics-only.
  • No existing tests reference these metrics or the removed field. Verified: files compile, ScheduleConfig validates without the field, and the training log format's keys are all declared (no format-time KeyError).

jlamypoirier and others added 2 commits July 15, 2026 16:56
#564 timed `next(context.data_iterator)` in `_get_forward_input`, but that
iterator is the `_preprocess_data` generator, so the metric conflated the real
data-loader block with CPU preprocessing (share_batch_data / preprocess_batch).
In the RL path this reads near zero because the loader is drained into a buffer
before the schedule runs.

Move the timing into `_preprocess_data`: time only the raw `next(data_iterator)`
pulls as `data_wait_time_ms` (input starvation), and the generator's own active
runtime -- paused across each yield to exclude schedule compute between
micro-batches -- as a new `data_preprocessing_time_ms`. Both are logged to the
terminal. Drop the now-redundant `data_batch_warn_time_ms` warning and its
config field, since the wait is logged explicitly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Removing the slow-load warning left the module `logger` (and `import logging`)
with no consumer -- drop both. Guard `wait_start` with `if measure_time:` to
match its sibling `preprocess_start` instead of a ternary fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jlamypoirier
jlamypoirier merged commit c7753cd into main Jul 15, 2026
3 of 4 checks passed
@jlamypoirier
jlamypoirier deleted the jlp_fix_data_wait_metric branch July 15, 2026 21:26
jlamypoirier added a commit that referenced this pull request Jul 16, 2026
Brings main (#562/#564/#567) into the branch. The one semantic conflict was
policy-gradient metrics: main #562 added reward/staleness data metrics
(`_register_data_metrics`) to the standalone GRPO/GSPO `_forward_backward`,
while this branch reworked registration to compute policy metrics in the fused
kernel and register them through `register_combinable_extras`. Kept the
fused-metrics design and grafted the data metrics onto every registration path:

- `register_combinable_extras` gains `split_index` (base + GRPO/GSPO overrides
  + 3 call sites) so the compiled and monolithic paths can register data metrics.
- GRPO triton-standalone and both `register_combinable_extras` overrides now
  call `_register_data_metrics`; GSPO standalone already did (auto-merged).
- `_policy_metric_definitions` folds in `_data_metric_definitions()`.

`test_lm_head` now supplies reward/model_version/documents_seen and asserts the
data-metric family via a `reference_data_metrics` helper.

CPU validation: test_lm_head + test_lm_losses = 722 passed, 75 skipped
(triton/GPU-only skipped locally).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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