Skip to content

Commit 515df20

Browse files
danbevggerganov
authored andcommitted
ggml-quants : rename best_mad to best_error (ggml/1283)
This commit renames the variable `best_mad` to `best_error` in the `make_qkx2_quants` function. The motivation for this is that the name `best_mad` can be somewhat confusing if mean absolute deviation (MAD) is not in use.
1 parent c88ffbf commit 515df20

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ggml/src/ggml-quants.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,14 @@ static float make_qkx2_quants(int n, int nmax, const float * GGML_RESTRICT x, co
568568
}
569569
float iscale = nmax/(max - min);
570570
float scale = 1/iscale;
571-
float best_mad = 0;
571+
float best_error = 0;
572572
for (int i = 0; i < n; ++i) {
573573
int l = nearest_int(iscale*(x[i] - min));
574574
L[i] = MAX(0, MIN(nmax, l));
575575
float diff = scale * L[i] + min - x[i];
576576
diff = use_mad ? fabsf(diff) : diff * diff;
577577
float w = weights[i];
578-
best_mad += w * diff;
578+
best_error += w * diff;
579579
}
580580
if (nstep < 1) {
581581
*the_min = -min;
@@ -601,18 +601,18 @@ static float make_qkx2_quants(int n, int nmax, const float * GGML_RESTRICT x, co
601601
this_min = 0;
602602
this_scale = sum_xl / sum_l2;
603603
}
604-
float mad = 0;
604+
float cur_error = 0;
605605
for (int i = 0; i < n; ++i) {
606606
float diff = this_scale * Laux[i] + this_min - x[i];
607607
diff = use_mad ? fabsf(diff) : diff * diff;
608608
float w = weights[i];
609-
mad += w * diff;
609+
cur_error += w * diff;
610610
}
611-
if (mad < best_mad) {
611+
if (cur_error < best_error) {
612612
for (int i = 0; i < n; ++i) {
613613
L[i] = Laux[i];
614614
}
615-
best_mad = mad;
615+
best_error = cur_error;
616616
scale = this_scale;
617617
min = this_min;
618618
}

0 commit comments

Comments
 (0)