slaren commited on
Commit
645c367
·
1 Parent(s): aef1b4b

ggml : fix another case of quants nans (llama/7387)

Browse files
Files changed (1) hide show
  1. ggml-quants.c +1 -1
ggml-quants.c CHANGED
@@ -1149,7 +1149,7 @@ static float make_qx_quants(int n, int nmax, const float * restrict x, int8_t *
1149
  sumlx += w*x[i]*l;
1150
  suml2 += w*l*l;
1151
  }
1152
- float scale = sumlx/suml2;
1153
  if (return_early) return suml2 > 0 ? 0.5f*(scale + 1/iscale) : 1/iscale;
1154
  float best = scale * sumlx;
1155
  for (int is = -9; is <= 9; ++is) {
 
1149
  sumlx += w*x[i]*l;
1150
  suml2 += w*l*l;
1151
  }
1152
+ float scale = suml2 ? sumlx/suml2 : 0.0f;
1153
  if (return_early) return suml2 > 0 ? 0.5f*(scale + 1/iscale) : 1/iscale;
1154
  float best = scale * sumlx;
1155
  for (int is = -9; is <= 9; ++is) {