Repository navigation
Conversation
zhihengy
added this pull request to stack #332
October 19, 2026 20:42
zhihengy
marked this pull request as ready for review
October 19, 2026 22:13
This branch has not been deployed
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 the DMD2 stacked series, on top of #329. A trainer group can now hand a per-rank result to the groups that train after it on the same rollout. For DMD2, the critic group uses this to pass the teacher's and the critic's predictions to the actor.
What
--custom-train-output-function-path:fn(ctx, train_pairs) -> Any, run without grad after a rollout's train steps.FSDPTrainRayActor.trainreturns its value (Nonewithout the hook).train_diffusion.pykeeps each group's per-rank train refs for the current rollout and passes the earlier groups' refs to the next group.RayTrainGroup.async_train(..., external_data): rank i receives rank i's ref from each earlier group, the pairing upstream miles uses for its critic values. Both groups share the world size and read the same rollout shard, so the paired ranks hold the same train pairs.ctx.external_data[<role>]. Without earlier groups this is{}.--teacher-loadalso counts the new hook as a consumer ofctx.teacher_models.Why
Upstream miles hands the critic's values to the actor the same way:
critic.trainreturns one output per worker, andactor.train(..., external_data=values)gives worker i the output of critic worker i. Here the hand-off goes through Ray object refs, so the payload never passes through the driver and is freed once the rollout's refs go out of scope. The producer side is a hook, like the existing prepare/loss hooks, so the trainer stays role-agnostic.Tests
tests/fast/rollout/test_placement_group.py: each rank receives the same-rank output of every earlier group, and an empty dict without them.tests/fast/test_train_diffusion.py: the second group receives the first group's refs from the same rollout, and the first group receives nothing.tests/fast/utils/test_reference_arguments.py: the train-output hook alone counts as a consumer of--teacher-load.tests/fast/rollout/test_async_training.py,tests/fast/backends/fsdp_utils/test_ema_optimizer.py: updated for the newtrainsignature.Checklist
pre-commithooks (black, isort, ruff at the pinned versions) pass on the changed filespytest tests/fastis green (517 passed, 6 skipped)python3 train_diffusion.py --helpstill parses (the new flag is listed)--custom-train-output-function-pathincli-reference.mdandcustomization.md)Stack
DMD2: distill a flow-matching teacher into a few-step student with distribution matching. Merge in order:
external_data--loss-type dmd2on the actor