Purpose
This repository provides fine-tuning training scripts for HunyuanImage-3.0. HunyuanImage-3.0 is an 80B MoE unified vision-language model that can perform both understanding and generation tasks, and the official repository contains only inference code. These scripts were independently developed by the Pixo team for research and educational purposes.
Main Capabilities
- Two training modes
- Pure-text fine-tuning: supervised fine-tuning based on the language model
- Image generation training: flow-matching-based text-to-image generation
- Note: The image understanding (MMU) pipeline has not yet been implemented.
- Parameter-efficient fine-tuning
- Supports LoRA fine-tuning
- Supports QLoRA (4-bit / 8-bit quantization), enabling memory-efficient training on a single GPU
- Training framework
- Based on Hugging Face Transformers Trainer
- Integrates DeepSpeed (including ZeRO-3 configuration)
- Integrates PEFT, Diffusers
- Data preparation tools
prepare_text_data.py: converts text formats such as Alpaca and ShareGPT into training JSONLprepare_image_gen_data.py: converts an image directory and a CSV description into training JSONL, supporting instruct and pretrain stylespreprocess_images.py: pre-encodes images into latent representations using the VAE encoder to accelerate training
- Training scripts
train_multimodal.py: main training script, supporting pure-text and image generation trainingtrain.sh: pure-text fine-tuning example (2 GPU + DeepSpeed, default Alpaca dataset)train_image.sh: image generation training exampletrain_image_qlora.sh: single-GPU memory-efficient image generation training (4-bit/8-bit)train_slurm.sh/train_image_slurm.sh: Slurm cluster multi-node version
- Advanced features
- Controllable text and image loss weights
- Flow matching weighting scheme:
sigma_sqrt、logit_normal、mode、cosmap、none - Supports
moe_drop_tokensto save VRAM at large resolutions
Usage
- Download the base model from the official repository
- Prepare training data (JSONL format, supporting pure text, instruct-style image generation, and pretrain-style image generation)
- Configure the training script
- Run training:
# 纯文本微调 bash train.sh # 图像生成训练 bash train_image.sh # Slurm 集群 bash train_slurm.sh
Applicable Scenarios and Limitations
- Suitable for community fine-tuning of HunyuanImage-3.0, style adapter training, and text-to-image generation customization.
- Training requires relatively high VRAM; QLoRA can lower the barrier. VRAM requirements are based on tests with batch size 1 and short prompts (<50 tokens); long prompts or larger batches require more VRAM.
- The image understanding pipeline has not yet been implemented.
- The repository contains only training scripts; for inference code and documentation, please refer to the official repository.
- Full model training requires significantly more VRAM and is not covered by the examples.
- The official repository
tokenizer_wrapper.pyhas a bug in instruct-style training, which this repository has fixed. - License: This repository is AGPL; the official Hunyuan Image 3.0 repository is under the Tencent Hunyuan Community License Agreement.