Repository navigation
Studio: LoRA training for MiniMax-H3-Image, and loading the trained LoRA - #17863
Conversation
…oRA for H3-Image generation
…dapter, sampler-sign and sigma tests
…o, falls back to none)
…the Train panel takes a family's recommended steps
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…load; auto never picks int8 where int8 cannot run [skip ci]
…alog so Deploy, Export and the picker see it [skip ci]
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The adapter repo keeps receiving uploads; fetch the exact file the recommended hyperparameters were tuned with (sha256 45a5d60d...68bb60) instead of main. [skip ci]
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…h3-image # Conflicts: # studio/backend/core/training/diffusion_samples.py # studio/frontend/src/features/images/images-page.tsx [skip ci]
|
@codex review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…iniMax LoRA sidecar read (#17913) ## Summary Two checks are red on main right now: 1. **`Repo tests (CPU, rest)`: `tests/test_ci_repo_cpu_shards.py::TestEveryGlobRootMatchesAFile::test_no_shard_hands_pytest_an_unexpanded_pattern`** ``` AssertionError: these shard globs match no test file: [('gloo', 'tests/test_t[!p]*gloo*.py')] ``` #17892 added `tests/test_t[!p]*gloo*.py` to the gloo shard so that `tests/test_tokenizer_save_ddp_gloo.py` (from #17862) was collected by some shard. #17882 landed at the same time and renamed that file to `tests/test_local_save_tokenizer_ddp_gloo.py`, which the gloo shard's first glob (`tests/test_[!dfimpstu]*gloo*.py`) already covers. The `test_t[!p]` glob now matches nothing, and an unmatched glob reaches pytest as a literal path. Both PRs were right on their own; together they leave one dead glob. 2. **`(Python 3.13, rest)` and `Repo tests (CPU, rest)`: the text I/O encoding gates** ``` test_text_io_names_its_encoding[diffusion_minimax_h3_image.py] assert not ['diffusion_minimax_h3_image.py:3422: read_text() without encoding'] ``` #17863 added `json.loads(sidecar.read_text())` for the LoRA `adapter_config.json` sidecar. Without an encoding that read uses the locale codepage on Windows. ## Change - `.github/workflows/studio-backend-ci.yml`: remove `tests/test_t[!p]*gloo*.py` from the gloo shard and restore the comment that a `test_t[!p]*` gloo file would be reported as dropped by `tests/test_ci_repo_cpu_shards.py` (with a note on why the glob is not kept for later: an unmatched glob is a missing file to pytest). - `studio/backend/core/inference/diffusion_minimax_h3_image.py`: `sidecar.read_text(encoding = "utf-8")`. JSON is UTF-8, so behaviour on Linux and macOS is unchanged. ## Testing - `tests/test_ci_repo_cpu_shards.py` and `test_text_io_encoding.py::test_text_io_names_its_encoding[diffusion_minimax_h3_image.py]`: 16 passed on this branch, 2 failed on main. - `tests/test_runtime_text_encoding.py` and `studio/backend/tests/test_diffusion_minimax_h3_image.py` pass; `studio/backend/tests/test_text_io_encoding.py` passes for every tracked file.
Summary
MiniMax-H3-Image could not be trained in Studio (the family was not trainable and no trainer handled its distilled 6-step DiT). This adds LoRA training for it, and loading the trained LoRA for H3-Image generation.
How it works
core/training/diffusion_h3_image_trainer.py, ondiffusion_train_common, like the MiniMax-H3 video trainer): captions are encoded once with the hosted int8 Qwen3-VL-32B conditioner, which is then freed; VAE latents are cached, each picture on its own canvas of aboutresolution^2pixels at its own aspect (batch 1). The DiT loads through the same converter inference uses, AdaLN as the timestep table; Auto picks a bf16 base with 56 GB or more free, else an int8 weight-only base.x0 - noiseat model timet = 1 - sigma. This is the same convention as the public reference trainer for this model (ai-toolkit:fixed_train_sigmas= the 6 nonzero sample sigmas, the final 0 is the endpoint, its target is the negation of ours with the prediction negated). Every training timestep is a row of the AdaLN table, so the table stays exact, and the LoRA trains through gradient checkpointing.UNSLOTH_H3_IMAGE_TRAINING_ADAPTER=auto|ostris|off|<path>;autotrains without it, with a warning, if it cannot be downloaded.transformer_blocks.N.{attn.to_q, to_k, to_v, to_out.0, ff.net.0.proj, ff.net.2}); heads, AdaLN and the text refiner stay frozen.load_minimax_h3_image_pipeline(loras=[(path, weight)])merges it into the dense DiT block by block before int8 / fp8 quantisation, so every placement and speed path runs unchanged. A LoRA load streams the 66 GB release DiT instead of the hosted prequant, and the set and weight are fixed per load (another selection at render time returns the existing "load again" 400); Deploy to Create puts the LoRA in the load request. Native-key (ai-toolkit format) H3-Image LoRAs load too: the fused qkv is reordered and split, the fc1 halves swapped, checked against the checkpoint converter. The GGUF / sd.cpp engine refuses with "LoRAs need the diffusers engine".trainable=True, baseMiniMaxAI/MiniMax-H3-Image, nf4 / fp8 / mxfp8 refused for training; defaults rank 32, lr 5e-5, 150 steps, 1024, constant with 20 warmup steps; VRAM facts; 6-step training previews; the Train panel hides flow shift, CFG dropout and random flip for this family and now takes a family's recommended step count (it was fixed at 500).Results
Colab G4 (RTX PRO 6000) and A100 80 GB, 18 cards from Studio's 1920 tarot example dataset, trigger
trtcrd, training adapter on, rank 32:With the default, the trigger prompt renders a clean tarot card that keeps the subject and a legible title; lr 5e-5 x 300 starts garbling the title, lr 1e-4 x 300 drifts most. The style still leaks into prompts without the trigger (most on a car and a lighthouse prompt), so lower weights (0.6 to 0.8) suit subtler use. Without the training adapter the same data gives blotchy cards with garbled titles, which is why it is on by default.
The sampler's x0 estimate on the training images moves closer to the image at every head after training (head 0: 1.013 -> 0.583, head 5: 0.0181 -> 0.0177).
A fresh process reloads the LoRA into 300 / 300 layers with every speed lever on; renders at 1536x2720 take 5 to 6 s on the A100.
Tests
tests/test_diffusion_h3_image_trainer.py(20): loss falls on the tiny native-layout release, the saved adapter holds exactly the trunk leaves, reload merges all layers and changes the output while weight 0 is bit-identical, merge equalsW + s * B @ A, native-key LoRAs merge like the converter, one sampler step fed the training target lands exactly on the next sigma at every head, every head is exercised, training sigmas equal the sampler's, a foreign LoRA and a changed render-time selection are refused.mainapart from environmental failures that fail the same there; frontend tsc clean, train-panel tests pass.Not covered
Screenshots
Images > Train, Model family list: BEFORE 9 families, AFTER adds MiniMax-H3-Image:
MiniMax-H3-Image picked: 33B, QLoRA 32GB+ VRAM, the bf16 / int8 note, Steps 150, rank 32, res 1024, lr 0.00005, Constant + warmup 20, and Timestep shift, Caption dropout and Random flip hidden (BEFORE cannot pick it and stays on FLUX.1-dev):