SuperAPIAI Directory

Mochi-Full-Finetuner

github.com · AI video

Mochi-Full-Finetuner is an open-source tool repository for full fine-tuning or partial fine-tuning (e.g., specific DiT blocks) of the Mochi and Pusa 0.5 video generation models. It supports single-node and multi-node distributed training, and can use pre-encoded datasets or custom data. According to the official instructions, full fine-tuning is recommended to use 8 H800 or higher GPUs, and supports video lengths of up to 163 frames (about 5.4 seconds, 30 FPS). The tool provides complete environment installation steps, Mochi 1 weight download, dataset preparation, single-node/multi-node training scripts, and a method for converting fine-tuned checkpoints to safetensors, making it easy to replace the fine-tuned DiT weights into the original Mochi or Pusa model for video generation. In addition, the repository also cites related references for LoRA fine-tuning, but the current version does not support more memory-efficient training methods such as context parallelism, sequence parallelism, or tensor parallelism.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

Purpose: Mochi-Full-Finetuner provides tools for full fine-tuning or partial fine-tuning (e.g., training only specific DiT blocks) of the Mochi and Pusa 0.5 video generation models. It supports single-node and multi-node training, and can use the official pre-encoded datasets or user-defined data.

Main capabilities:

  • Supports full fine-tuning and partial fine-tuning of the Mochi and Pusa 0.5 video generation models.
  • Supports single-node and multi-node training configurations.
  • Video length supports up to 163 frames (about 5.4 seconds, 30 FPS), with the number of frames increasing in increments of 6: 25, 31, 37, ..., 163.
  • Single node (8 GPUs): with 163 frames and batch_size_per_worker=1, each GPU uses about 59GB of VRAM.
  • Dual node (16 GPUs): supports 163 frames with batch_size_per_worker=2 (total batch size 32); according to the instructions, training the Pusa-V0.5 model for 500 steps takes about 7 hours.
  • Supports multi-node training with more than two nodes.
  • Provides steps for converting training checkpoints to safetensors, and uses them to replace the original DiT weights.

How to use:

  1. Environment and dependency installation: set up the environment and install dependencies according to the repository instructions.
  2. Download the Mochi 1 weights.
  3. Dataset preparation:
    • You can use the official preprocessed dataset (52,695 pre-encoded latent samples, from VIDGEN-1M, of which Pusa V0.5 used only 16,000 samples).
    • You can also prepare a custom dataset according to the instructions in Mochi LoRA Training; the final dataset structure must meet the requirements.
  4. Single-node training (8 GPUs):
    • The training script uses src/genmo/mochi_preview/train_xxxx.py, where train_mochi.py is used to train the original Mochi, and train_pusa.py is used to train Pusa.
    • --data_path only needs to provide the video directory path; the caption directory is automatically inferred (by replacing the base directory name "videos" with "captions").
    • Checkpoints are saved to os.path.join(args.model_dir, 'checkpoints').
  5. Multi-node training:
    • Edit the SLURM configuration in src/genmo/mochi_preview/train_multi_nodes.sh: --partition, --nodes, --nodelist (optional), --cpus-per-task, --mem, --gres.
    • Update the project directory, model directory, data directory, and training script path (train_mochi.py or train_pusa.py).
    • Adjust training parameters: --num_frames, --frame_interval, --width, --height.
    • After starting multi-node training, logs are saved in logs/mochi_[job_id].out and logs/mochi_[job_id].err.
  6. Using the fine-tuned model:
    • Training checkpoints are located at os.path.join(args.model_dir, 'checkpoints').
    • Since FSDP is used to shard the model for training, the saved checkpoints need to be converted to safetensors.
    • After conversion, the fine-tuned DiT safetensors file is obtained, which can be used to replace the original DiT safetensors file and used in the same way as the original Mochi or Pusa model.
    • For example, when using Pusa, the fine-tuned DiT safetensors file can be provided as the checkpoint path in cli_test_ti2v_release.sh to generate videos.

Applicable scenarios:

  • Research and development requiring full fine-tuning or partial fine-tuning of the Mochi or Pusa 0.5 video generation models.
  • A single-node training environment with 8 H800 or higher GPUs, or a multi-node GPU cluster.
  • Wanting to use the official pre-encoded dataset or a custom dataset for video generation model training.

Limitations:

  • Full fine-tuning requires 8x H800 or higher GPUs.
  • Context parallelism, sequence parallelism, or tensor parallelism are currently not supported; these methods can significantly save GPU memory, and the repository welcomes related contributions.
  • For LoRA fine-tuning, refer to Mochi LoRA Training and Diffusers Python Library.
  • Other specific features, fees, prices, platforms, or effects are not yet provided.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools