Skip to content

Commit 7abf5be

Browse files
unamedkrclaude
andauthored
Fix Windows MSVC build: hoist CB*_I8_RECIP out of __ARM_NEON guard (#17)
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) <noreply@anthropic.com>
1 parent bb62094 commit 7abf5be

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/core/tq_turbo_kv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,11 @@ void tq_turbo_kv_3b_attention_ref(const float* query, const void* kv_cache,
339339
* 3-bit codebook has 8 entries which fit in 8 bytes — store in lower half
340340
* of a 16-byte register. Indices in 0-7. */
341341
const float* cb = tq_codebook_centroids(3);
342+
/* Used by both NEON and scalar paths — keep outside the NEON guard. */
343+
static const float CB3_I8_RECIP = 2.1520f / 127.0f;
342344
#ifdef __ARM_NEON
343345
static int8_t s_cb3_i8[16] = {0};
344346
static int s_cb3_i8_init = 0;
345-
static const float CB3_I8_RECIP = 2.1520f / 127.0f;
346347
if (!s_cb3_i8_init) {
347348
for (int j = 0; j < 8; j++) {
348349
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,
559560
* scale gives 16-element processing per ~10 NEON instructions vs
560561
* the previous ~32 scalar instructions.
561562
*/
563+
/* Used by both NEON and scalar paths — keep outside the NEON guard. */
564+
static const float CB_I8_RECIP = 2.7326f / 127.0f; /* fp32 = int8 * recip */
562565
#ifdef __ARM_NEON
563566
/* Static int8 codebook (computed once at startup; safe across blocks) */
564567
static int8_t s_cb_i8[16] = {0};
565568
static int s_cb_i8_init = 0;
566-
static const float CB_I8_RECIP = 2.7326f / 127.0f; /* fp32 = int8 * recip */
567569
if (!s_cb_i8_init) {
568570
for (int j = 0; j < 16; j++) {
569571
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,
12991301
* within regression test thresholds).
13001302
*/
13011303
const float* cb = tq_codebook_centroids(5);
1304+
/* Used by both NEON and scalar paths — keep outside the NEON guard. */
1305+
static const float CB5_I8_RECIP = 1.9956f / 127.0f; /* 5-bit max centroid */
13021306
#ifdef __ARM_NEON
13031307
static int8_t s_cb5_i8[32] = {0};
13041308
static int s_cb5_i8_init = 0;
1305-
static const float CB5_I8_RECIP = 1.9956f / 127.0f; /* 5-bit max centroid */
13061309
if (!s_cb5_i8_init) {
13071310
for (int j = 0; j < 32; j++) {
13081311
float v = cb[j] * (127.0f / 1.9956f);

0 commit comments

Comments
 (0)