nynxz commited on
Commit
4a9dcc8
Β·
verified Β·
1 Parent(s): d3a54c3

README: split q/k/v MOSS-Image checkpoints

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - comfyui
4
+ - diffusion-single-file
5
+ base_model:
6
+ - OpenMOSS-Team/MOSS-Image-Base
7
+ - OpenMOSS-Team/MOSS-Image-SFT
8
+ license: apache-2.0
9
+ ---
10
+
11
+ # MOSS-Image β€” split q/k/v (non-fused) checkpoints
12
+
13
+ The same MOSS-Image weights as [Comfy-Org/MOSS-Image](https://huggingface.co/Comfy-Org/MOSS-Image),
14
+ packed for ComfyUI with each attention layer's **q, k and v kept as separate tensors** instead of
15
+ fused into one `qkv` tensor. Use them to check whether a LoRA or LoKr behaves differently on the
16
+ fused files, or as the base for LoRAs trained on separate q/k/v projections.
17
+
18
+ Original model repositories:
19
+
20
+ - https://huggingface.co/OpenMOSS-Team/MOSS-Image-Base
21
+ - https://huggingface.co/OpenMOSS-Team/MOSS-Image-SFT
22
+
23
+ ## Files
24
+
25
+ ```
26
+ πŸ“‚ ComfyUI/
27
+ β”œβ”€β”€ πŸ“‚ models/
28
+ β”‚ β”œβ”€β”€ πŸ“‚ diffusion_models/
29
+ β”‚ β”‚ β”œβ”€β”€ moss_image_base_bf16_split_qkv.safetensors
30
+ β”‚ β”‚ └── moss_image_sft_bf16_split_qkv.safetensors
31
+ ```
32
+
33
+ | File | SHA-256 |
34
+ | --- | --- |
35
+ | `diffusion_models/moss_image_base_bf16_split_qkv.safetensors` | `65a698df38fbee8307a16059958f6dd1fef0db69c1e3805fe13ec1498cb0499e` |
36
+ | `diffusion_models/moss_image_sft_bf16_split_qkv.safetensors` | `9373f43d0fdad7d6d62b7dc2d96b2a048aab47f9c6e7befe11456b5ec26f70fc` |
37
+
38
+ Only the diffusion models are here. Get the text encoder (`text_encoders/`) and VAE (`vae/`) from
39
+ [Comfy-Org/MOSS-Image](https://huggingface.co/Comfy-Org/MOSS-Image); they are unchanged. Load these
40
+ files with **Load Diffusion Model** in place of the Comfy-Org ones. Everything else in the workflow
41
+ stays the same.
42
+
43
+ ## How they differ from Comfy-Org/MOSS-Image
44
+
45
+ | | Comfy-Org `moss_image_*_bf16` | This repo `moss_image_*_bf16_split_qkv` |
46
+ | --- | --- | --- |
47
+ | Attention weights per layer | `layers.N.proj.qkv.weight` `[9216, 3072]` | `layers.N.proj.q.weight`, `.k.weight`, `.v.weight`, each `[3072, 3072]` |
48
+ | Tensors | 379 | 463 (42 layers Γ— 3 instead of 1) |
49
+ | Everything else | bf16 | identical |
50
+
51
+ The weights are the same numbers in a different layout: for every layer, `cat(q, k, v)` here
52
+ equals `qkv` in the Comfy-Org file, bit for bit. Spot-checked on layers 0 and 41, plus the
53
+ output projection, for both Base and SFT. ComfyUI loads either layout as is, because the MOSS
54
+ model detects fused or split q/k/v from the keys. Fused is one matmul per layer instead of three,
55
+ so it can be a little faster. Image quality is the same.
56
+
57
+ ## Why this matters for LoRAs and LoKrs
58
+
59
+ Trainers such as AI Toolkit train adapters against **separate** `q`, `k` and `v` layers. On the
60
+ fused Comfy-Org files, ComfyUI has to map each of those adapters onto a third of the fused `qkv`
61
+ weight:
62
+
63
+ - **Load LoRA (normal patching):** the adapter is applied to its slice of `qkv`. This works, but
64
+ only for adapter keys named `diffusion_model.layers.N.proj.{q,k,v}` or
65
+ `lora_unet_layers_N_proj_{q,k,v}`. Keys under any other name are skipped, with a
66
+ `lora key not loaded` line in the console.
67
+ - **Load LoRA (Bypass):** adapters that target part of a fused weight are dropped. The console
68
+ logs `[BypassLoRA] Adapter key not in model state_dict` for each one, so a LoRA or LoKr loses
69
+ all of its attention q/k/v changes. (ComfyUI `fc04da91`: the patch for a slice is stored under
70
+ a `(key, slice)` tuple, which the bypass loader looks up as a plain state-dict key.)
71
+
72
+ With the split checkpoints every q/k/v adapter targets its own tensor directly, with no slicing,
73
+ in either loader. If a LoRA or LoKr looks noticeably different in ComfyUI than in the trainer's
74
+ own samples, try it on these files and check the console for the two messages above.
75
+
76
+ ## Licence
77
+
78
+ Apache 2.0, as the original MOSS-Image release.