Skip to content

feat(rollout): carry a rollout's stored tensors as store slices and release them after its train - #360

Merged
Rockdu merged 5 commits into
mainfrom
output-store/02-rollout-refs
Nov 11, 2026
Merged

Rockdu merged 5 commits into
mainfrom
output-store/02-rollout-refs

Conversation

@zhihengy

@zhihengy zhihengy commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Second of three, on #359. With the switch, the rollout side now asks the engines for the output store, keeps what comes back as slices, and deletes each rollout's objects after its train; #361 reads the slices on the trainer.

Summary

A response from an engine started with the store (sgl-project/sglang#48959) carries output_store_ref and, where the latents, debug and cond tensors were, {"__store__": "<field>"} markers; a tensor the engine slices per sample is one field per sample, so a trainer reads only its samples. The parser turns every marker into a StoreSlice of the response's ref, so a Sample keeps its shape: dit_trajectory.latents, the CondKwargs leaves and the debug tensors are slices, everything else (timesteps, sigmas, step indices, log probs, guidance, generated_output) is the tensor it always was. The conversion hubs index latents the way they did, a StoreSlice indexes like a tensor along its leading axis, so a train pair holds the step row it needs, not the data.

Changes

  • StoreSlice (miles/utils/output_store.py): the ref, the stored field, the fixed leading rows, and a pending row selection; [int], [-1], [LongTensor] then [int] resolve as on a tensor, shape comes from the ref's FieldSpec.
  • apply_rollout_image_response: a body with output_store_ref sets Sample.rollout_store_ref and deserializes markers into slices; the two helpers that only looked for __tensor__ now take either.
  • build_rollout_sampling_params sends rollout_return_outputs_via_store with the switch (training requests only).
  • flow_grpo: .detach().cpu() only on tensors (a slice passes through); nft: the x0 slice is returned as is, the loss casts x0 to float32 on consumption anyway.
  • Lifecycle, as in miles: RolloutManager records every ref a rollout's samples hold (store_refs_of) plus those of groups that will never train (record_dropped_samples), under the rollout id, before the global-batch trim, so a trimmed sample's object is deleted with its siblings' and never early. release(rollout_id) deletes them; both drivers call it after the rollout's train (the sync driver after every trainer group of [DMD2 2/10] feat(ray): train several colocated trainer groups in the sync driver #329 has trained it). dispose sweeps whatever the run left under its key prefix (a response the client never received, a crash). A release whose delete fails (master unreachable, client evicted) logs and keeps those refs in _undeleted_store_refs, retried with the next release and swept at dispose; a removed key reads as not found, so the retry is safe. The driver calls release between the train step and save, so a cleanup failure must not raise there.
  • The groups a dynamic-filter rollout generates but does not train on are all recorded: the ones the filter drops, the ones that pass after the target is reached (a drop refetches a whole over_sampling_batch_size batch), and the ones still generating when the loop ends, which the rollout now awaits before it returns instead of leaving them running.

Tests

  • test_rollout_store_refs.py::test_release_keeps_refs_a_failed_delete_left_behind: a failing delete_many keeps the refs, leaves the still-training rollout's refs untouched, and the next release deletes both.

tests/fast/utils/test_output_store_slice.py (indexing, ref collection), test_diffusion_rollout_response.py (markers to slices, inline fields untouched), test_traj_window_convert.py (Flow-GRPO pairs hold (row, step) and (row, step + 1), NFT x0 is the final row), test_rollout_negative_prompt.py (the request flag), tests/fast/rollout/test_rollout_store_refs.py (the real generate_rollout_async loop with a scripted state: filtered, surplus and in-flight groups all recorded, nothing left in flight); the three fast suites on the full stack: 527 passed, 3 skipped.

@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

Base automatically changed from output-store/01-mooncake to main November 11, 2026 06:02
@Rockdu
Rockdu force-pushed the output-store/02-rollout-refs branch from c85c2cd to 457d43d Compare November 11, 2026 06:02
@Rockdu
Rockdu merged commit 63ed7aa into main Nov 11, 2026
7 checks passed
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