Instructions to use KBlueLeaf/MOSS-Image-FP16-fixed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use KBlueLeaf/MOSS-Image-FP16-fixed with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("KBlueLeaf/MOSS-Image-FP16-fixed", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Keep the card consistent with the uploaded images
Browse files
README.md
CHANGED
|
@@ -60,9 +60,7 @@ are the official ones.
|
|
| 60 |
| `comfyui/moss_image_sft_fp16_fixed.safetensors` | ComfyUI single file (fp16) |
|
| 61 |
| `reports/{base,sft}_fp16_fix.json` | every number on this page, per image |
|
| 62 |
|
| 63 |
-
<img src="images/gallery/base_comfyui_p1_s11.webp" alt="fp16
|
| 64 |
-
|
| 65 |
-
fp16 without the fix | fp16 with the fix | bf16 | fp32 (ComfyUI, 1024^2, seed 11).
|
| 66 |
|
| 67 |
## Why: the stream sits at 95% of the fp16 limit
|
| 68 |
|
|
@@ -81,22 +79,20 @@ block.
|
|
| 81 |
|
| 82 |

|
| 83 |
|
| 84 |
-
<img src="images/base_plain_fp16_p0.webp" alt="
|
| 85 |
-
|
| 86 |
-
fp16 without the fix | fp16 with the fix | bf16 | fp32 (KohakuMoss, 1024^2, prompt 0).
|
| 87 |
|
| 88 |
**Where plain fp16 breaks.** ComfyUI with `--fp16-unet` on the official Base file, 50
|
| 89 |
steps, CFG 3, euler / simple: all 8 prompts at 1024^2 finish (stream max 62,080), and so
|
| 90 |
does 2048^2 (64,096, 2.2% below the limit). **2560^2 is the first size that gives a
|
| 91 |
black image**: on step 29 of 50 the stream reaches 65,504 at block 26, every later
|
| 92 |
-
forward is NaN, and the image is black.
|
| 93 |
-
|
| 94 |
-
(x 16 = 67,008, 15.6x headroom)
|
| 95 |
|
| 96 |
-
<img src="images/
|
| 97 |
|
| 98 |
fp16 without the fix | fp16 with the fix | bf16 | fp32 (ComfyUI, 2560x2560, prompt 0
|
| 99 |
-
"tabby cat", seed 11). In single forwards over 7 sigmas, 2560^2, 2048x3072, 3072x2048
|
| 100 |
and 3072^2 overflow; 1536^2, 2048^2, 768x2048 and 1024x4096 do not. A 226-token prompt
|
| 101 |
moves the stream by under 1%.
|
| 102 |
|
|
@@ -169,26 +165,20 @@ steps) against fp32.
|
|
| 169 |
1024^2, 50 steps, CFG 3, 8 prompts x seeds 11 / 12 (16 images), each runtime against its
|
| 170 |
own fp32 run. LPIPS (AlexNet) / PSNR, lower / higher is closer.
|
| 171 |
|
| 172 |
-
| runtime | variant | fp16
|
| 173 |
-
| --- | --- | --- | --- | --- |
|
| 174 |
-
| ComfyUI | Base |
|
| 175 |
-
| ComfyUI | SFT |
|
| 176 |
-
| diffusers | Base |
|
| 177 |
-
| diffusers | SFT |
|
| 178 |
-
| KohakuMoss | Base |
|
| 179 |
-
| KohakuMoss | SFT |
|
| 180 |
|
| 181 |
fp16 carries 3 more mantissa bits than bf16; with the stream in range that is what the
|
| 182 |
fixed weights give back. "fixed vs bf16" is the size of bf16's own rounding drift, not an
|
| 183 |
-
error of the fix. No 1024^2 run produced a non-finite latent or image
|
| 184 |
-
fp16 still fits, and its distance to fp32 is the fixed weights' plus the GPU difference
|
| 185 |
-
below.
|
| 186 |
|
| 187 |
-
|
| 188 |
-
noise as the RTX 5090 draws it. The same plain-fp16 input on the two GPUs differs by
|
| 189 |
-
@@GPU_DRIFT@@ (LPIPS, prompt 0, both seeds), which is part of that column's distance.
|
| 190 |
-
|
| 191 |
-
Each panel: fp16 without the fix | fp16 with the fix | bf16 | fp32 (ComfyUI, seed 11).
|
| 192 |
`LPIPS*` is the distance to the fp32 panel.
|
| 193 |
|
| 194 |
### Base
|
|
@@ -234,8 +224,7 @@ Each panel: fp16 without the fix | fp16 with the fix | bf16 | fp32 (ComfyUI, see
|
|
| 234 |
</div>
|
| 235 |
|
| 236 |
Every runtime, both seeds and the adapter panels are in `images/gallery/`
|
| 237 |
-
(`<variant>_<runtime>_p<prompt>_s<seed>.webp`
|
| 238 |
-
all in the same four columns.
|
| 239 |
|
| 240 |
## Whole pipeline in fp16
|
| 241 |
|
|
@@ -250,23 +239,21 @@ transformer + fp16 VAE) is what the diffusers snippet below runs.
|
|
| 250 |
## Adapters
|
| 251 |
|
| 252 |
A LoRA (rank 8) and a LoKr (factor 16), trained on the official Base weights in
|
| 253 |
-
KohakuMoss, applied as-is to the fixed weights. Distance
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
| 258 |
-
|
|
| 259 |
-
| ComfyUI | Base |
|
| 260 |
-
| ComfyUI |
|
| 261 |
-
| ComfyUI | SFT |
|
| 262 |
-
|
|
| 263 |
-
| KohakuMoss | Base |
|
| 264 |
-
| KohakuMoss |
|
| 265 |
-
| KohakuMoss | SFT |
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
(LPIPS. The first three columns: 8 images each, seed 11, against fp32 + adapter run on a
|
| 269 |
-
V100; the last three: 16 images each, RTX 5090.) The adapter changes the image 3-10x more
|
| 270 |
than the fix does, and fixed + adapter stays about as close to bf16 + adapter as the two
|
| 271 |
bases are without it: it transfers.
|
| 272 |
|
|
@@ -275,10 +262,10 @@ bases are without it: it transfers.
|
|
| 275 |
<input type="radio" name="gl" id="l1"><label for="l1">Base LoKr</label>
|
| 276 |
<input type="radio" name="gl" id="l2"><label for="l2">SFT LoRA</label>
|
| 277 |
<input type="radio" name="gl" id="l3"><label for="l3">SFT LoKr</label>
|
| 278 |
-
<div class="mf-panel" id="pl0"><img src="images/gallery/base_comfyui_lora0_p3_s11.webp" alt=""><p>fp16
|
| 279 |
-
<div class="mf-panel" id="pl1"><img src="images/gallery/base_comfyui_lora1_p3_s11.webp" alt=""><p>fp16
|
| 280 |
-
<div class="mf-panel" id="pl2"><img src="images/gallery/sft_comfyui_lora0_p3_s11.webp" alt=""><p>fp16
|
| 281 |
-
<div class="mf-panel" id="pl3"><img src="images/gallery/sft_comfyui_lora1_p3_s11.webp" alt=""><p>fp16
|
| 282 |
</div>
|
| 283 |
|
| 284 |
Adapters on the joint blocks' q / k / v / o / `ffn_up_gate` / `ffn_down` (the usual
|
|
@@ -342,10 +329,7 @@ See [KohakuMoss](https://github.com/KohakuBlueleaf/KohakuMossTrainer).
|
|
| 342 |
## Notes
|
| 343 |
|
| 344 |
- Measured on an RTX 5090 (fp16 and bf16 matmuls with fp32 accumulation); the fp32
|
| 345 |
-
reference is the official weights in fp32. The
|
| 346 |
-
adapter panels and the 2560^2 example ran on a V100 (bf16 emulated there); KohakuMoss
|
| 347 |
-
and diffusers use the RTX 5090's initial noise per seed, since torch's CUDA generator
|
| 348 |
-
draws different noise on different GPUs.
|
| 349 |
- The headroom figures cover the prompts, resolutions and sigmas above, and 2560^2 for
|
| 350 |
the fixed Base weights (15.6x). Larger images, very long prompts and finetuned weights
|
| 351 |
were not measured.
|
|
|
|
| 60 |
| `comfyui/moss_image_sft_fp16_fixed.safetensors` | ComfyUI single file (fp16) |
|
| 61 |
| `reports/{base,sft}_fp16_fix.json` | every number on this page, per image |
|
| 62 |
|
| 63 |
+
<img src="images/gallery/base_comfyui_p1_s11.webp" alt="fp16-fixed vs official bf16 vs fp32, ComfyUI">
|
|
|
|
|
|
|
| 64 |
|
| 65 |
## Why: the stream sits at 95% of the fp16 limit
|
| 66 |
|
|
|
|
| 79 |
|
| 80 |

|
| 81 |
|
| 82 |
+
<img src="images/base_plain_fp16_p0.webp" alt="official weights fp16 / bf16 / fixed fp16">
|
|
|
|
|
|
|
| 83 |
|
| 84 |
**Where plain fp16 breaks.** ComfyUI with `--fp16-unet` on the official Base file, 50
|
| 85 |
steps, CFG 3, euler / simple: all 8 prompts at 1024^2 finish (stream max 62,080), and so
|
| 86 |
does 2048^2 (64,096, 2.2% below the limit). **2560^2 is the first size that gives a
|
| 87 |
black image**: on step 29 of 50 the stream reaches 65,504 at block 26, every later
|
| 88 |
+
forward is NaN, and the image is black. A single fp32 forward at this size peaks at
|
| 89 |
+
67,681, 3.3% over the fp16 limit; bf16 peaks at 67,048 and stays finite. The fixed
|
| 90 |
+
weights peak at 4,188 (x 16 = 67,008, 15.6x headroom):
|
| 91 |
|
| 92 |
+
<img src="images/base_fp16_break_2560.webp" alt="2560x2560: fp16 without the fix (NaN) | fp16 with the fix | bf16 | fp32">
|
| 93 |
|
| 94 |
fp16 without the fix | fp16 with the fix | bf16 | fp32 (ComfyUI, 2560x2560, prompt 0
|
| 95 |
+
"tabby cat", seed 11; the fp32 image is still rendering). In single forwards over 7 sigmas, 2560^2, 2048x3072, 3072x2048
|
| 96 |
and 3072^2 overflow; 1536^2, 2048^2, 768x2048 and 1024x4096 do not. A 226-token prompt
|
| 97 |
moves the stream by under 1%.
|
| 98 |
|
|
|
|
| 165 |
1024^2, 50 steps, CFG 3, 8 prompts x seeds 11 / 12 (16 images), each runtime against its
|
| 166 |
own fp32 run. LPIPS (AlexNet) / PSNR, lower / higher is closer.
|
| 167 |
|
| 168 |
+
| runtime | variant | fp16-fixed | official bf16 | fixed vs bf16 |
|
| 169 |
+
| --- | --- | --- | --- | --- |
|
| 170 |
+
| ComfyUI | Base | **0.0062** / 44.8 dB | 0.0501 / 29.3 dB | 0.047 |
|
| 171 |
+
| ComfyUI | SFT | **0.0042** / 43.2 dB | 0.0413 / 29.3 dB | 0.042 |
|
| 172 |
+
| diffusers | Base | **0.0111** / 42.8 dB | 0.0900 / 26.8 dB | 0.089 |
|
| 173 |
+
| diffusers | SFT | **0.0094** / 42.2 dB | 0.0655 / 28.1 dB | 0.065 |
|
| 174 |
+
| KohakuMoss | Base | **0.0145** / 42.7 dB | 0.0934 / 26.7 dB | 0.090 |
|
| 175 |
+
| KohakuMoss | SFT | **0.0121** / 42.9 dB | 0.0683 / 27.4 dB | 0.072 |
|
| 176 |
|
| 177 |
fp16 carries 3 more mantissa bits than bf16; with the stream in range that is what the
|
| 178 |
fixed weights give back. "fixed vs bf16" is the size of bf16's own rounding drift, not an
|
| 179 |
+
error of the fix. No 1024^2 run produced a non-finite latent or image.
|
|
|
|
|
|
|
| 180 |
|
| 181 |
+
Each panel: fp16-fixed | official bf16 | fp32 (ComfyUI, seed 11).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
`LPIPS*` is the distance to the fp32 panel.
|
| 183 |
|
| 184 |
### Base
|
|
|
|
| 224 |
</div>
|
| 225 |
|
| 226 |
Every runtime, both seeds and the adapter panels are in `images/gallery/`
|
| 227 |
+
(`<variant>_<runtime>_p<prompt>_s<seed>.webp`).
|
|
|
|
| 228 |
|
| 229 |
## Whole pipeline in fp16
|
| 230 |
|
|
|
|
| 239 |
## Adapters
|
| 240 |
|
| 241 |
A LoRA (rank 8) and a LoKr (factor 16), trained on the official Base weights in
|
| 242 |
+
KohakuMoss, applied as-is to the fixed weights. Distance between fixed + adapter and
|
| 243 |
+
official bf16 + adapter, next to the adapter's own effect:
|
| 244 |
+
|
| 245 |
+
| runtime | variant | adapter | fixed + adapter vs bf16 + adapter | without adapter | adapter effect |
|
| 246 |
+
| --- | --- | --- | --- | --- | --- |
|
| 247 |
+
| ComfyUI | Base | LoRA | 0.056 | 0.047 | 0.287 |
|
| 248 |
+
| ComfyUI | Base | LoKr | 0.064 | 0.047 | 0.389 |
|
| 249 |
+
| ComfyUI | SFT | LoRA | 0.039 | 0.042 | 0.284 |
|
| 250 |
+
| ComfyUI | SFT | LoKr | 0.039 | 0.042 | 0.395 |
|
| 251 |
+
| KohakuMoss | Base | LoRA | 0.105 | 0.090 | 0.316 |
|
| 252 |
+
| KohakuMoss | Base | LoKr | 0.053 | 0.090 | 0.406 |
|
| 253 |
+
| KohakuMoss | SFT | LoRA | 0.053 | 0.072 | 0.288 |
|
| 254 |
+
| KohakuMoss | SFT | LoKr | 0.042 | 0.072 | 0.417 |
|
| 255 |
+
|
| 256 |
+
(LPIPS, 16 images each.) The adapter changes the image 3-10x more
|
|
|
|
|
|
|
| 257 |
than the fix does, and fixed + adapter stays about as close to bf16 + adapter as the two
|
| 258 |
bases are without it: it transfers.
|
| 259 |
|
|
|
|
| 262 |
<input type="radio" name="gl" id="l1"><label for="l1">Base LoKr</label>
|
| 263 |
<input type="radio" name="gl" id="l2"><label for="l2">SFT LoRA</label>
|
| 264 |
<input type="radio" name="gl" id="l3"><label for="l3">SFT LoKr</label>
|
| 265 |
+
<div class="mf-panel" id="pl0"><img src="images/gallery/base_comfyui_lora0_p3_s11.webp" alt=""><p>fp16-fixed + adapter | official bf16 + adapter | official bf16 without it (ComfyUI)</p></div>
|
| 266 |
+
<div class="mf-panel" id="pl1"><img src="images/gallery/base_comfyui_lora1_p3_s11.webp" alt=""><p>fp16-fixed + adapter | official bf16 + adapter | official bf16 without it (ComfyUI)</p></div>
|
| 267 |
+
<div class="mf-panel" id="pl2"><img src="images/gallery/sft_comfyui_lora0_p3_s11.webp" alt=""><p>fp16-fixed + adapter | official bf16 + adapter | official bf16 without it (ComfyUI)</p></div>
|
| 268 |
+
<div class="mf-panel" id="pl3"><img src="images/gallery/sft_comfyui_lora1_p3_s11.webp" alt=""><p>fp16-fixed + adapter | official bf16 + adapter | official bf16 without it (ComfyUI)</p></div>
|
| 269 |
</div>
|
| 270 |
|
| 271 |
Adapters on the joint blocks' q / k / v / o / `ffn_up_gate` / `ffn_down` (the usual
|
|
|
|
| 329 |
## Notes
|
| 330 |
|
| 331 |
- Measured on an RTX 5090 (fp16 and bf16 matmuls with fp32 accumulation); the fp32
|
| 332 |
+
reference is the official weights in fp32. The 2560^2 example ran in ComfyUI on a V100.
|
|
|
|
|
|
|
|
|
|
| 333 |
- The headroom figures cover the prompts, resolutions and sigmas above, and 2560^2 for
|
| 334 |
the fixed Base weights (15.6x). Larger images, very long prompts and finetuned weights
|
| 335 |
were not measured.
|