mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 19:04:50 +07:00
[PR #10] [MERGED] Prompt attention on the tensor cores for Turing: the context in the accumulator registers (58368 bytes) #277
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#277
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/10
Author: @dummerjindabin
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @mw00
Base:
main← Head:turing-tensor-core-prefill📝 Commits (1)
1b97b71Prompt attention on the tensor cores for Turing: the context stays in the accumulator registers📊 Changes
1 file changed (+34 additions, -19 deletions)
View changed files
📝
src/kernels/cuda/glm_batch.cu(+34 -19)📄 Description
The second half of #8, as you asked. The crash fix (the FP16 latents) is already in v1.0.7, so this is one commit, not two - the reason for the split was "ship the crash fix first if the tensor-core change needs more checking", and that is what happened.
The problem
mla_attn_tc_kernelasked for 91,136 bytes of dynamic shared memory a block (sO 32 KB + sQ 16 KB + sL 32 KB + sPart 8 KB + sP 1 KB) against Turing's 65,536 ceiling. The opt-in failed,tc_okwent -1, and sm_75 silently ran the F32 kernel, so the faster prefill never reached RTX 20-series.The change
The context O moves out of shared memory into the wmma accumulator fragments:
TC_OT = KV / 16 / 8; eight warps x 4 tiles x 16 = 512 = KV, so the tiles cover the context exactly once);lholds rowsl>>2inx[0],x[1],x[4],x[5]and rows(l>>2)+8inx[2],x[3],x[6],x[7]- that is where the per-row factors go;ctxat the end, and a__syncthreads()before the row normalization makes sure every warp's tiles are there first (the F32 kernel normalizes by row).Shared memory a block: 91,136 -> 58,368 bytes (16x512x2 + 32x512x2 + 4x16x32x4 + 16x32x2). That still needs the opt-in, but 58,368 <= 65,536, so Turing grants it - and on Volta (96 KB) the kernel is unchanged, with more room left over.
Measured here
2x Titan RTX (sm_75, driver 610.57.04, CUDA 13.0 build), Maya-S IQ2_XXS, 96K context, one 18,476-token prompt, greedy. The engine logs which prompt kernel it picked -
glm_batch: CUDA0 prompt attention on the F32 coresvs... on the tensor cores- so the A/B below is not a guess about what ran:STRATA_GLM_PREFILL_ATTN=f32(what Turing ran before this patch)STRATA_GLM_PREFILL_ATTN_CHECK=1(run on top of v1.0.8), over all 110 chunk checks:rel L2 5.3e-5 .. 1.6e-4(median 1.1e-4),worst head 2.5e-4 .. 1.3e-3(median 6.4e-4). Your V100 run quoted rel L2 ~7e-5 / worst head ~4e-4: the medians sit in the same band, the tail here is a little wider.invalid argument/illegal memory access/planned 0 of ... routed rowslines. Before v1.0.7 the same prompt never computed attention at all.To reproduce: run the same prompt twice, once with
STRATA_GLM_PREFILL_ATTN=f32and once without it (or use--bench), addSTRATA_GLM_PREFILL_ATTN_CHECK=1for the numeric comparison, and grep the engine log forprompt attention on the,glm stat:andattention check.What I could not test
There is no sm_70 card here, so the V100 run you described is still the gate. The register rescale uses the same m16n16k16 f32 accumulator layout on sm_70 and sm_75, but I have only verified sm_75. I did not add a test:
STRATA_GLM_PREFILL_ATTN_CHECK=1is the comparison this kernel needs, and the repo's parity tests are CPU/HIP-side. I also leftCHANGELOG.mdalone, since releases look like your call.Rebase against #7
I merged #7 into this branch to check the rebase you mentioned: the conflicts are
CMakeLists.txt,README.mdandsrc/kernels/cuda/glm_batch.cu- and merging #7 into plainmain(83f0fbb) gives exactly the same three, so this patch adds no new conflict surface. The only place they meet is the TC kernel, which #7 wraps in#if !defined(STRATA_USE_HIP)(it is CUDA-only there anyway); if #7 lands first, this is a two-line rebase.Raw evidence (engine log and journal, 2x Titan RTX)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.