Repository navigation
feat(rollout): carry a rollout's stored tensors as store slices and release them after its train - #360
Merged
Conversation
zhihengy
force-pushed
the
output-store/02-rollout-refs
branch
from
November 6, 2026 22:12
85e7e68 to
ed8e878
Compare
This was referenced Nov 6, 2026
zhihengy
force-pushed
the
output-store/02-rollout-refs
branch
2 times, most recently
from
November 10, 2026 13:35
094efeb to
49da564
Compare
3 of 4 tasks
…elease them after its train
…ollout for release
Rockdu
force-pushed
the
output-store/02-rollout-refs
branch
from
November 11, 2026 06:02
c85c2cd to
457d43d
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.
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_refand, 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 aStoreSliceof the response's ref, so aSamplekeeps its shape:dit_trajectory.latents, theCondKwargsleaves 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, aStoreSliceindexes 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,shapecomes from the ref'sFieldSpec.apply_rollout_image_response: a body withoutput_store_refsetsSample.rollout_store_refand deserializes markers into slices; the two helpers that only looked for__tensor__now take either.build_rollout_sampling_paramssendsrollout_return_outputs_via_storewith 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 castsx0to float32 on consumption anyway.RolloutManagerrecords 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).disposesweeps whatever the run left under its key prefix (a response the client never received, a crash). Areleasewhose delete fails (master unreachable, client evicted) logs and keeps those refs in_undeleted_store_refs, retried with the next release and swept atdispose; a removed key reads as not found, so the retry is safe. The driver callsreleasebetween the train step andsave, so a cleanup failure must not raise there.over_sampling_batch_sizebatch), 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 failingdelete_manykeeps 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 realgenerate_rollout_asyncloop 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.