]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : skip loading unused tensors (#12004)
authorGeorgi Gerganov <redacted>
Fri, 21 Feb 2025 16:33:18 +0000 (18:33 +0200)
committerGitHub <redacted>
Fri, 21 Feb 2025 16:33:18 +0000 (18:33 +0200)
* llama : assign unknown/unused tensors to host buffer type

ggml-ci

* llama : skip unused tensors

ggml-ci

src/llama-model.cpp

index 0f4b62c434d4b3a8758a40f5df17c82ba9ee9c2d..f64c3afa029830da7ef77980460af2cb10f990e6 100644 (file)
@@ -1424,6 +1424,14 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
                 throw std::runtime_error(format("missing tensor info mapping for %s", tn.str().c_str()));
             }
 
+            // skip unused tensors
+            if (info.op == GGML_OP_NONE) {
+                LLAMA_LOG_WARN("model has unused tensor %s -- ignoring\n", tn.str().c_str());
+                ml.n_created++;
+
+                return nullptr;
+            }
+
             // tensors with "bias" suffix are always used with GGML_OP_ADD
             ggml_op op;
             bool bias = tn.suffix != nullptr && strcmp(tn.suffix, "bias") == 0;