From bf5fc81a8a3ad3e63415ce707f0fdb7113ec4772 Mon Sep 17 00:00:00 2001 From: slaren Date: Sun, 19 May 2024 17:08:46 +0200 Subject: [PATCH] ggml : fix another case of quants nans (llama/7387) --- ggml-quants.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml-quants.c b/ggml-quants.c index 7008e5d8..ff105986 100644 --- a/ggml-quants.c +++ b/ggml-quants.c @@ -1149,7 +1149,7 @@ static float make_qx_quants(int n, int nmax, const float * restrict x, int8_t * sumlx += w*x[i]*l; suml2 += w*l*l; } - float scale = sumlx/suml2; + float scale = suml2 ? sumlx/suml2 : 0.0f; if (return_early) return suml2 > 0 ? 0.5f*(scale + 1/iscale) : 1/iscale; float best = scale * sumlx; for (int is = -9; is <= 9; ++is) {