From bf1c8d761ab0cc9862591aa8167d83ea8689ab56 Mon Sep 17 00:00:00 2001 From: Michael Potter Date: Sun, 12 Nov 2023 15:07:24 -0800 Subject: [PATCH] Update ggml-quants.c --- ggml-quants.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ggml-quants.c b/ggml-quants.c index 740be6dc5..42bf749e9 100644 --- a/ggml-quants.c +++ b/ggml-quants.c @@ -1273,7 +1273,8 @@ static float make_qkx2_quants(int n, int nmax, const float * restrict x, const f float max = x[0]; float sum_w = weights[0]; float sum_x = sum_w * x[0]; - for (int i = 1; i < n; ++i) { + // Mark i as volatile to prevent the -O3 optimizer from unrolling this loop and breaking MacOS Sonoma quantization + for (volatile int i = 1; i < n; ++i) { if (x[i] < min) min = x[i]; if (x[i] > max) max = x[i]; float w = weights[i];