|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +"""Reference AnyFlow experiment config on Wan-1.3B T2V. |
| 5 | +
|
| 6 | +Mirrors the AnyFlow paper's pretrain configuration: 1.3B student initialised |
| 7 | +from a Wan2.1-T2V checkpoint, flow-matching shift=5, beta08 loss weighting, |
| 8 | +6k iterations with batch_size_global=32 and lr=5e-5. |
| 9 | +
|
| 10 | +Switching to the on-policy stage: |
| 11 | +
|
| 12 | + config.model.loss_config.training_stage = "onpolicy" |
| 13 | + config.model.pretrained_student_net_path = "<path-to-pretrain-ckpt>" |
| 14 | +
|
| 15 | +and adjust ``student_update_freq`` / ``gan_loss_weight_gen`` to taste. |
| 16 | +""" |
| 17 | + |
| 18 | +import fastgen.configs.methods.config_anyflow as config_anyflow_default |
| 19 | +from fastgen.configs.data import VideoLoaderConfig |
| 20 | +from fastgen.configs.discriminator import Discriminator_Wan_1_3B_Config |
| 21 | +from fastgen.configs.net import Wan_1_3B_Config |
| 22 | + |
| 23 | + |
| 24 | +def create_config(): |
| 25 | + config = config_anyflow_default.create_config() |
| 26 | + |
| 27 | + # Default to the pretrain stage; flip the switch to "onpolicy" once the |
| 28 | + # flow-map pretrain checkpoint is available. |
| 29 | + config.model.loss_config.training_stage = "pretrain" |
| 30 | + config.model.loss_config.jvp_finite_diff_eps = 5e-3 |
| 31 | + config.model.loss_config.diffusion_ratio = 0.5 |
| 32 | + config.model.loss_config.consistency_ratio = 0.25 |
| 33 | + config.model.loss_config.weight_type = "beta08" |
| 34 | + config.model.loss_config.shift = 5.0 |
| 35 | + |
| 36 | + config.model.net = Wan_1_3B_Config |
| 37 | + config.model.net.r_timestep = True |
| 38 | + |
| 39 | + # The on-policy stage uses these too, but they are harmless in pretrain. |
| 40 | + config.model.discriminator = Discriminator_Wan_1_3B_Config |
| 41 | + config.model.discriminator.disc_type = "multiscale_down_mlp_large" |
| 42 | + config.model.discriminator.feature_indices = [15, 22, 29] |
| 43 | + config.model.gan_loss_weight_gen = 0.0 # disabled by default in pretrain |
| 44 | + config.model.guidance_scale = 5.0 |
| 45 | + |
| 46 | + config.model.precision = "bfloat16" |
| 47 | + # VAE compress ratio: (1 + T/4) * H/8 * W/8. 81-frame, 480p clips. |
| 48 | + config.model.input_shape = [16, 21, 60, 104] |
| 49 | + |
| 50 | + config.model.net_optimizer.lr = 5e-5 |
| 51 | + config.model.fake_score_optimizer.lr = 5e-5 |
| 52 | + config.model.discriminator_optimizer.lr = 5e-5 |
| 53 | + |
| 54 | + config.model.sample_t_cfg.time_dist_type = "shifted" |
| 55 | + config.model.sample_t_cfg.min_t = 0.001 |
| 56 | + config.model.sample_t_cfg.max_t = 0.999 |
| 57 | + |
| 58 | + config.model.student_sample_type = "ode" |
| 59 | + # Any-step model — multiple NFEs validated at inference time. |
| 60 | + config.model.student_sample_steps = 4 |
| 61 | + config.model.sample_t_cfg.t_list = [0.999, 0.937, 0.833, 0.624, 0.0] |
| 62 | + |
| 63 | + config.dataloader_train = VideoLoaderConfig |
| 64 | + config.dataloader_train.img_size = (config.model.input_shape[-1] * 8, config.model.input_shape[-2] * 8) |
| 65 | + config.dataloader_train.sequence_length = (config.model.input_shape[1] - 1) * 4 + 1 |
| 66 | + config.dataloader_train.batch_size = 1 |
| 67 | + |
| 68 | + config.trainer.max_iter = 6000 |
| 69 | + config.trainer.logging_iter = 100 |
| 70 | + config.trainer.save_ckpt_iter = 500 |
| 71 | + config.trainer.batch_size_global = 32 |
| 72 | + |
| 73 | + config.log_config.group = "wan_anyflow" |
| 74 | + return config |
0 commit comments