mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #459] [MERGED] GLM decode on Volta: the MLA attention on the tensor cores (mma.m8n8k4) - attention 4.3x, decode +3-6% on a V100 #537
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#537
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/459
Author: @merbanan
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @mw00
Base:
main← Head:pr/mla-decode-v70📝 Commits (1)
b2ddf05GLM decode: the MLA attention on Volta's tensor cores - the prompts' one-pass kernel (mma.m8n8k4) in cell splits (MAYA_GLM_MLA_V70, on by default on sm_70/72; =0: the F32 split kernel)📊 Changes
4 files changed (+146 additions, -17 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -0)📝
include/strata/kernels/glm_batch.hpp(+5 -0)📝
src/kernels/cuda/glm_batch.cu(+131 -17)📝
src/kernels/cuda/glm_fast.cu(+9 -0)📄 Description
What
On Volta (sm_70 / sm_72), the GLM decode ran its sparse MLA attention on the CUDA cores.
mla_mma_on()is sm_80+ only, because its kernel needsmma.m16n8k16. So every decode token used the F32 split kernel, once per DSA layer: on a V100, 192 µs a call plus a 43 µs combine, about 2.6 ms of every token.This PR runs the decode attention on Volta's tensor cores. It reuses the prompts' one-pass Volta kernel,
mla_attn_v70_kernelfrom #335: wmma Q·Kᵀ, online softmax, then P·V onmma.m8n8k4with O in registers.SPLITinstantiation of that kernel. It takes one token's selected cells in splits of whole 32-cell tiles, about one block per multiprocessor across the head groups. Each split writes its unnormalised context and its heads' max and sum into the decode's existing partial buffer (mla_part), so no new VRAM is needed at decode time.mla_dec_combine_kernelmerges the splits: a block per (head, 128 columns).SPLIT = false) does the same arithmetic as before. The decode tail sits behindif constexpr.tools/check_hip_compat.pypasses).MAYA_GLM_MLA_V70is on by default on sm_70/72;=0gives the F32 split kernel.MAYA_GLM_MLA_V70_SPLITSsets the splits per head group. Both have a row indocs/SETTINGS.md.Exactness
The kernel is not bit for bit the F32 kernel. Q and the softmax weights enter the tensor cores as FP16, with F32 sums. It is deterministic: repeated runs give identical tokens.
KL against the F32 kernel, with the CPU lane off and a fixed RAM tier, teacher-forced, the last 256 positions decoded:
The first decoded positions differ by about 3e-5. Most of the KL is the small difference carried forward through the recurrent state.
I also tried a variant that splits Q and P into FP16 high + low parts, two products each, as
mla_split_mma_kerneldoes. It gave the same KL (0.0088 vs 0.0086), so the remaining difference is summation order, not FP16 rounding, and this PR keeps the cheaper form.Speed
Measured on a Tesla V100-PCIE-32GB at 250 W with a Ryzen 9 7950X and the Maya-S-v2 IQ2_XXS pack.
The attention, per DSA layer (nvprof, 8K prompt + 512 decoded tokens):
=0)Decode, deterministic (CPU lane off,
MAYA_GLM_RAM_GB=50, 4 alternating rounds, 512 tokens, ms per token, mean with range):=0Every round with the change was faster than every round without it.
Decode, as served (the default CPU lane, 3 alternating rounds, 256 tokens, tok/s): 2K 20.9 → 21.5, 8K 25.4 → 26.5, 27K 24.1 → 25.4. That is +2.6 / +4.4 / +5.7 %, and every round with the change was faster at 2K and 8K. This setting varies about ±2 % from run to run.
The same A/B with turboderp's EXL3 2.05bpw quant: 22.8 → 23.3 / 24.1 → 25.1 / 24.0 → 25.2 tok/s (+2.2 / +3.9 / +5.1 %). The attention does not depend on the expert format.
Prompt speed is unchanged.
Not run on other Volta parts (Titan V, sm_72) or on other cards; off Volta the code path is not taken.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.