From: Georgi Gerganov Date: Fri, 21 Feb 2025 16:33:18 +0000 (+0200) Subject: llama : skip loading unused tensors (#12004) X-Git-Tag: upstream/0.0.4853~100 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=51f311e057723b7454d0ebe20f545a1a2c4db6b2;p=pkg%2Fggml%2Fsources%2Fllama.cpp llama : skip loading unused tensors (#12004) * llama : assign unknown/unused tensors to host buffer type ggml-ci * llama : skip unused tensors ggml-ci --- diff --git a/src/llama-model.cpp b/src/llama-model.cpp index 0f4b62c4..f64c3afa 100644 --- a/src/llama-model.cpp +++ b/src/llama-model.cpp @@ -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;