From c637fcd34d135a9ff4f97d3a53ad03a910a4a31f Mon Sep 17 00:00:00 2001 From: Frank Mai Date: Mon, 17 Jun 2024 22:11:08 +0800 Subject: [PATCH] fix: divide 0 exception in mamba (#7932) Signed-off-by: thxCode --- llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index b324807f8..dd7020dc0 100644 --- a/llama.cpp +++ b/llama.cpp @@ -5383,7 +5383,7 @@ static bool llm_load_tensors( // create tensors for the weights { const int64_t n_embd = hparams.n_embd; - const int64_t n_embd_head = n_embd / hparams.n_head; + const int64_t n_embd_head = (hparams.n_head == 0) ? 0 : n_embd / hparams.n_head; const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(); const int64_t n_embd_v_gqa = hparams.n_embd_v_gqa(); const int64_t n_embd_gqa = n_embd_v_gqa;