Skip to content

test(core): add GPU tests for the attention kernels - #51

Merged
chmjkb merged 6 commits into
mainfrom
@chmjkb/gpu-suites-attention
Oct 22, 2026
Merged

chmjkb merged 6 commits into
mainfrom
@chmjkb/gpu-suites-attention

Conversation

@chmjkb

@chmjkb chmjkb commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Description

GPU suites for attn, attnDecode, attnFlash and rope, with a shared f64 reference in checkSdpa.ts (windows, GQA, sinks, segments, packed qkv).

kernel covered
attn rowsSubgroupSplit, rowsSplit, rows, batch, each with every option; headDim 1/200/512, chunk boundaries (96/97 keys, past 16 chunks), maxSegment on both sides of the chunk, past 65535 row-heads, split scratch past the binding limit, rows that see no key
attnDecode decode and decodeSplit, with and without subgroups, f32/f16; chunk thresholds, headDim 1/37/128, windows, sinks, MQA, 64 heads, two split calls in one submit
attnFlash headDim 16 to 512 (both lane counts and tile sizes), every option, partial workgroups, fallbacks on the no-subgroups device
rope slab slices, a hand-worked rotation, past GRID_Y_STRIDE

Known bugs found

  • decodeSplit with more than 64 query heads: heads 64+ come out 0 (scratch holds 64 heads, the merge runs one 64-thread workgroup). Repro: 72 q heads, 8 kv heads, kvLen 600.
  • attnFlash past 65535·16 rows: grid x passes the per-dimension limit, output is all zeros, no error. Repro: qLen 1048561, headDim 16.
  • batch attention past 2^24 row-heads and rope f16 past 2^24 pairs: the flat index is split with d.u32(a / b), which TypeGPU compiles to an f32 division.

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Performance (kernel tuning, graph building, anything related to performance)
  • Other (chores, tests, code style improvements etc.)

Testing instructions

  1. pnpm --filter runntime exec playwright install chromium (once per machine)
  2. pnpm --filter runntime test:gpu: 787 passed, 15 expected fail at this point in the stack

Screenshots

Related issues

Stack: 1. reduce → 2. attention → 3. shape + elementwise → 4. matmul → 5. conv + ssm. Related: #49 (empty tensor fix), #44 (same f32 index bug in tiled matmul).

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional notes

  • Tests only, no src/ changes. Each case says in a comment which route it takes and why; nothing asserts the route yet.
  • Every suite checks against a plain CPU loop written from the formula (or torch values where noted), plus wrong-dtype and bad-shape refusals.
  • Each suite has an empty-input case as it.fails. fix(core): reject an empty tensor with INVALID_ARGUMENT #49 fixes that bug; once it merges these flip to it in a follow-up commit at the bottom of the stack.
  • Known bugs found are it.fails with a comment naming the bug. None are fixed here.

@chmjkb
chmjkb marked this pull request as draft October 19, 2026 13:38
@chmjkb
chmjkb force-pushed the @chmjkb/gpu-suites-reduce branch from 8adb05a to 2cb6b71 Compare October 21, 2026 15:35
Base automatically changed from @chmjkb/gpu-suites-reduce to main October 22, 2026 12:50
Comment thread packages/runntime/test/core/kernels/attention/attn.gpu.test.ts Outdated
@chmjkb
chmjkb marked this pull request as ready for review October 22, 2026 13:50
@chmjkb
chmjkb force-pushed the @chmjkb/gpu-suites-attention branch from 56dcd14 to 2401469 Compare October 22, 2026 13:55
@chmjkb
chmjkb merged commit 7946988 into main Oct 22, 2026
2 checks passed
@chmjkb
chmjkb deleted the @chmjkb/gpu-suites-attention branch October 22, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants