From 79f17576611ddf6d16c28728cb82ba8e2c96ce0c Mon Sep 17 00:00:00 2001 From: Iwan Kawrakow Date: Mon, 4 Sep 2023 14:10:15 +0300 Subject: [PATCH] Guard against all weights in a super-block being zero --- k_quants.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/k_quants.c b/k_quants.c index 4accd2480..446917e20 100644 --- a/k_quants.c +++ b/k_quants.c @@ -1086,6 +1086,12 @@ void quantize_row_q6_K_reference(const float * restrict x, block_q6_K * restrict } + if (!max_abs_scale) { + memset(&y[i], 0, sizeof(block_q6_K)); + y[i].d = ggml_fp32_to_fp16(0.f); + continue; + } + float iscale = -128.f/max_scale; y[i].d = ggml_fp32_to_fp16(1/iscale); for (int ib = 0; ib < QK_K/16; ++ib) {