You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
8.**VAE decoding** — `flux::autoencoder::AutoEncoder::decode()` converts latents to pixels
87
87
9.**Image encoding** — Tensor → RGB → PNG/JPEG bytes via the `image` crate
88
88
89
+
**Device split** — T5 and CLIP encoders load on **CPU** (9.2GB combined), while the FLUX transformer and VAE load on **GPU**. This is required because FLUX dev BF16 (23GB) + T5 (9.2GB) exceeds 24GB VRAM.
90
+
91
+
**GGUF quantized models** — the engine auto-detects `.gguf` extension on `MOLD_TRANSFORMER_PATH` and uses `candle_transformers::quantized_var_builder` + `flux::quantized_model::Flux`. GGUF quantized models (Q4_1 = 7GB, Q8_0 = 12GB) leave plenty of VRAM for activations. When quantized, state tensors use F32; when BF16, they use BF16.
92
+
93
+
**FluxTransformer enum** wraps either `flux::model::Flux` (BF16) or `flux::quantized_model::Flux` (GGUF quantized). Both implement `flux::WithForward` so the same `denoise()` call works for both.
94
+
89
95
Model loading is **lazy** (on first generation request) and uses **mmap** for safetensors files.
|`flux-dev`|`black-forest-labs/FLUX.1-dev`|`flux1-dev-Q4_1.gguf` (7GB) or `flux1-dev-Q8_0.gguf` (12GB) |
276
+
277
+
> **Note:** The full BF16 safetensors FLUX dev (23GB) fills all 24GB VRAM and causes CUDA OOM during the denoising activation pass. Always use GGUF quantized models on the RTX 4090.
225
278
226
279
Model registry is defined in `mold-inference/src/model_registry.rs`.
227
280
@@ -297,3 +350,18 @@ cargo test -p mold-core # Test specific crate
297
350
7.**mmap for safetensors**: Model weights are memory-mapped rather than read into memory, allowing the OS to manage paging efficiently.
298
351
299
352
8.**Env var + config file model paths**: Supports both deployment-friendly env vars and local config file paths. Env vars take precedence over config.
353
+
354
+
9.**GGUF over BF16 safetensors for 24GB VRAM**: The full BF16 FLUX dev model (23GB) fills all VRAM, leaving nothing for activations. GGUF Q8_0 (12GB) or Q4_1 (7GB) leave plenty of room. Engine auto-detects `.gguf` extension.
355
+
356
+
10.**T5/CLIP on CPU**: Text encoders load on CPU to keep ~9.2GB off the GPU. Embeddings are moved to GPU after encoding. This is required for the FLUX transformer to fit in VRAM alongside activations.
357
+
358
+
11.**Nix devshell for CUDA**: `flake.nix` provides a devshell with CUDA 12.8 packages (`cuda_nvcc`, `cuda_cudart`, `libcublas`, `cuda_nvrtc`, `libcurand`) and `CUDA_COMPUTE_CAP=89` for the RTX 4090. Build with `nix develop --command cargo build --release -p mold-server --features cuda`.
359
+
360
+
## Confirmed Working Configuration (hal9000, 2026-03-12)
0 commit comments