|
| 1 | +# LTX-2 T2V NVFP4 quantization-aware fine-tune (QAT). |
| 2 | +# |
| 3 | +# Same recipe as fine_tuning/ltx2/t2v.yaml, with the deployment-matched |
| 4 | +# NVFP4 quantization from the validated |
| 5 | +# examples/train/configs/overfit_ltx2_t2v_nvfp4_qat.yaml run: the curated |
| 6 | +# attention/FFN linear set used by LTX-2 NVFP4 deployment runs its |
| 7 | +# forward through real NVFP4 GEMMs (flashinfer cutlass) with a |
| 8 | +# straight-through-estimator backward into the dense fp32 master weights. |
| 9 | +# No extra parameters or buffers are added, so FSDP sharding, |
| 10 | +# checkpointing, and export are identical to dense training. Video |
| 11 | +# attention uses ATTN_QAT_TRAIN for its quantized forward and STE |
| 12 | +# backward, then ATTN_QAT_INFER during validation. Head-dim-64 audio |
| 13 | +# attention and masked text attention remain dense. |
| 14 | +# |
| 15 | +# Validation requires an sm_120 GPU with the attn_qat_infer extension. |
| 16 | +# |
| 17 | +# Prerequisites: preprocess your dataset into the trainer's latent format |
| 18 | +# (see docs/training/data_preprocess.md; |
| 19 | +# fastvideo/pipelines/preprocess/preprocess_ltx2_overfit.py is a minimal |
| 20 | +# LTX-2 reference to adapt). Data paths, step counts, and learning rate |
| 21 | +# below are placeholders you must adapt to your workload. |
| 22 | +# |
| 23 | +# Run on multi-GPU sm_120 hardware: |
| 24 | +# NUM_GPUS=4 bash examples/train/run.sh \ |
| 25 | +# examples/train/configs/fine_tuning/ltx2/nvfp4_qat_t2v.yaml |
| 26 | +# |
| 27 | +# GB200 can train and validate with ATTN_QAT_TRAIN, but cannot load the |
| 28 | +# sm_120-only inference kernel. Disable only the validation-time swap: |
| 29 | +# NUM_GPUS=4 bash examples/train/run.sh \ |
| 30 | +# examples/train/configs/fine_tuning/ltx2/nvfp4_qat_t2v.yaml \ |
| 31 | +# --callbacks.validation.attn_qat_infer false |
| 32 | + |
| 33 | +models: |
| 34 | + student: |
| 35 | + _target_: fastvideo.train.models.ltx2.LTX2Model |
| 36 | + # Validation settings below (8 steps, guidance 1.0) assume this |
| 37 | + # distilled checkpoint. |
| 38 | + init_from: FastVideo/LTX2-Distilled-Diffusers |
| 39 | + trainable: true |
| 40 | + enable_gradient_checkpointing_type: full |
| 41 | + attention_backend: ATTN_QAT_TRAIN |
| 42 | + |
| 43 | +method: |
| 44 | + _target_: fastvideo.train.methods.fine_tuning.finetune.FineTuneMethod |
| 45 | + |
| 46 | +training: |
| 47 | + distributed: |
| 48 | + # The 13B video branch needs sharding; 4-way HSDP shard matches the |
| 49 | + # validated LTX-2 runs. Scale num_gpus/hsdp_shard_dim together. |
| 50 | + num_gpus: 4 |
| 51 | + sp_size: 1 |
| 52 | + tp_size: 1 |
| 53 | + hsdp_replicate_dim: 1 |
| 54 | + hsdp_shard_dim: 4 |
| 55 | + |
| 56 | + data: |
| 57 | + # REQUIRED: path to your preprocessed dataset. |
| 58 | + data_path: data/your_dataset_preprocessed |
| 59 | + dataloader_num_workers: 4 |
| 60 | + train_batch_size: 1 |
| 61 | + # LTX2Model requires 0.0: CFG dropout would zero post-connector |
| 62 | + # embeddings, which is not the model's unconditional input. |
| 63 | + training_cfg_rate: 0.0 |
| 64 | + seed: 42 |
| 65 | + # Must match your preprocessed resolution/length. |
| 66 | + # num_latent_t = (num_frames - 1) / 8 + 1. |
| 67 | + num_latent_t: 11 |
| 68 | + num_height: 480 |
| 69 | + num_width: 832 |
| 70 | + num_frames: 81 |
| 71 | + |
| 72 | + optimizer: |
| 73 | + # Carried from the validated LTX-2 QAT overfit run as a starting |
| 74 | + # point; tune for your dataset size and batch configuration. |
| 75 | + learning_rate: 5.0e-5 |
| 76 | + betas: [0.9, 0.999] |
| 77 | + weight_decay: 0.0 |
| 78 | + lr_scheduler: constant |
| 79 | + lr_warmup_steps: 0 |
| 80 | + |
| 81 | + loop: |
| 82 | + # Workload-dependent: set from your dataset size and target epochs. |
| 83 | + max_train_steps: 2000 |
| 84 | + gradient_accumulation_steps: 1 |
| 85 | + |
| 86 | + checkpoint: |
| 87 | + output_dir: outputs/ltx2_t2v_nvfp4_qat_finetune |
| 88 | + # A full training-state checkpoint is ~150GB for the 13B trainable |
| 89 | + # video branch — size the interval and total limit to your storage. |
| 90 | + training_state_checkpointing_steps: 500 |
| 91 | + checkpoints_total_limit: 2 |
| 92 | + resume_from_checkpoint: latest |
| 93 | + |
| 94 | + tracker: |
| 95 | + trackers: [wandb] |
| 96 | + project_name: fastvideo_ltx2 |
| 97 | + run_name: ltx2_t2v_nvfp4_qat_finetune |
| 98 | + |
| 99 | + model: |
| 100 | + # LTX2Model.predict_noise converts the DiT's x0 output to velocity, |
| 101 | + # so the default noise-minus-clean target reproduces the official |
| 102 | + # unweighted masked-MSE (mask is all-ones for plain T2V). |
| 103 | + precondition_outputs: false |
| 104 | + enable_gradient_checkpointing_type: full |
| 105 | + |
| 106 | +callbacks: |
| 107 | + grad_clip: |
| 108 | + _target_: fastvideo.train.callbacks.grad_clip.GradNormClipCallback |
| 109 | + max_grad_norm: 1.0 |
| 110 | + validation: |
| 111 | + _target_: fastvideo.train.callbacks.validation.ValidationCallback |
| 112 | + pipeline_target: fastvideo.pipelines.basic.ltx2.ltx2_pipeline.LTX2Pipeline |
| 113 | + # REQUIRED: prompts to sample during training. |
| 114 | + dataset_file: data/your_dataset_preprocessed/validation_prompts.json |
| 115 | + every_steps: 250 |
| 116 | + # 8-step single-pass sampling matches the distilled checkpoint |
| 117 | + # (validated in the LTX-2 overfit runs). |
| 118 | + sampling_steps: [8] |
| 119 | + guidance_scale: 1.0 |
| 120 | + num_frames: 81 |
| 121 | + # Validation reuses the live transformer and temporarily replaces its |
| 122 | + # ATTN_QAT_TRAIN implementations with the sm120 inference kernel. |
| 123 | + # Set false on GB200 (see header). |
| 124 | + attn_qat_infer: true |
| 125 | + |
| 126 | +# quant_config selects NVFP4 QAT for the same curated linear prefixes as |
| 127 | +# LTX-2 NVFP4 deployment. They fake-quantize through real FP4 GEMMs with |
| 128 | +# an STE backward. The string resolves to NVFP4QATTrainConfig at parse. |
| 129 | +pipeline: |
| 130 | + dit_config: |
| 131 | + quant_config: nvfp4_qat_train |
0 commit comments