From 74644b6d249644d79c9a2921590b04c5ad5748b1 Mon Sep 17 00:00:00 2001 From: quantumaikr Date: Thu, 9 Apr 2026 00:12:10 +0900 Subject: [PATCH] Fix Windows MSVC build: hoist CB*_I8_RECIP out of __ARM_NEON guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 11 introduced three int8 codebook reciprocal constants (CB3_I8_RECIP, CB_I8_RECIP, CB5_I8_RECIP) inside #ifdef __ARM_NEON blocks, but the per_block_scale computation that uses them lives *outside* the guard and runs on every platform. NEON builds happened to compile; MSVC x64 errored with C2065 undeclared identifier on tq_turbo_kv.c lines 365, 585, 1324. These are plain `static const float`s, not NEON-typed — hoist them out of the guards so all platforms see the declarations. No behavior change. Fixes 8 consecutive Windows CI failures since Round 10. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/core/tq_turbo_kv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/tq_turbo_kv.c b/src/core/tq_turbo_kv.c index d32fd59..3794a8b 100644 --- a/src/core/tq_turbo_kv.c +++ b/src/core/tq_turbo_kv.c @@ -339,10 +339,11 @@ void tq_turbo_kv_3b_attention_ref(const float* query, const void* kv_cache, * 3-bit codebook has 8 entries which fit in 8 bytes — store in lower half * of a 16-byte register. Indices in 0-7. */ const float* cb = tq_codebook_centroids(3); + /* Used by both NEON and scalar paths — keep outside the NEON guard. */ + static const float CB3_I8_RECIP = 2.1520f / 127.0f; #ifdef __ARM_NEON static int8_t s_cb3_i8[16] = {0}; static int s_cb3_i8_init = 0; - static const float CB3_I8_RECIP = 2.1520f / 127.0f; if (!s_cb3_i8_init) { for (int j = 0; j < 8; j++) { float v = cb[j] * (127.0f / 2.1520f); @@ -559,11 +560,12 @@ void tq_turbo_kv_4b_attention_ref(const float* query, const void* kv_cache, * scale gives 16-element processing per ~10 NEON instructions vs * the previous ~32 scalar instructions. */ + /* Used by both NEON and scalar paths — keep outside the NEON guard. */ + static const float CB_I8_RECIP = 2.7326f / 127.0f; /* fp32 = int8 * recip */ #ifdef __ARM_NEON /* Static int8 codebook (computed once at startup; safe across blocks) */ static int8_t s_cb_i8[16] = {0}; static int s_cb_i8_init = 0; - static const float CB_I8_RECIP = 2.7326f / 127.0f; /* fp32 = int8 * recip */ if (!s_cb_i8_init) { for (int j = 0; j < 16; j++) { float v = cb[j] * (127.0f / 2.7326f); @@ -1299,10 +1301,11 @@ void tq_turbo_kv_5b_attention_ref(const float* query, const void* kv_cache, * within regression test thresholds). */ const float* cb = tq_codebook_centroids(5); + /* Used by both NEON and scalar paths — keep outside the NEON guard. */ + static const float CB5_I8_RECIP = 1.9956f / 127.0f; /* 5-bit max centroid */ #ifdef __ARM_NEON static int8_t s_cb5_i8[32] = {0}; static int s_cb5_i8_init = 0; - static const float CB5_I8_RECIP = 1.9956f / 127.0f; /* 5-bit max centroid */ if (!s_cb5_i8_init) { for (int j = 0; j < 32; j++) { float v = cb[j] * (127.0f / 1.9956f);