[PR #457] [CLOSED] GLM decode attention: take-two kernels for the indexer's scores and MLA's split attention (opt-in, bit for bit), glm_attn_bench #536

Closed
opened 2026-10-29 21:26:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/457
Author: @pepuscz
Created: 10/24/2026
Status: ❌ Closed

Base: main ← Head: pr/glm-attn-take-two-v1126


📝 Commits (10+)

  • a5350cf GLM experts: IQ2_S gate/up on the tuned RDNA kernel, opt-in (MAYA_GLM_GU22_TUNED=1)
  • e6cd86e GLM experts: the engine logs which kernel IQ2_S gate/up ran, once per GPU and call path (Codex's review)
  • 0507d3b GLM experts: the engine logs which dense GEMV kernels each GPU's decode runs, once per GPU
  • c6db566 GLM fast path: the stage profiler splits the indexer's score from its top-k select and MLA into its three steps
  • e20d99b GLM decode attention: take-two kernels for the indexer's scores and MLA's split attention (opt-in, bit for bit), glm_attn_bench
  • 86ae92f glm_attn_bench: time every call against a working set past the 96 MB Infinity Cache, the rotation never restarting
  • f0772d1 glm_attn_bench: the reduction row fails on a non-finite sum or max too, and prints the count (Codex's review)
  • 4934849 GLM decode attention: the indexer label takes only the block counts the bench sweeps (2, 4, 8, 16) - every accepted label is a tested one (Codex)
  • 42921ce glm_attn_bench: MLA's timed cell sets are disjoint (one shuffled permutation of the pool's rows), the bytes a round reads printed (Codex)
  • 2e21847 glm_attn_bench: stdout line-buffered, so the engine's stderr records never land inside a row (C11 0400Z, raw line 354)

📊 Changes

8 files changed (+904 additions, -22 deletions)

View changed files

📝 CMakeLists.txt (+5 -0)
📝 docs/SETTINGS.md (+4 -1)
📝 include/strata/kernels/glm_expert_bench.hpp (+9 -0)
📝 include/strata/kernels/glm_fast.hpp (+13 -2)
📝 src/core/glm_fast_path.cu (+9 -5)
📝 src/core/glm_rows.cu (+2 -2)
📝 src/kernels/cuda/glm_fast.cu (+477 -12)
➕ tests/hip/glm_attn_bench.cu (+385 -0)

📄 Description

Builds on #455 and #456 (their commits are the first four here); review those first.

What. Two opt-in decode kernels, each selected by a label, each doing the original kernel's arithmetic in the same
order:

  • MAYA_GLM_DSA_SCORE2=<label>: the indexer's scores over the visible pools (32 heads x 128), [r|s][l|x][1|2]b [2|4|8|16] - the query in registers or LDS, the warp reduction across lanes (RDNA3 DPP) or by shuffles, one or two
    pools a warp, 2-16 blocks a multiprocessor.
  • MAYA_GLM_MLA_ATTN2=<label>: MLA's split attention over the selected latents, h<16|32|64>[l|x][v|e][c|o].

Only the decode's token path (and a decode row of several conversations) takes them; a prompt's windows keep the
original kernels. The variables are new names on purpose: STRATA_GLM_DSA_SCORE is already the prompt's numeric switch
in glm_batch.cu. The engine logs which kernels each GPU ran. tests/hip/glm_attn_bench.cu times every label against
the original on a working set past the 96 MB Infinity Cache and checks each one bit for bit.

Changes. src/kernels/cuda/glm_fast.cu, src/core/glm_fast_path.cu, src/core/glm_rows.cu,
include/strata/kernels/glm_fast.hpp, glm_expert_bench.hpp, tests/hip/glm_attn_bench.cu, CMakeLists.txt,
docs/SETTINGS.md.

Verified (Maya-M; RX 7900 XTX gfx1100):

  • glm_attn_bench: all 32 indexer and 24 MLA labels exact; rl1b8 250.2 -> 57.7 µs (4.34x), h32lvc 201.7 -> 143.9 µs
    (1.40x).
  • Same binary, two loads an arm, the 130,397-token near-full prompt: decode 55.5 / 55.8 tok/s with rl1b8 +
    h32lvc against 52.4 / 52.4 without (+6.2 %); prefill unchanged (927.4 vs 927.1); all five values, the same answer.
  • Logits through the engine, a 4,064-token pair (the last 32 positions on the token path) and a short pair:
    byte-identical with and without the labels.
  • On v1.1.26 (this PR with A-C, built together as pr/glm-union-v1126 30f93cf): the same two logits pairs, original
    against take-two, are byte-identical again (32 rows each), with all 365 intermediate dumps of the long pair identical,
    and the same hashes as on v1.1.25.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/457 **Author:** [@pepuscz](https://github.com/pepuscz) **Created:** 10/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/glm-attn-take-two-v1126` --- ### 📝 Commits (10+) - [`a5350cf`](https://github.com/mw00/project-maya/commit/a5350cf041ed6b0bc46c9d6112f3d04ea910c975) GLM experts: IQ2_S gate/up on the tuned RDNA kernel, opt-in (MAYA_GLM_GU22_TUNED=1) - [`e6cd86e`](https://github.com/mw00/project-maya/commit/e6cd86e9fb8f1d06ad29ce17d3ebc79cdf3c0895) GLM experts: the engine logs which kernel IQ2_S gate/up ran, once per GPU and call path (Codex's review) - [`0507d3b`](https://github.com/mw00/project-maya/commit/0507d3b5d2bc27dc59a5571283f9e74c67f4d0f3) GLM experts: the engine logs which dense GEMV kernels each GPU's decode runs, once per GPU - [`c6db566`](https://github.com/mw00/project-maya/commit/c6db566727728a33439b49671d6853063058d188) GLM fast path: the stage profiler splits the indexer's score from its top-k select and MLA into its three steps - [`e20d99b`](https://github.com/mw00/project-maya/commit/e20d99b8199541353187aa792de068ffb5e26d4c) GLM decode attention: take-two kernels for the indexer's scores and MLA's split attention (opt-in, bit for bit), glm_attn_bench - [`86ae92f`](https://github.com/mw00/project-maya/commit/86ae92f1073334210b5fdc5b81ee69383b339bec) glm_attn_bench: time every call against a working set past the 96 MB Infinity Cache, the rotation never restarting - [`f0772d1`](https://github.com/mw00/project-maya/commit/f0772d16ab8a42f8e4545709605b87005fa058b3) glm_attn_bench: the reduction row fails on a non-finite sum or max too, and prints the count (Codex's review) - [`4934849`](https://github.com/mw00/project-maya/commit/49348497ac494f26184640edea05f051e2c90b47) GLM decode attention: the indexer label takes only the block counts the bench sweeps (2, 4, 8, 16) - every accepted label is a tested one (Codex) - [`42921ce`](https://github.com/mw00/project-maya/commit/42921ced3635d7fc2ef19c5e376d0c977ec996ea) glm_attn_bench: MLA's timed cell sets are disjoint (one shuffled permutation of the pool's rows), the bytes a round reads printed (Codex) - [`2e21847`](https://github.com/mw00/project-maya/commit/2e2184771c9e815223d9229fdec95b210646240c) glm_attn_bench: stdout line-buffered, so the engine's stderr records never land inside a row (C11 0400Z, raw line 354) ### 📊 Changes **8 files changed** (+904 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+5 -0) 📝 `docs/SETTINGS.md` (+4 -1) 📝 `include/strata/kernels/glm_expert_bench.hpp` (+9 -0) 📝 `include/strata/kernels/glm_fast.hpp` (+13 -2) 📝 `src/core/glm_fast_path.cu` (+9 -5) 📝 `src/core/glm_rows.cu` (+2 -2) 📝 `src/kernels/cuda/glm_fast.cu` (+477 -12) ➕ `tests/hip/glm_attn_bench.cu` (+385 -0) </details> ### 📄 Description Builds on #455 and #456 (their commits are the first four here); review those first. **What.** Two opt-in decode kernels, each selected by a label, each doing the original kernel's arithmetic in the same order: - `MAYA_GLM_DSA_SCORE2=<label>`: the indexer's scores over the visible pools (32 heads x 128), `[r|s][l|x][1|2]b [2|4|8|16]` - the query in registers or LDS, the warp reduction across lanes (RDNA3 DPP) or by shuffles, one or two pools a warp, 2-16 blocks a multiprocessor. - `MAYA_GLM_MLA_ATTN2=<label>`: MLA's split attention over the selected latents, `h<16|32|64>[l|x][v|e][c|o]`. Only the decode's token path (and a decode row of several conversations) takes them; a prompt's windows keep the original kernels. The variables are new names on purpose: `STRATA_GLM_DSA_SCORE` is already the prompt's numeric switch in `glm_batch.cu`. The engine logs which kernels each GPU ran. `tests/hip/glm_attn_bench.cu` times every label against the original on a working set past the 96 MB Infinity Cache and checks each one bit for bit. **Changes.** `src/kernels/cuda/glm_fast.cu`, `src/core/glm_fast_path.cu`, `src/core/glm_rows.cu`, `include/strata/kernels/glm_fast.hpp`, `glm_expert_bench.hpp`, `tests/hip/glm_attn_bench.cu`, `CMakeLists.txt`, `docs/SETTINGS.md`. **Verified** (Maya-M; RX 7900 XTX gfx1100): - glm_attn_bench: all 32 indexer and 24 MLA labels exact; `rl1b8` 250.2 -> 57.7 µs (4.34x), `h32lvc` 201.7 -> 143.9 µs (1.40x). - Same binary, two loads an arm, the 130,397-token near-full prompt: decode **55.5 / 55.8 tok/s** with `rl1b8` + `h32lvc` against **52.4 / 52.4** without (+6.2 %); prefill unchanged (927.4 vs 927.1); all five values, the same answer. - Logits through the engine, a 4,064-token pair (the last 32 positions on the token path) and a short pair: byte-identical with and without the labels. - On v1.1.26 (this PR with A-C, built together as `pr/glm-union-v1126` 30f93cf): the same two logits pairs, original against take-two, are byte-identical again (32 rows each), with all 365 intermediate dumps of the long pair identical, and the same hashes as on v1.1.25. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:32 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#536
No description provided.