Skip to content

feat(fsdp): read a shard's store slices back from the output store before training on it - #361

Merged
Rockdu merged 1 commit into
mainfrom
output-store/03-trainer-read
Nov 11, 2026
Merged

Rockdu merged 1 commit into
mainfrom
output-store/03-trainer-read

Conversation

@zhihengy

@zhihengy zhihengy commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

ci-sglang-pr: #48959

Third of three, on #360. With this the switch works end to end: the engines store, the rollout side carries slices, the trainer reads.

Summary

A train pair of a store run holds StoreSlices where the inline path holds tensors: latent, next_latent or x0, the debug step tensors, and the CondKwargs leaves of its denoising_env. Each train worker, right after it fetches its shard, reads every stored object the shard's slices name once (OutputStore.read_many with the TensorStash) and replaces each slice with its rows, in place: the dicts, lists and dataclasses that the pairs of one sample share are replaced once. _train_core and the losses then see the tensors they always saw, in the producer's dtype.

Changes

  • materialize_store_slices (miles/utils/output_store.py): collect the slices under the pairs (dicts, lists, dataclasses), one read per object with the fields it needs, then the rows of each slice (rows, then a pending selection).
  • FSDPTrainRayActor.init connects a reader with the switch; train materializes the shard before _train_core when args.use_output_store is set, so nothing changes without it.

Tests

  • tests/fast/utils/test_output_store_materialize.py: the same samples once with tensors and once with slices of one stored object, through flow_grpo.expand_samples_to_train_pairs; after materialization every pair field is torch.equal to the inline pair's (latents in bf16, debug step, cond leaves, shared pooled), the object was read once with exactly the fields the shard needs, and a shard without slices reads nothing.
  • tests/fast/backends, tests/fast/rollout, tests/fast/utils: 523 passed, 3 skipped (the two fake actors of test_ema_optimizer and test_async_training now carry the switch in their args).

@Rockdu Rockdu 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

@Rockdu
Rockdu force-pushed the output-store/03-trainer-read branch from 80be9ae to 03d8658 Compare November 11, 2026 06:02
Base automatically changed from output-store/02-rollout-refs to main November 11, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci-e2e Run e2e metric-regression tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants