akhaliq HF Staff commited on
Commit
2390667
·
verified ·
1 Parent(s): 50b353f

Model card v2: validation verdict — branch attaches but does not steer; evidence + repro

Browse files
Files changed (1) hide show
  1. README.md +87 -45
README.md CHANGED
@@ -3,6 +3,10 @@ license: other
3
  license_name: minimax-h3-community-license-agreement
4
  license_link: LICENSE
5
  library_name: diffusers
 
 
 
 
6
  tags:
7
  - minimax-h3
8
  - videox_fun
@@ -10,64 +14,102 @@ tags:
10
  - controlnet-union
11
  - text-to-image
12
  - image-to-image
13
- - image-editing
14
  - ml-intern
15
  ---
16
 
17
- <div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 0 2em"><a href="https://hf.co/chat?mode=ml-intern"><img src="https://hf.co/datasets/huggingface/badges/resolve/main/built-with-ml-intern-lg.svg" alt="Built with ML Intern" style="margin:0"></a><a href="https://hf.co/chat?mode=ml-intern&prompt=Build%20a%20demo%20Space%20for%20akhaliq%2FMiniMax-H3-Image-Fun-Controlnet-Union-2.0" style="display:inline-flex;align-items:center;gap:5px;padding:4px 12px;border:1.5px solid #eee;border-radius:16px;background:#f9fbfc;color:#c2410c;font-weight:600;font-size:14px;text-decoration:none">Build a demo Space<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M13.5 6H5a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-8.5m-10.5 6L21 3m0 0h-5m5 0v5"/></svg></a><a href="https://hf.co/chat?mode=ml-intern&prompt=Adapt%20the%20ControlNet%20in%20akhaliq%2FMiniMax-H3-Image-Fun-Controlnet-Union-2.0%20for%20single-image%20control" style="display:inline-flex;align-items:center;gap:5px;padding:4px 12px;border:1.5px solid #eee;border-radius:16px;background:#f9fbfc;color:#c2410c;font-weight:600;font-size:14px;text-decoration:none">Adapt it for image control<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M13.5 6H5a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-8.5m-10.5 6L21 3m0 0h-5m5 0v5"/></svg></a></div>
18
-
19
- # MiniMax-H3-Image + Fun ControlNet-Union 2.0 (experimental merge)
20
-
21
- This repo packages two upstream models into one download:
22
-
23
- 1. **Base:** [MiniMaxAI/MiniMax-H3-Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image) — the MiniMax-H3 text-to-image / image-editing model, copied in full (native `transformer/` + `vae/` layout, diffusers `transformer_diffusers/` + `vae_diffusers/` layout, text encoder, processor/tokenizer, scheduler, and `pdd_fused_heads.safetensors`).
24
- 2. **Control branch:** [alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0](https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0) — a union ControlNet branch (`control_proj_in` + 10 `control_blocks`, ~13.6 GB) supporting 8 control conditions (Canny, Depth, HED, MLSD, Pose, Scribble, Layout, Gray) plus inpainting.
25
-
26
- ## ⚠️ Experimental pairing — read before using
27
-
28
- The ControlNet branch was **trained by the VideoX-Fun authors against the MiniMax-H3 *video* transformer**, not against this image model. It is a parallel residual branch that injects zero-gated skips into 10 of the 50 transformer blocks (layers 0, 5, 10, …, 45) at **runtime** — it cannot be (and has not been) folded into the base weights. The architectures are closely related (same hidden size 5376, 50 layers), so the weights are shape-compatible, but:
29
-
30
- - The control branch is **off-distribution** for the image checkpoint. Expect degraded or absent control until adapted/fine-tuned.
31
- - Control signals are **videos** in the upstream recipe (24 fps, frame counts of `17n + 5`). For single-image control, treat the image as a 1-frame (or 5-frame) control "video" and validate empirically.
32
- - Guidance is distilled for `guidance_scale = 1.0`; use `minimax_h3_control_inpaint_post_norm.yaml` from [VideoX-Fun](https://github.com/aigc-apps/VideoX-Fun) — loading the v1 config silently misplaces half the control blocks.
33
-
34
- If you get good (or bad) results with this pairing, please open a discussion — the point of this repo is to make that experiment easy.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  ## Repo layout
37
 
38
  ```
39
- model_index.json # MiniMaxH3ImagePipeline (native variant)
40
- modular_model_index.json # MiniMaxH3ImageModularPipeline (diffusers variant)
41
- transformer/ # native DiT (50 layers, hidden 5376)
42
- transformer_diffusers/ # diffusers DiT variant
43
- vae/, vae_diffusers/ # image VAE (both layouts)
44
- text_encoder/, tokenizer/, processor/
45
- scheduler/
46
- pdd_fused_heads.safetensors
47
- MiniMax-H3-Fun-Controlnet-Union-2.0.safetensors # ← the merged-in control branch
48
- configuration.json # controlnet metadata
 
 
 
 
 
 
 
 
 
49
  ```
50
 
51
- ## Usage sketch
52
 
53
  ```python
54
- from diffusers import DiffusionPipeline
55
-
56
- pipe = DiffusionPipeline.from_pretrained(
57
- "akhaliq/MiniMax-H3-Image-Fun-Controlnet-Union-2.0",
58
- torch_dtype="bfloat16",
59
- )
60
- # Load the control branch on top of the transformer via VideoX-Fun's
61
- # minimax_h3_control_inpaint_post_norm.yaml, then run with a control image
62
- # treated as a single-frame control video.
63
  ```
64
 
65
- See the upstream cards for full inference recipes:
66
 
67
- - Base: https://huggingface.co/MiniMaxAI/MiniMax-H3-Image
68
- - ControlNet: https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0
69
- - Code: https://github.com/aigc-apps/VideoX-Fun
 
 
 
 
 
70
 
71
- ## License
72
 
73
- Both upstream models are released under the MiniMax-H3 Community License Agreement (`other`). The same terms apply to this redistribution — see `LICENSE` (from the base model) and `LICENSE.controlnet` (from the ControlNet repo). This is an unofficial community packaging, not endorsed by MiniMax or the VideoX-Fun authors.
 
 
3
  license_name: minimax-h3-community-license-agreement
4
  license_link: LICENSE
5
  library_name: diffusers
6
+ base_model:
7
+ - MiniMaxAI/MiniMax-H3-Image
8
+ - alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0
9
+ base_model_relation: merge
10
  tags:
11
  - minimax-h3
12
  - videox_fun
 
14
  - controlnet-union
15
  - text-to-image
16
  - image-to-image
 
17
  - ml-intern
18
  ---
19
 
20
+ <div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 0 2em"><a href="https://hf.co/chat?mode=ml-intern"><img src="https://hf.co/datasets/huggingface/badges/resolve/main/built-with-ml-intern-lg.svg" alt="Built with ML Intern" style="margin:0"></a><a href="https://hf.co/chat?mode=ml-intern&prompt=Fine-tune%20the%20control%20branch%20in%20akhaliq%2FMiniMax-H3-Image-Fun-Controlnet-Union-2.0%20so%20it%20steers%20H3-Image" style="display:inline-flex;align-items:center;gap:5px;padding:4px 12px;border:1.5px solid #eee;border-radius:16px;background:#f9fbfc;color:#c2410c;font-weight:600;font-size:14px;text-decoration:none">Adapt the control branch<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M13.5 6H5a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-8.5m-10.5 6L21 3m0 0h-5m5 0v5"/></svg></a><a href="https://hf.co/chat?mode=ml-intern&prompt=Test%20the%20control%20branch%20from%20akhaliq%2FMiniMax-H3-Image-Fun-Controlnet-Union-2.0%20on%20the%20native%20(non-distilled)%20H3-Image%20DiT%20at%2040%20steps" style="display:inline-flex;align-items:center;gap:5px;padding:4px 12px;border:1.5px solid #eee;border-radius:16px;background:#f9fbfc;color:#c2410c;font-weight:600;font-size:14px;text-decoration:none">Try the native DiT<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M13.5 6H5a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-8.5m-10.5 6L21 3m0 0h-5m5 0v5"/></svg></a></div>
21
+
22
+ # MiniMax-H3-Image + Fun ControlNet-Union 2.0 (wired, not yet steering)
23
+
24
+ **Status: honest negative.** This repo packages [MiniMaxAI/MiniMax-H3-Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image)
25
+ (diffusers variant) with the [alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0](https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0)
26
+ control branch, plus a **verified-correct runtime wiring** to attach the branch to the image DiT.
27
+ The verdict from validation: the branch attaches and runs, but **does not transfer usable spatial
28
+ control to the image model out of the box** — it perturbs the output instead of steering it.
29
+ It needs adaptation fine-tuning on the image model (the same kind of port that worked for the
30
+ [character-swap LoRA](https://huggingface.co/akhaliq/MiniMax-H3-Image-Character-Swap), but this
31
+ time it's 10 transformer blocks, not a weight delta — see "Why this merge is different" below).
32
+
33
+ Everything needed to reproduce, extend, or fine-tune from this point is in the repo.
34
+
35
+ ## What was verified (H200, diffusers 0.43, seed 904231, 1024×1024)
36
+
37
+ | Check | Result | Meaning |
38
+ |---|---|---|
39
+ | Control weights load | 144 tensors, `missing=0 unexpected=0` | Block architecture matches the image DiT exactly |
40
+ | `control_context_scale=0.0` | **PSNR = ∞** vs base (bit-identical) | Wiring is inert when gated off — math is right |
41
+ | Canny control @ 0.5 / 1.0 / 1.5 / 2.0 | PSNR vs base 16.2 / 13.8 / 12.8 / 12.1 dB | Output changes monotonically with scale… |
42
+ | …but structure follows edges? | **No** — output ignores the edge map at every scale | Branch perturbs, doesn't steer |
43
+ | Circle-left vs circle-right control | Output edge-density L/R ratio 1.012 vs 1.008 | No spatial routing reaches the pixels |
44
+ | `control_proj_in` output norms | L/R 1.031 → 0.970 when circle flips side | Control **input** is spatially correct |
45
+ | Hint norms after control blocks | L/R ≈ 0.97–1.00, nearly identical for both circles | Control **blocks** collapse the spatial signal on image-model activations |
46
+
47
+ Images: [`assets/validation/`](assets/validation) (canny sweep), [`assets/diag/`](assets/diag) (circle test),
48
+ [`assets/diag2/`](assets/diag2) (hint heatmaps).
49
+
50
+ **Mechanism of the failure:** the control rows (image VAE latents of the control image, patchified
51
+ (1,2,2), zero-padded to the 196-col no-inpaint layout) carry the spatial pattern correctly into
52
+ `control_proj_in`. But the 10 control blocks — trained against the MiniMax-H3 **video** model's
53
+ activations at ~40 flow-matching steps — wash that pattern into a global offset when they run over
54
+ the image DiT's packed sequence (6-step PDD-distilled grid). The zero-gated `after_proj` skips they
55
+ emit are spatially near-uniform, so the main branch receives a per-position nudge that carries no
56
+ structure.
57
+
58
+ ## Why this merge is different from a LoRA merge
59
+
60
+ A LoRA is a weight delta (`W + B·A`) — it fuses offline and the forward pass never changes, which
61
+ is why the video-trained character-swap LoRA ported cleanly. A ControlNet is a **parallel runtime
62
+ branch**: 10 full transformer blocks whose zero-gated outputs are added to the main branch's
63
+ activations at layers 0,5,…,45 on every denoising step. It cannot be folded into the weights, and
64
+ its behavior depends on the activation statistics and denoising trajectory it was trained with —
65
+ both of which differ between the video model and the PDD-distilled image model.
66
 
67
  ## Repo layout
68
 
69
  ```
70
+ transformer_diffusers/ # H3-Image DiT (PDD, 6-step) — unmodified
71
+ vae_diffusers/, tokenizer/, processor/, scheduler/
72
+ modular_model_index.json # components referenced from MiniMaxAI/MiniMax-H3-Image
73
+ controlnet/
74
+ MiniMax-H3-Fun-Controlnet-Union-2.0.safetensors # the video-trained branch (13.6 GB)
75
+ configuration.json
76
+ merge/
77
+ validate_controlnet.py # attach + wrap + canny sweep (the wiring, working)
78
+ diag_spatial.py # circle left/right spatial-routing test
79
+ diag_hints.py # offline control-branch replay, hint heatmaps
80
+ assets/validation*/ , assets/diag*/
81
+ ```
82
+
83
+ ## Using the wiring (reproduce / build on it)
84
+
85
+ ```bash
86
+ pip install "diffusers>=0.43" torch transformers accelerate safetensors gradio_client \
87
+ opencv-python-headless hf_xet
88
+ python merge/validate_controlnet.py # needs an H200-class GPU (~77 GiB peak)
89
  ```
90
 
91
+ The attach API (from `merge/validate_controlnet.py`):
92
 
93
  ```python
94
+ attach_control_branch(model, "controlnet/MiniMax-H3-Fun-Controlnet-Union-2.0.safetensors")
95
+ wrap_forward_with_control(model) # forward gains control_rows / control_context_scale
96
+ control_rows = build_control_rows(pipe, control_image_rgb, latent_h, latent_w)
97
+ # pass through the modular pipeline:
98
+ pipe(..., denoiser_input_fields={"control_rows": control_rows, "control_context_scale": 1.0})
 
 
 
 
99
  ```
100
 
101
+ ## Paths forward (not done here)
102
 
103
+ 1. **Fine-tune the branch on the image model** — freeze the DiT, train the 10 control blocks +
104
+ `control_proj_in` on image/edge pairs. The zero-gated init means training starts from exact
105
+ base-model behavior. This is the route most likely to work well.
106
+ 2. **Native (non-distilled) DiT at 30–40 steps** — the native `transformer/` checkpoint in
107
+ MiniMaxAI/MiniMax-H3-Image is closer to the branch's training trajectory, but its VideoX-Fun
108
+ key layout needs a remap before diffusers can load it.
109
+ 3. **Video-VAE control latents** — the branch was trained on the 3D VAE's latents; feeding image
110
+ VAE latents may itself be off-distribution.
111
 
112
+ ## Sources & license
113
 
114
+ - Base: https://huggingface.co/MiniMaxAI/MiniMax-H3-Image · ControlNet: https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union-2.0 · Code: https://github.com/aigc-apps/VideoX-Fun
115
+ - Both under the MiniMax-H3 Community License (`LICENSE`, `LICENSE.controlnet`); the same terms apply to this unofficial community repackaging. Not endorsed by MiniMax or the VideoX-Fun authors.