From 7cbe1eac78588f2b7f9a6ee0f7f56d0dc68611d7 Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Fri, 22 Mar 2024 06:48:15 +0100 Subject: [PATCH] llama_model_loader: if n_tensors declared not equals to loaded tensors in split, throw an exception instead of asserting --- llama.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index f0c187f9a..c129b1640 100644 --- a/llama.cpp +++ b/llama.cpp @@ -2919,7 +2919,10 @@ struct llama_model_loader { gguf_free(ctx_gguf); } get_key(llm_kv(LLM_KV_SPLIT_TENSORS_COUNT), n_tensors); - GGML_ASSERT(n_tensors == (int) weights.size()); + int n_tensors_loaded = (int) weights.size(); + if (n_tensors != n_tensors_loaded) { + throw std::runtime_error(format("corrupted model: %d tensors expected but %d found", n_tensors, n_tensors_loaded)); + } LLAMA_LOG_INFO("%s: additional %d GGUFs metadata loaded.\n", __func__, n_split); }