Download training-scripts/maltrainer/qwen_image_2_1_template.yaml from malcolmrey/various: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/datasets/malcolmrey/various/resolve/main/training-scripts/maltrainer/qwen_image_2_1_template.yaml
- Command line
-
hf download hf://datasets/malcolmrey/various/training-scripts/maltrainer/qwen_image_2_1_template.yaml
-
curl -L -o qwen_image_2_1_template.yaml https://huggingface.co/datasets/malcolmrey/various/resolve/main/training-scripts/maltrainer/qwen_image_2_1_template.yaml
3.15 kB
| # Qwen-Image 2.1 LoRA Training Configuration - maltrainer (https://github.com/malcolmamal/maltrainer) | |
| # | |
| # The recommended setting from the Qwen-Image 2.1 optimizer benchmark: | |
| # qwen/docs/QWEN_IMAGE_21_LORA_OPTIMIZER_BENCHMARK.md | |
| # Automagic3, ~1500 steps, 512px, rank 16 -> about 13-16 minutes on one RTX 5090 (~11 GB VRAM). | |
| # | |
| # Run with: python train_qwen_image_2_1_lora.py --config qwen_image_2_1_template.yaml | |
| # Sanity-check the stack first: python scripts/qwen_2_1_stack_probe.py --config qwen_image_2_1_template.yaml | |
| # Model configuration - the ComfyUI single-file checkpoints from Comfy-Org/Qwen-Image-2.1, no diffusers conversion | |
| model: | |
| transformer_path: "[comfyui_location]/models/diffusion_models/qwen_image_2.1_int8_convrot.safetensors" | |
| vae_path: "[comfyui_location]/models/vae/qwen_image_2.1_vae_bf16.safetensors" | |
| text_encoder_path: "[comfyui_location]/models/text_encoders/qwen3vl_8b_int8_convrot.safetensors" | |
| # Dataset configuration | |
| # Caption files (.txt next to each image) are recommended. Write them as "[instance_token], a [class_token] with ..." | |
| # so the trigger binds to the class word. If captions only say "a woman ..." the trigger never learns gender, | |
| # and prompts without the class word (e.g. "[instance_token] as a medieval knight") can come out as a man. | |
| dataset: | |
| path: "[dataset_location]/[person_to_train]" | |
| resolution: 512 # square 512x512 only for now (no cropping or bucketing yet: crop your images to | |
| # square first). More resolutions and aspect-ratio bucketing are planned. | |
| trigger: "[instance_token]" | |
| default_caption: "a photo of [instance_token], a [class_token]" | |
| repeats: 1 | |
| num_workers: 0 | |
| # LoRA configuration - all 32 blocks, attention + MLP (192 layers, 39.8M params at rank 16) | |
| lora: | |
| rank: 16 | |
| alpha: 16 | |
| prefix: "diffusion_model." | |
| target_modules: | |
| - "to_q" | |
| - "to_k" | |
| - "to_v" | |
| - "to_out.0" | |
| - "gate_up" | |
| - "img_mlp.out" | |
| dtype: "float32" | |
| # Training configuration | |
| train: | |
| batch_size: 1 | |
| gradient_accumulation_steps: 1 | |
| max_steps: 1500 # stops exactly here. Set 0 to train num_epochs instead. | |
| num_epochs: 70 # used when max_steps is 0. Aim for 60-80 epochs; Automagic3 tolerates running long. | |
| save_every: 250 | |
| timestep_distribution: "shift" | |
| sigmoid_scale: 1.0 | |
| max_grad_norm: 1.0 | |
| optimizer: "automagic3" | |
| learning_rate: 1.0e-6 # launch point only - Automagic3 adapts it (peaks ~2e-4, then decays to ~1e-5) | |
| weight_decay: 0.01 | |
| automagic_polarity_history: 8 | |
| automagic_clip_threshold: 1.0 | |
| automagic_beta2: 0.999 | |
| automagic_eps: 1.0e-30 | |
| # Alternative: optimizer "adamw8bit" with learning_rate 1.0e-4, keep checkpoints 1250-1750. | |
| # Prodigy is not recommended on this model: its LR keeps climbing and it overcooks. | |
| dtype: "bfloat16" | |
| mixed_precision: "bf16" | |
| seed: 42 | |
| output: | |
| path: "[output_location]/[person_to_train]" | |
| name: "qwen21_[person_to_train]" | |
| format: "diffusers" # lora_A / lora_B keys with the diffusion_model. prefix - loads in ComfyUI | |
| dtype: "bfloat16" | |
| embed_config: true | |
| logging: | |
| level: "INFO" | |