xocialize commited on
Commit
1b13810
·
verified ·
1 Parent(s): a4ee298

README: int8 tier — measured quality, footprints, and why there is no 4-bit tier

Browse files
Files changed (1) hide show
  1. README.md +106 -0
README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: nvidia-open-model-license
4
+ license_link: https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license
5
+ base_model:
6
+ - nvidia/Qwen-Image-Flash
7
+ pipeline_tag: text-to-image
8
+ library_name: mlx
9
+ tags:
10
+ - mlx
11
+ - mlx-swift
12
+ - text-to-image
13
+ - qwen-image
14
+ - dmd2
15
+ - few-step
16
+ - nvidia
17
+ - quantized
18
+ ---
19
+
20
+ # Qwen-Image-Flash-8bit (MLX)
21
+
22
+ An **int8** MLX snapshot of [nvidia/Qwen-Image-Flash](https://huggingface.co/nvidia/Qwen-Image-Flash) —
23
+ NVIDIA's DMD2 four-step distillation of [Qwen/Qwen-Image](https://huggingface.co/Qwen/Qwen-Image).
24
+ 28 GB total, versus 57.7 GB for
25
+ [the bf16 snapshot](https://huggingface.co/mlx-community/Qwen-Image-Flash-bf16).
26
+
27
+ This is the tier that makes a 20B-parameter image model reachable on ordinary Apple Silicon: a
28
+ **30.0 GB peak** at 1024²/4 steps instead of bf16's 57.4 GB, and it is **4× faster**.
29
+
30
+ ## Contents
31
+
32
+ | file | precision | size |
33
+ |---|---|---|
34
+ | `transformer/model-int8.safetensors` | int8 attention + feed-forward + modulation, group 64 | 21.75 GB |
35
+ | `text_encoder/model-int8.safetensors` | int8 Qwen2.5-VL-7B **language model only** | 7.51 GB |
36
+ | `vae/` | unquantized | 0.25 GB |
37
+
38
+ The `img_in` / `txt_in` / `time_text_embed` / `norm_out` / `proj_out` projections are left at full
39
+ precision, and the VAE is never quantized — decode is where precision loss shows up as visible
40
+ colour and banding artifacts.
41
+
42
+ The text encoder carries **no vision tower**: text-to-image conditions on text alone, so the ViT is
43
+ dead weight in this pipeline and is omitted entirely.
44
+
45
+ ## Measured quality
46
+
47
+ Against PyTorch fp32 goldens (diffusers 0.37.1), on identical injected inputs:
48
+
49
+ | | int8 | bf16 | fp32 oracle |
50
+ |---|---|---|---|
51
+ | DiT step-0 cosine | **0.9973** | 0.99836 | 1.0 |
52
+ | VL-7B prompt-embed cosine | **0.99992** | 0.9999926 | 1.0 |
53
+ | 1024²/4-step render | 19.8 s | 83.3 s | — |
54
+ | load | 2.3 s | ~60 s | — |
55
+ | peak memory | **30.0 GB** | 57.4 GB | — |
56
+
57
+ Renders at this tier are visually indistinguishable from bf16 at the same seed.
58
+
59
+ ### Why there is no 4-bit tier
60
+
61
+ int4 was built and measured, not skipped: DiT step-0 cosine **0.9623** at group 64 and **0.9659** at
62
+ group 32, with the VL encoder at 0.9845. The 1024² render came out visibly soft and washed out, with
63
+ fine fur and snow detail gone. Finer scale groups did not rescue it — this DiT is intrinsically lossy
64
+ at 4 bits — so no 4-bit snapshot is published rather than shipping one that looks like that.
65
+
66
+ ## Inference notes that are easy to get wrong
67
+
68
+ The distillation **internalized CFG 4.0**, and the packaged scheduler is **static shift-3**
69
+ (`use_dynamic_shifting: false`):
70
+
71
+ - `num_inference_steps = 4`, `true_cfg_scale = 1.0` — applying CFG again double-counts guidance the
72
+ student already absorbed, and doubles the transformer evaluations per step for nothing.
73
+ - The four-step trajectory is sigmas `[1.0, 0.9, 0.75, 0.5, 0.0]`.
74
+ - Tested at 1024 × 1024. Use width/height divisible by 16.
75
+
76
+ ## Use from Swift (MLXEngine)
77
+
78
+ ```swift
79
+ import MLXQwenImageFlash
80
+ import MLXToolKit
81
+
82
+ let package = QwenImageFlashPackage(configuration: .init(quant: .int8))
83
+ try await package.load()
84
+ let response = try await package.run(T2IRequest(
85
+ prompt: "A red fox in a snowy pine forest at golden hour, photorealistic",
86
+ width: 1024, height: 1024, seed: 42)) as! T2IResponse
87
+ ```
88
+
89
+ Port: [xocialize/qwen-image-edit-swift](https://github.com/xocialize/qwen-image-edit-swift) (MIT).
90
+ The package also selects this tier automatically when the engine's memory governor reports a budget
91
+ that cannot seat bf16 — and it resolves that *before* downloading, so a constrained machine fetches
92
+ this 28 GB snapshot rather than 41 GB of bf16 it could never load.
93
+
94
+ These are **pre-quantized** weights. Consumers never materialize bf16 at any point, which is the
95
+ difference between a tier that runs on a 32–48 GB machine and one that merely claims to: quantizing
96
+ at load would require holding the 41 GB bf16 transformer first.
97
+
98
+ ## License
99
+
100
+ Governing terms: **[NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license)**.
101
+ Additional information: Apache License 2.0 (`LICENSE`).
102
+
103
+ > Licensed by NVIDIA Corporation under the NVIDIA Open Model License
104
+
105
+ Commercial use, derivative models, and redistribution are permitted; if you redistribute these
106
+ weights you must pass on the Agreement and this notice (§3.1). See `NOTICE`.