Repository navigation
Conversation
This was referenced Oct 19, 2026
Open
… from the critic group's scores
zhihengy
force-pushed
the
dmd2/04-critic
branch
from
October 19, 2026 23:26
b9b818c to
79e0d90
Compare
zhihengy
force-pushed
the
dmd2/05-dmd2-loss
branch
from
October 19, 2026 23:26
d9f0737 to
208e5b3
Compare
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.
Fifth of the DMD2 stacked series, on top of #333.
--loss-type dmd2now trains the actor. The student recomputes its x0 at the rollout's stepi, then follows the teacher-minus-critic scores that the critic group handed over.What
prepare_generator_batch: the student's unguided forward at(x_i, t_i)with the pair's positive cond.dmd2_loss_formula:x0 = x_i - σ_i·v;g = nan_to_num((x̂0_fake - x̂0_real) / mean|x0 - x̂0_real|);loss = 0.5·mean((x0 - sg(x0 - g))²), so∂loss/∂x0 = g / numel.This is the reference gradient: tianweiy/DMD2
compute_distribution_matching_loss, with the same batch-mean MSE once the actor divides by the pair count.--loss-type dmd2fills these two hooks the waynftfills its own. [DMD2 4/7]'s requirement for user hooks is dropped.Metrics:
dmd2_grad_abs_mean;x0_mean_abs_diff,x0_max_abs_diffandx0_rel_max, which compare the trainer's x0 with the rollout'sx̂0_i(same step, same weights) through the existingrecord_rollout_train_abs_diff.Single DiT component only, as with NFT.
Why
x̂0_i. The normalizer and the gradient path use the trainer's x0. The two x0s differ only by rollout/train numerics, because the actor takes one step per rollout on synced weights. Thex0_*metrics measure that gap on every step.x_iitself.Tests
tests/fast/backends/fsdp_utils/test_loss_hub_dmd2.py:tests/fast/utils/test_dmd2_arguments.py:dmd2fills the converter, prepare and loss paths, but never over a user's own.Checklist
pre-commithooks (black, isort, ruff at the pinned versions) pass on the changed filespytest tests/fastis green (556 passed, 6 skipped; 549 on [DMD2 4/7] feat(dmd2): train a fake-score critic group from the teacher and score the student's samples #333)python3 train_diffusion.py --helpstill parses (no flags added)customization.mdtable lists thedmd2hooks)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