Commit b9294ab for stable-diffusion.cpp

commit b9294abe9860d28ad48ac84f493f3a0dd4bae1ae
Author: Pento <pentolo@outlook.com>
Date:   Thu Dec 3 15:09:38 2026 +0100

    docs: update quantization guide and Anima Turbo notes (#2501)

diff --git a/docs/guides/quantization_and_gguf.md b/docs/guides/quantization_and_gguf.md
index fd7f7ee..5d91535 100644
--- a/docs/guides/quantization_and_gguf.md
+++ b/docs/guides/quantization_and_gguf.md
@@ -1,27 +1,56 @@
-## Quantization
+# Quantization and GGUF conversion

-You can specify the model weight type using the `--type` parameter. The weights are automatically converted when loading the model.
+## Quantization

-- `f16` for 16-bit floating-point
-- `f32` for 32-bit floating-point
-- `q8_0` for 8-bit integer quantization
-- `q5_0` or `q5_1` for 5-bit integer quantization
-- `q4_0` or `q4_1` for 4-bit integer quantization
+`--type` sets the weight type. Weights are converted while loading, so the
+conversion repeats on every run. Names are case-sensitive ggml type names, for
+example `f32`, `f16`, `bf16`, `q8_0`, `q6_K`, `q5_K`, `q4_K`, `q4_0`, `q3_K`,
+and `iq4_xs`. Without `--type`, weights keep the type stored in the file
+unless a `--tensor-type-rules` rule matches them.
+Builds with `SD_USE_UPSTREAM_GGML=ON` are an exception: they always load F8
+safetensors weights as F16, which doubles their memory use, and reject F8 GGUF
+files.

+`--tensor-type-rules` sets the type per tensor with comma-separated
+`regex=type` pairs, for example `"^text_encoders\.=q8_0,^model\.=q4_K"`.
+Each regex is searched in the full tensor name, and the first matching rule
+wins over `--type`. Loaded tensor names carry their component prefix, such as
+`model.diffusion_model.` or `text_encoders.`.

-### Memory Requirements of Stable Diffusion 1.x
+Some tensors are never converted, not even by a matching rule: biases, scale
+tensors, embedders, and other small layers that are sensitive to precision.
+Quantized types also skip tensors whose first dimension is not a multiple of
+the block size (32 for `q8_0`, 256 for K-quants).

-| precision | f32  | f16  |q8_0  |q5_0  |q5_1  |q4_0  |q4_1  |
-| ----         | ----  |----  |----  |----  |----  |----  |----  |
-|  **Memory** (txt2img - 512 x 512) | ~2.8G | ~2.3G | ~2.1G | ~2.0G | ~2.0G | ~2.0G | ~2.0G |
-|  **Memory** (txt2img - 512 x 512) *with Flash Attention* | ~2.4G | ~1.9G | ~1.6G | ~1.5G | ~1.5G | ~1.5G | ~1.5G |
+For quantization guided by an importance matrix, see [imatrix](imatrix.md).

 ## Convert to GGUF

-You can also convert weights in the formats `ckpt/safetensors/diffusers` to gguf and perform quantization in advance, avoiding the need for quantization every time you load them.
+`-M convert` writes converted weights to a file, so they do not need to be
+quantized on every load. It reads `ckpt`, `safetensors`, diffusers, and GGUF
+files. The output is GGUF, or safetensors when the output name ends in
+`.safetensors`; safetensors output supports only unquantized types.
+
+```sh
+./bin/sd-cli -M convert \
+  -m ../models/checkpoints/v1-5-pruned-emaonly.safetensors \
+  -o ../models/checkpoints/v1-5-pruned-emaonly.q8_0.gguf \
+  --type q8_0 -v
+```
+
+To convert a single component, pass it with its usual option instead of `-m`:
+`--diffusion-model`, `--vae`, `--clip_l`, `--clip_g`, or `--t5xxl`. A converted
+diffusion model keeps the `model.diffusion_model.` prefix; load it again with
+`--diffusion-model`.

-For example:
+`--tensor-type-rules` also applies to conversion. For example, this keeps the
+LLM adapter of an Anima model in BF16 and its adaLN modulation in Q6_K, and
+quantizes the remaining weights to Q5_K:

 ```sh
-./bin/sd-cli -M convert -m ../models/v1-5-pruned-emaonly.safetensors -o  ../models/v1-5-pruned-emaonly.q8_0.gguf -v --type q8_0
-```
\ No newline at end of file
+./bin/sd-cli -M convert \
+  --diffusion-model ../models/diffusion_models/anima-turbo.safetensors \
+  -o ../models/diffusion_models/anima-turbo-q5_K.gguf \
+  --type q5_K \
+  --tensor-type-rules "llm_adapter\.=bf16,adaln_modulation=q6_K"
+```
diff --git a/docs/models/anima.md b/docs/models/anima.md
index 8a928cc..088f2e2 100644
--- a/docs/models/anima.md
+++ b/docs/models/anima.md
@@ -6,9 +6,10 @@ Anima generates images from text using a Qwen3 text encoder and a compatible Qwe

 | Component | Weights and downloads | CLI option | Requirement |
 | --- | --- | --- | --- |
-| Anima | [Safetensors](https://huggingface.co/circlestone-labs/Anima/tree/main/split_files/diffusion_models)<br>[GGUF](https://huggingface.co/Bedovyy/Anima-GGUF/tree/main)<br>gguf Anima2: [GGUF](https://huggingface.co/JusteLeo/Anima2-GGUF/tree/main) | `--diffusion-model` | Required |
-| vae | [Safetensors](https://huggingface.co/circlestone-labs/Anima/tree/main/split_files/vae) | `--vae` | Use matching VAE |
+| Anima | [Safetensors](https://huggingface.co/circlestone-labs/Anima/tree/main/split_files/diffusion_models)<br>[GGUF](https://huggingface.co/Bedovyy/Anima-GGUF/tree/main)<br>Anima2: [GGUF](https://huggingface.co/JusteLeo/Anima2-GGUF/tree/main) | `--diffusion-model` | Required |
+| VAE | [Safetensors](https://huggingface.co/circlestone-labs/Anima/tree/main/split_files/vae) | `--vae` | Use matching VAE |
 | Qwen3-0.6B-Base | [Safetensors](https://huggingface.co/circlestone-labs/Anima/tree/main/split_files/text_encoders)<br>[GGUF](https://huggingface.co/mradermacher/Qwen3-0.6B-Base-GGUF/tree/main) | `--llm` | Use matching text encoder |
+| TAEHV for Wan 2.1 | [taew2_1.safetensors](https://github.com/madebyollin/taehv/blob/main/safetensors/taew2_1.safetensors) | `--taesd` / `--tae` | Optional, faster decoding instead of `--vae`, with slightly softer fine detail |

 ## Usage

@@ -60,6 +61,11 @@ to validate syntax and types without loading weights. See the
 [shared run instructions](../dgl/README.md#run-an-example) for build paths
 and the server's file-access rules.

+### Anima Turbo
+
+Anima Turbo is a distilled variant in the same diffusion model folder. Use it
+with `--cfg-scale 1`, 8 to 12 steps, and the `euler` sampler.
+
 ### Legacy CLI

 CLI examples use the [shared path and shell conventions](README.md#example-conventions).
diff --git a/docs/models/taesd.md b/docs/models/taesd.md
index b22b358..ad8fb4f 100644
--- a/docs/models/taesd.md
+++ b/docs/models/taesd.md
@@ -8,11 +8,11 @@ previews. Choose the file matching the base model.
 | Component | Weights and downloads | CLI option | Requirement |
 | --- | --- | --- | --- |
 | TAESD | [Safetensors weights](https://huggingface.co/madebyollin/taesd/blob/main/diffusion_pytorch_model.safetensors) | `--taesd` / `--tae` | For compatible SD 1.x models |
-| TAEHV for Wan 2.1 | [taew2_1.safetensors](https://github.com/madebyollin/taehv/blob/main/safetensors/taew2_1.safetensors) | `--taesd` / `--tae` | Qwen Image, Wan 2.1, and Wan 2.2 A14B |
+| TAEHV for Wan 2.1 | [taew2_1.safetensors](https://github.com/madebyollin/taehv/blob/main/safetensors/taew2_1.safetensors) | `--taesd` / `--tae` | Qwen Image, Anima, Wan 2.1, and Wan 2.2 A14B |
 | TAEHV for Wan 2.2 5B | [taew2_2.safetensors](https://github.com/madebyollin/taehv/blob/main/safetensors/taew2_2.safetensors) | `--taesd` / `--tae` | Wan 2.2 TI2V 5B only |
 | TAEQI2.1 | [taeqi2_1.safetensors](https://huggingface.co/madebyollin/taeqi2_1/blob/main/taeqi2_1.safetensors) | `--taesd` / `--tae` | Qwen Image 2.1, including RGBA |

-### Qwen-Image and wan (TAEHV)
+### TAEHV (Qwen Image, Anima, and Wan)

 [TAEHV](https://github.com/madebyollin/taehv) provides tiny autoencoders for the
 model families in the table. Replace `--vae PATH` with `--taesd PATH` using the
diff --git a/examples/common/common.cpp b/examples/common/common.cpp
index 66b2b5d..b10e8dc 100644
--- a/examples/common/common.cpp
+++ b/examples/common/common.cpp
@@ -500,7 +500,7 @@ ArgOptions SDContextParams::get_options() {
          &hires_upscalers_dir},
         {"",
          "--tensor-type-rules",
-         "weight type per tensor pattern (example: \"^vae\\.=f16,model\\.=q8_0\")",
+         "weight type per tensor pattern (example: \"^text_encoders\\.=q8_0,^model\\.=q4_K\")",
          (int)',',
          &tensor_type_rules},
         {"",