Repository navigation
Conversation
a6e8635 to
36222f1
Compare
9ea9eb3 to
b9e206a
Compare
8732fa8 to
676119c
Compare
676119c to
0992d73
Compare
A group that trains and then scores in the same wake would wake twice, and waking a frozen model twice replaces its pinned host copies with its GPU parameters, so the next sleep would leave the teacher on the GPU. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
`train(..., optim_steps=(lo, hi))` runs windows lo..hi-1 of the rollout's micro-batch schedule with the micro-batch ids of the full run, so a range draws the same noise as the whole rollout would; a range outside the schedule, or one under --diffusion-recompute-old-log-prob, is rejected. The EMA steps once per rollout, by the call whose range ends at the last step. `RayTrainGroup.async_train` passes the range through. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
`FSDPTrainRayActor.compute(rollout_id, rollout_data_ref, external_data, hooks_key)` runs the loss hub's `(--loss-type, hooks_key)` hooks without grad: their train-input selection, one forward per micro-batch through the trunk (`_forward_train_pair_batch` takes the hooks to run instead of the group's), numbered past the rollout's training micro-batches so no training forward shares a draw, then their train-output hook, boxed as train's output is. The models are resharded after; the optimizer, scheduler, EMA and step count stay. `RayTrainGroup.async_compute` dispatches it per rank like `async_train`. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…ate scoring forward
`reuse-critic-step` (default, no behavior change): the critic's last training step draws in the scoring range, asks
for the teacher and keeps both x0 as the score. `original`: that step is plain SFT and keeps nothing; the new
`("dmd2", "critic-scoring")` hooks, run forward-only by `FSDPTrainRayActor.compute`, score the last step's pairs
(`last_step_pairs`) at the scoring draw with the critic before its last update, as tianweiy/DMD2 does. Both modes share
`prepare_scoring_batch` and `keep_scores`, so they score the same function of the same draw.
Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…actor within a rollout `--loss-type dmd2` runs through its own entrypoint, as async NFT does: under `reuse-critic-step` the critic trains and the actor trains on its scores; under `original` the critic trains steps 0..K-2, scores forward-only, the actor trains on the scores and the critic trains step K-1. A group saves after its last train of the rollout and, under --offload-train, sleeps before another group wakes. `train_diffusion.py` sends dmd2 here; the H3 recipe passes `train_script="train_dmd2.py"` (its reference evals keep train_diffusion.py). Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
0992d73 to
a48de7f
Compare
|
Thanks for the PR! One thought on Since the critic's last step doesn't depend on the actor, the order could then be critic → actor like reuse, and |
…in call under --dmd2-critic-scoring original The critic's last step does not depend on the actor's update, and the actor reads only the scores, so the scoring only has to precede that step's update, not the actor's train. A group's hooks can now declare a forward-only pass, `LossHooks.forward_only`: before the optimizer steps it names, the trunk runs its prepare and formula without grad on that step's micro-batches, numbered past the rollout's training ones. The DMD2 critic declares its scoring hooks there, so both modes run critic -> actor through train_diffusion.py, and train_dmd2.py goes. The critic's forwards and their order are the ones of the split calls: steps 0..K-2, the scoring forwards at micro-batch ids K*m.., step K-1. Suggested by Rockdu on #375.
…guard, which nothing calls now They existed to split the critic's steps around a forward-only scoring call from train_dmd2.py. The scoring now runs inside the critic's one train call, so `FSDPTrainRayActor.compute` / `RayTrainGroup.async_compute`, the `optim_steps` range of `train`, and the awake check that kept a second `wake_up` in one wake from repointing the frozen models' host copies have no caller. The trunk keeps its `hooks` argument, which the forward-only pass uses.
… flow-grpo test fix (#380)
…ate scoring forward `reuse-critic-step`, the default, keeps the current behavior: the critic's last training forward, drawn in the scoring range, is its score. Under `original` the last step trains plain SFT on the full grid and its prepare hook also returns the scoring batch, a separate draw in the scoring range with the teacher asked for, as the step's forward-only batch; the formula keeps the x0 of that batch's teacher and critic forwards, which the trunk runs before the step's training forward and so before its update, as tianweiy/DMD2 does. Both modes score the same samples and hand the actor the same structure, through train_diffusion.py. The scoring batch and the kept x0 are factored into `prepare_scoring_batch` and `keep_scores`, which both modes use. Suggested by Rockdu on #375. (cherry picked from commit f2f18e9) (cherry picked from commit eee94ab26f6a6bd9cbb5804188ad768134ace0e4)
--dmd2-critic-scoring original: tianweiy/DMD2's scoring, a separate noise draw and critic forward on the last step's samples before the critic trains on them. The default,reuse-critic-step, keeps the current behavior, where that step's training forward doubles as the critic's score.This branch now follows the review suggestion below: the scoring runs inside the critic's own train call, as a forward-only pass before its last step, so the PR no longer adds
train_dmd2.py,compute/async_compute, theoptim_stepsrange or thewake_upguard. #416 implements the same suggestion with the scoring batch inside the last step'sPreparedBatchand has the side-by-side table; one of the two gets closed. #351 is the earlier version with the separate driver.What
--dmd2-critic-scoring {reuse-critic-step, original}, defaultreuse-critic-step(no behavior change).LossHooks.forward_only, aForwardOnlyHooks(runs_before_step, prepare, formula): before each optimizer step the predicate names,_train_corecalls the trunk with that prepare and formula on the step's micro-batches, without grad, numbered past the rollout's training micro-batches. What the formula keeps goes into the sametrain_output_inputslist._forward_train_pair_batchtakes the hooks to run.loss_hub.dmd2: the scoring batch and the kept x0 are factored intoprepare_scoring_batchandkeep_scores, which both modes use. The critic declaresForwardOnlyHooks(is_scored_before_training, prepare_scoring_batch, scoring_formula): underoriginalits last step is plain SFT (full grid, no teacher, keeps nothing) and the pass before it scores that step's pairs at a separate draw in the scoring range.train_diffusion.py.Why
PreparedBatch, the formula signature and the trunk's forward path are unchanged.originalper rollout: a critic and a teacher forward per scored sample. No extra sleep/wake under--offload-train, unlike the separate driver.computeskippedmaterialize_stored_tensorsno longer applies: the scoring runs insidetrain, which materializes.Tests
test_train_input_hook.py: the pass runs before its steps train, without grad, through the forward-only hooks, numbered past the training micro-batches and counting on across steps; the train-output hook receives what both kinds of forward kept.test_reference_models.py: the trunk runs the hooks it is handed instead of the group's.test_loss_hub_dmd2.py: underoriginalthe last step is plain SFT and keeps nothing; the scoring batch equals the reuse mode's last-step batch at the same micro-batch id;scoring_formulareturns no loss and keepsx_s − σ vof both forwards; each mode scores the last step exactly once.test_loss_hub_selection.py: the critic'sforward_onlyentry.Validation
pytest tests/fastin the CI CPU environment at 142d562: 726 passed._train_coreand_forward_train_pair_batchwith the DMD2 critic hooks, a 3-parameter critic and teacher, K = 3, 2 micro-batches per step, AdamW. Against a48de7f (this PR's previous head) driven as itstrain_dmd2.pydid (train(0, K−1)→compute→train(K−1, K)), the scores, the critic's final parameters and every step's loss and grad norm are bitwise equal. With the forward-only ids started at 0 instead the scores differ, so the check sees the draw.run-ci-e2e): the CPU stages, stage-b and all ten e2e tests pass, among them the H3 DMD2 proxy in the default mode (9 metric series match the committed standard). Three stage-c jobs of this run and [DMD2 10/10, alternative] feat(dmd2): --dmd2-critic-scoring original, scored by a forward-only batch inside the critic's last step #416's first died of the node's host-RAM limit while their suites overlapped (RayOutOfMemoryErrorat 1924 / 2013 GB) and passed when rerun one at a time.--dmd2-critic-scoring originalon GPU. The CI runs in [DMD2 10/10] feat(dmd2): train_dmd2.py and --dmd2-critic-scoring original, the reference's separate scoring #351's body are of the separate driver.Checklist
pre-commithooks pass on the changed filespython3 train_diffusion.py --helpparses;--dmd2-critic-scoringis listed