mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 19:04:50 +07:00
[PR #335] [MERGED] GLM prompt attention on Volta in one pass (mma.m8n8k4): long prompts +8-9% on a V100 #473
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#473
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/335
Author: @merbanan
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @mw00
Base:
main← Head:pr/mla-attn-v70📝 Commits (1)
8aaf0caGLM prompt attention on Volta in one pass (mma.m8n8k4): 27K prompts +9% on a V100📊 Changes
2 files changed (+191 additions, -2 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -1)📝
src/kernels/cuda/glm_batch.cu(+190 -1)📄 Description
What
On Volta, GLM's prompt attention (
mla_attn_tc2_kernel) walks each token's selected cells twice. The first pass does the gather and Q·Kᵀ to get the softmax's max and sum; the second does them again to get P. It needs two passes because a wmma accumulator's layout isn't known on Volta, so the context can't be rescaled in registers.mla_attn_v70_kerneldoes it in one pass, usingmma.sync.m8n8k4, whose layout is known:mma.m8n8k4, with the context in registers (64 floats a lane) and rescaled there each tile;cp.async).It uses 202 registers with no spills. It is the default on sm_70 / sm_72.
STRATA_GLM_PREFILL_ATTN=tc2(orMAYA_GLM_PREFILL_ATTN=tc2) runs the two-pass kernel. The other architectures are unchanged. The kernel body is guarded for Pascal the same way tc2's is. Its row in docs/SETTINGS.md is updated.The one-pass design follows 1CatAI/1Cat-vLLM #1092 / #1125 (FP32 scores and softmax, FP16 operands, F32 sums). The code is new.
Measured
One Tesla V100-PCIE-32GB with a 7950X and 62 GB of RAM, GLM-5.3-Flash Maya-S24,
STRATA_GLM_PREFILL_SUB=1024. Same build (main v1.1.19 + this PR), two rounds each,tc2vs the new default. Each run is a fresh request: a prompt of N tokens, then 128 greedy tokens.Profile of a 27K prompt (
STRATA_GLM_PREFILL_PROF=1):dsa_attngoes from 6.87 s to 4.09 s.The output changes slightly. It's a different summation order, as any rewrite of the attention would be.
STRATA_GLM_PREFILL_ATTN_CHECK=1, rel L2 against the FP32 kernel is 8.6–9.5e-5 (tc2: 4.4–5.2e-5).ab/longctx.py, Maya-S-v2 IQ2_XXS, 128K context, measured on our branch with the same kernel): 6 / 6 at haystacks of 40K and 100K, with tc2 and with the one-pass kernel. Prompt speed there goes from 695 / 698 to 743 / 753 tok/s.Decode right after a fresh long prompt comes out a little lower. After 27K: 24.8 / 26.0 vs 26.6 / 27.0 tok/s; after 8K: mixed. The kernel itself doesn't slow decode:
Builds: native (sm_70) for the run;
glm_batch.cualso compiled for sm_75 / 86 / 120.tools/check_hip_compat.pypasses.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.