Skip to content

tests: cover turbo KV flash attention at head dim 256 - #279

Closed
TheTom wants to merge 1 commit into
feature/turboquant-kv-cachefrom
tests/turbo-fa-head-dim-256
Closed

TheTom wants to merge 1 commit into
feature/turboquant-kv-cachefrom
tests/turbo-fa-head-dim-256

Conversation

@TheTom

@TheTom TheTom commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Closes the coverage gap behind #252.

Two filters compounded at test-backend-ops.cpp:10001-10002:

if ((type_KV == TURBO3_0 || type_KV == TURBO4_0) && hsk < 128) continue;
if (type_KV != F16 && hsk != 64 && hsk != 72 && hsk != 128) continue;

The first excludes below 128, the second admits only 64, 72 and 128 for non-f16 KV. Net effect: every turbo FLASH_ATTN_EXT case in the suite runs at hsk=hsv=128, and no other head dim has ever been exercised on any backend.

That is not a hypothetical shape. qwen35moe carries key_length = value_length = 256, which is the model @jasstrong reports turbo4-V corruption on in #252.

Result

224 new cases, all passing on CUDA (GB10, sm_121): FLASH_ATTN_EXT 7656/7656 to 7880/7880, zero failures.

So head dim 256 is correct on CUDA, which narrows #252 usefully:

hsk=128 hsk=256
CUDA (sm_121) 752 OK 224 OK
HIP (gfx1100) 528 OK, by @jasstrong untested

Three of the four squares are clean. The corruption lives in the remaining one, HIP at head dim 256, which is precisely what nothing covered.

I have no AMD hardware, so I cannot close the last square. @jasstrong this branch is what you offered to write; running it on gfx1100 should turn your full-inference corruption into a failing harness case.

Two filters compounded to confine turbo KV coverage to a single head dim:

  if (turbo && hsk < 128) continue;
  if (type_KV != F16 && hsk != 64 && hsk != 72 && hsk != 128) continue;

The first excludes below 128, the second admits only 64, 72 and 128 for any
non-f16 KV type, so every turbo FLASH_ATTN_EXT case in the suite runs at
hsk=hsv=128 and no other head dim has ever been exercised.

Head dim 256 is not hypothetical: qwen35moe carries key_length =
value_length = 256, and @jasstrong reports turbo4-V corruption on exactly that
model. Allow 256 for the turbo types.

Adds 224 cases, all passing on CUDA (GB10, sm_121): FLASH_ATTN_EXT goes
7656/7656 to 7880/7880. So the shape is correct on CUDA, which narrows #252 to
the HIP path at this head dim rather than head dim 256 in general.
@jasstrong

Copy link
Copy Markdown

Ran this on gfx1100 (RX 7900 XTX, ROCm 7.2.3) — the untested square.

turbo KV flash attention at head dim 256, matched type_K == type_V:

type_K / type_V hsk=256
turbo3 / turbo3 112 / 112 OK
turbo4 / turbo4 112 / 112 OK

Zero failures. Same result on a clean checkout of this branch with none of my downstream turboquant patches applied, so it's your tree — nothing local. The HIP + 256 square is green.

That actually closes my end of #252 rather than reproducing it. My corruption was on an old pin (c26cbdffc), and the head-dim-256 turbo fattn instances (fattn-mma-turbo-instance-dkq256-*, fattn-vec-instance-q8_0-turbo4_0) didn't exist there — git shows they were added since. On current HEAD they're present and correct on AMD, and the full-inference corruption is gone.

One coverage gap remains, and it's the exact shape a real deployment runs: the suite only emits type_K == type_V, but qwen35moe runs -ctk q8_0 -ctv turbo4 — mixed, which dispatches to a distinct instance (fattn-vec-instance-q8_0-turbo4_0). I added that case (q8_0 K, turbo4 V, hsk=256, incl. GQA nr=8 to match 16/2 heads) and ran it:

FLASH_ATTN_EXT(hsk=256,hsv=256,nh=4,nr23=[8,1],kv=113,nb=1..64,prec=f32,type_K=q8_0,type_V=turbo4): OK   (8/8)

So the mixed product is correct too. Happy to PR a type_K != type_V case (q8_0 K + turbo V at 256) so the mixed instance stays covered — it's the one shape real qwen35moe inference hits that matched-KV coverage misses.

@TheTom

TheTom commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

Closing. This existed to add hsk=256 turbo FA coverage so the #252 corruption would be reproducible in the suite. jasstrong has since confirmed that bug is fixed on current HEAD, so the coverage no longer pays for its cost here.

If the turbo K-cache spill work in #294 ends up needing hsk=256 shapes to validate a fix, this is easy to revive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants