Skip to content

Commit cddaf02

Browse files
authored
ggml : fix handling of zero blocks in IQ quants (#7955)
ggml-ci
1 parent c8a8219 commit cddaf02

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ggml-quants.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13139,7 +13139,7 @@ static int iq1_find_best_neighbour(const uint16_t * restrict neighbours, const u
1313913139
const float * restrict xval, const float * restrict weight, float * scale, int8_t * restrict L, int ngrid) {
1314013140
int num_neighbors = neighbours[0];
1314113141
GGML_ASSERT(num_neighbors > 0);
13142-
float best_score = 0;
13142+
float best_score = -FLT_MAX;
1314313143
int grid_index = -1;
1314413144
for (int j = 1; j <= num_neighbors; ++j) {
1314513145
const int8_t * pg = (const int8_t *)(grid + neighbours[j]);
@@ -13337,7 +13337,7 @@ static void quantize_row_iq1_s_impl(const float * restrict x, void * restrict vy
1333713337
sumw[j+1] = sumw[j] + weight[i];
1333813338
}
1333913339
}
13340-
float best_score = 0, scale = max;
13340+
float best_score = -FLT_MIN, scale = max;
1334113341
int besti1 = -1, besti2 = -1, best_shift = 0;
1334213342
for (int i1 = 0; i1 <= block_size; ++i1) {
1334313343
for (int i2 = i1; i2 <= block_size; ++i2) {
@@ -13513,7 +13513,7 @@ static void quantize_row_iq1_m_impl(const float * restrict x, void * restrict vy
1351313513
idx[2*j] = j;
1351413514
}
1351513515
qsort(pairs, block_size, 2*sizeof(float), iq1_sort_helper);
13516-
float best_score = 0, scale = max;
13516+
float best_score = -FLT_MIN, scale = max;
1351713517
int besti1 = -1, besti2 = -1, best_k = -1;
1351813518
// 0: +, +
1351913519
// 1: +, -

0 commit comments

Comments
 (0)