1717
1818 trainer.checkpointer.pretrained_ckpt_path=<stage1>/checkpoints/0006000.pth
1919
20- Known deviation from the reference: full-rank fine-tuning instead of the paper's
21- rank-256 LoRA.
20+ Known deviations from the reference: full-rank fine-tuning instead of the paper's
21+ rank-256 LoRA; the noising times for the DMD gradient and the fake score are drawn
22+ on [0.001, 0.999] rather than the reference's [0, 1] (its ``dmd_cfg`` sets no
23+ ``min_timestep`` / ``max_timestep``, so it clamps to the full range) -- FastGen's
24+ convention for the other rectified-flow Wan configs; and, in the co-trained loss, the
25+ 1/g rescaling of dF/dt under ``guidance_fuse_scale`` is gated on the samples that kept
26+ their condition, where the reference's ``compute_central_difference`` rescales the whole
27+ batch (see ``config_anyflow.py`` and ``FlowMapLossMixin._compute_mf_loss``).
2228"""
2329
2430import copy
2531
32+
2633import fastgen .configs .methods .config_anyflow as config_anyflow_default
2734from fastgen .configs .data import VideoLoaderConfig
2835from fastgen .configs .net import Wan_1_3B_Config
36+ from fastgen .methods import AnyFlowModel
2937
3038
3139def create_config ():
@@ -77,11 +85,13 @@ def create_config():
7785 config .model .guidance_scale = 4.0
7886
7987 # DMD gradient noising time: reference `generator_loss` draws torch.rand
80- # then applies the shift -> shifted-uniform.
88+ # then applies the shift -> shifted-uniform. The bounds keep the score models off
89+ # the degenerate endpoints (see the deviation note above); `fake_score_sample_t_cfg`
90+ # inherits them through the deepcopy below.
8191 config .model .sample_t_cfg .time_dist_type = "shifted"
8292 config .model .sample_t_cfg .shift = 5.0
83- config .model .sample_t_cfg .min_t = 0.0
84- config .model .sample_t_cfg .max_t = 1.0
93+ config .model .sample_t_cfg .min_t = 0.001
94+ config .model .sample_t_cfg .max_t = 0.999
8595
8696 # Fake-score noising time: reference `discriminator_loss` draws
8797 # logit_normal(0, 1) then applies the same shift. This is a DIFFERENT
@@ -92,13 +102,12 @@ def create_config():
92102 config .model .fake_score_sample_t_cfg .train_p_std = 1.0
93103
94104 # ------ student rollout (reference rollout_cfg) ------
105+ # The rollout grid's shift comes from `cotrain_sample_t_cfg` below: the reference
106+ # builds its rollout pipeline from the same `scheduler` it draws the co-trained
107+ # (t, r) from, separately from the DMD noising time above.
95108 config .model .student_sample_type = "ode"
96109 config .model .student_sample_steps_list = [2 , 4 , 8 , 16 , 50 ]
97110 config .model .student_sample_steps = 4
98- # Validation schedule for `student_sample_steps = 4`: `shift * s / (1 + (shift
99- # - 1) * s)` on `s = linspace(1, 0, 5)` -- the same grid the per-NFE rollout
100- # builds. Recompute if `shift`, `max_t` or `student_sample_steps` changes.
101- config .model .sample_t_cfg .t_list = [1.0 , 0.9375 , 0.8333333333333334 , 0.625 , 0.0 ]
102111
103112 # ------ co-trained Stage-1 flow-map loss (reference cotrain_forward_kl) ------
104113 # FastGen's VSD loss carries a 0.5 factor the reference's DMD loss does
@@ -115,9 +124,22 @@ def create_config():
115124 config .model .guidance_fuse_scale = 3.0
116125 config .model .cond_dropout_prob = 0.1
117126 config .model .precision_amp_jvp = "float32"
118- config .model .sample_t_cfg .flow_matching_ratio = 0.5
119- config .model .sample_t_cfg .consistency_ratio = 0.25
120- config .model .sample_t_cfg .deterministic_buckets = True
127+ # (t, r) sampling for the co-trained loss, drawn from the reference's `scheduler`.
128+ # Its shift also drives the student's rollout grid, so it is independent of the DMD
129+ # noising-time shift above; the reference recipe sets both to 5.0.
130+ config .model .cotrain_sample_t_cfg .time_dist_type = "shifted"
131+ config .model .cotrain_sample_t_cfg .shift = 5.0
132+ config .model .cotrain_sample_t_cfg .min_t = 0.0
133+ config .model .cotrain_sample_t_cfg .max_t = 1.0
134+ config .model .cotrain_sample_t_cfg .flow_matching_ratio = 0.5
135+ config .model .cotrain_sample_t_cfg .consistency_ratio = 0.25
136+ config .model .cotrain_sample_t_cfg .deterministic_buckets = True
137+
138+ # Validation schedule at `student_sample_steps` -- the same grid the per-NFE rollout
139+ # builds, so it follows the co-trained sampling shift.
140+ config .model .sample_t_cfg .t_list = AnyFlowModel .rollout_t_list (
141+ config .model .student_sample_steps , config .model .cotrain_sample_t_cfg .shift , config .model .net .max_t
142+ ).tolist ()
121143
122144 # ------ optimization (reference: AdamW lr=2e-6, betas=(0.0, 0.999), wd=0,
123145 # grad clip 1.0, EMA 0.99) ------
0 commit comments