From: slaren Date: Sun, 19 May 2024 15:08:46 +0000 (+0200) Subject: ggml : fix another case of quants nans (llama/7387) X-Git-Tag: upstream/0.0.1642~669 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=2a1c455d32393d4dcb580cdebd2d9404aa32c434;p=pkg%2Fggml%2Fsources%2Fggml ggml : fix another case of quants nans (llama/7387) --- diff --git a/src/ggml-quants.c b/src/ggml-quants.c index 7008e5d8..ff105986 100644 --- a/src/ggml-quants.c +++ b/src/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) {