1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-10-24 20:59:27 +03:00
Files
diffusers/examples/cosmos/train_lora.sh
Ting-Yun Chang 4ca863323d Add LoRA support for Cosmos Predict 2.5 and fix pipeline to match official Cosmos repo (#13664)
* support lora for cosmos 2.5

* Fix inconsistencies with cosmos official repo in VAE encoding, text encoder attention implementation, and timestep scaling

* Support f_min and f_max in linear_scheduler warmup

* Add requirements and dataset preprocessing scripts to run examples

* Add LoRA training scripts

* Add LoRA eval scripts

* add assets for blogpost

* Fix(scheduler): device mismatch from upstream b114620 - move rk and b to device before torch.stack

* Always upcast to fp32

* Directly inhrit from LoraBaseMixin

* remove flash-attn2

* Use _keep_in_fp32_modules instead of autocast

* remove the get_latent_shape_cthw method and fix style

* simplifiy the eval script to make it more user-friendly

* overwrite scheduling_unipc_multistep.py with main's version

* remove network_alphas and add # Copied from

* remove figures and assets

* revert scheduler

* revert fp32 upcast and support bs > 1

---------

Co-authored-by: Ting-Yun Chang <tingyunc@nvidia.com>
2026-05-07 16:50:13 -10:00

19 lines
640 B
Bash

export MODEL_NAME="nvidia/Cosmos-Predict2.5-2B"
export DATA_DIR="gr1_dataset/train"
export OUT_DIR=YOUR_OUTPUT_DIR
lora_rank=32
revision="diffusers/base/post-trained"
export TOKENIZERS_PARALLELISM=false
accelerate launch --mixed_precision="bf16" train_cosmos_predict25_lora.py \
--pretrained_model_name_or_path=$MODEL_NAME --revision $revision \
--train_data_dir=$DATA_DIR \
--train_batch_size=1 \
--num_train_epochs=500 --checkpointing_epochs=100 \
--seed=0 \
--output_dir=$OUT_DIR \
--report_to=wandb \
--height 432 --width 768 \
--allow_tf32 --gradient_checkpointing \
--lora_rank $lora_rank --lora_alpha $lora_rank