Commit 3ab310b for stable-diffusion.cpp
commit 3ab310b0d23e504aa2ffa5d61c1317bc84f73510
Author: Pento <pentolo@outlook.com>
Date: Thu Dec 3 15:43:55 2026 +0100
fix: keep single-row weights unquantized when converting (#2500)
diff --git a/src/model_loader.cpp b/src/model_loader.cpp
index c7636e9..59a33b4 100644
--- a/src/model_loader.cpp
+++ b/src/model_loader.cpp
@@ -1680,6 +1680,10 @@ bool ModelLoader::tensor_should_be_converted(const TensorStorage& tensor_storage
if (type != GGML_TYPE_COUNT) {
if (ggml_is_quantized(type) && tensor_storage.ne[0] % ggml_blck_size(type) != 0) {
// Pass, do not convert
+ } else if (ggml_is_quantized(type) && tensor_storage.nelements() == tensor_storage.ne[0]) {
+ // Pass, do not convert. Single-row weights such as norm scales save almost no space when
+ // quantized, and each value scales a whole channel, so rounding errors do not average out.
+ // Checked by element count because GGUF loading drops trailing singleton dimensions.
} else if (ends_with(name, ".bias")) {
// Pass, do not convert
} else if (ends_with(name, ".scale")) {