Skip to content

Commit fc0cae1

Browse files
authored
Update ggml-quants.c
1 parent a0e584d commit fc0cae1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ggml-quants.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11543,6 +11543,7 @@ static void quantize_row_iq1_s_impl(const float * restrict x, void * restrict vy
1154311543

1154411544
float scales[QK_K/IQ1S_BLOCK_SIZE];
1154511545
float weight[IQ1S_BLOCK_SIZE];
11546+
float waux[IQ1S_BLOCK_SIZE];
1154611547
int8_t L[IQ1S_BLOCK_SIZE];
1154711548
float sumx[IQ1S_BLOCK_SIZE+1];
1154811549
float sumw[IQ1S_BLOCK_SIZE+1];
@@ -11562,12 +11563,13 @@ static void quantize_row_iq1_s_impl(const float * restrict x, void * restrict vy
1156211563
const float * xbl = x + QK_K*ibl;
1156311564
float sumx2 = 0;
1156411565
for (int i = 0; i < QK_K; ++i) sumx2 += xbl[i]*xbl[i];
11565-
float sigma2 = 2*sumx2/QK_K;
11566+
float sigma2 = sumx2/QK_K;
1156611567

1156711568
for (int ib = 0; ib < QK_K/IQ1S_BLOCK_SIZE; ++ib) {
1156811569
const float * xb = xbl + IQ1S_BLOCK_SIZE*ib;
1156911570
const float * qw = quant_weights + QK_K*ibl + IQ1S_BLOCK_SIZE*ib;
1157011571
for (int i = 0; i < IQ1S_BLOCK_SIZE; ++i) weight[i] = qw[i] * sqrtf(sigma2 + xb[i]*xb[i]);
11572+
for (int i = 0; i < IQ1S_BLOCK_SIZE; ++i) waux[i] = sqrtf(weight[i]);
1157111573
float max = fabsf(xb[0]);
1157211574
for (int i = 1; i < IQ1S_BLOCK_SIZE; ++i) max = MAX(max, fabsf(xb[i]));
1157311575
if (!max) {
@@ -11629,7 +11631,7 @@ static void quantize_row_iq1_s_impl(const float * restrict x, void * restrict vy
1162911631
if (grid_index < 0) {
1163011632
all_on_grid = false;
1163111633
const uint16_t * neighbours = kneighbors_q2xs - kmap_q2xs[u] - 1;
11632-
grid_index = iq1_find_best_neighbour2(neighbours, kgrid_q2xs, xb + 8*k, weight + 8*k, scale, xx, L + 8*k, NGRID_IQ1S);
11634+
grid_index = iq1_find_best_neighbour2(neighbours, kgrid_q2xs, xb + 8*k, waux + 8*k, scale, xx, L + 8*k, NGRID_IQ1S);
1163311635
GGML_ASSERT(grid_index >= 0);
1163411636
}
1163511637
index[k] = grid_index;

0 commit comments

Comments
 (0)