fix(ggml): TurboQ rotate-block OOB — unbreaks Windows x64 CI#104
Merged
Conversation
turboq_rotate_block_forward/inverse looped to QK_K (256) while every caller (tbq3_0/tbq4_0 quantize + dequantize) passes TBQ_BLK_SIZE (128) float buffers — a 128-float OOB read+write per block. Confirmed with ASAN (heap-buffer-overflow in matvec_row via quantize_row_tbq3_0_ref) and the cause of the Windows x64 CI failures: test-quantize-fns SEGFAULT / test-quantize-perf 0xc0000374 (STATUS_HEAP_CORRUPTION). Loop bound fixed to TBQ_BLK_SIZE. No behavior change for the valid region: the extra iteration only produced the out-of-bounds garbage. test-quantize-fns + test-quantize-perf now pass under ASAN+UBSAN.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
windows (x64-cpu-static)has been red on every PR:test-quantize-fnsSEGFAULT andtest-quantize-perfexit0xc0000374(STATUS_HEAP_CORRUPTION). Linux legs passed silently.Root cause
turboq_rotate_block_forward/_inverseloop toQK_K(256) but all four callers (tbq3_0/tbq4_0 quantize + dequantize) passTBQ_BLK_SIZE(128) float buffers. Every call read and wrote 128 floats (512 bytes) past both scratch buffers. The Windows CRT heap checker trips on it; glibc doesn't, which is why Linux CI stayed green.ASAN confirms pre-fix:
Fix
Loop bound →
TBQ_BLK_SIZE. Zero behavior change for the valid region — the second iteration only produced out-of-bounds garbage (the rotation tiles inTURBOQ_KV_DIM=128 chunks, so the first iteration fully covers the block). May also be implicated in the broken TBQ KV-cache on CPU (ggml-org#125) — heap corruption next to every dequant call is a plausible mechanism; not yet validated.Validation
test-quantize-fns+test-quantize-perf: pass under ASAN+UBSAN (RelWithDebInfo, sm-agnostic CPU path) — pre-fix, fns aborts with the trace above.