[PR #388] [MERGED] GLM prompt: EXL3 experts' tensor-core path by chunk length, opt-in (MAYA_GLM_EXL3_MMA_ROWS_SHORT) #506

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/388
Author: @somnergy
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @mw00

Base: main ← Head: pr/glm-exl3-mma-short


📝 Commits (1)

  • 40dddb9 GLM prompt: EXL3 experts' tensor-core path by chunk length, opt-in (MAYA_GLM_EXL3_MMA_ROWS_SHORT)

📊 Changes

5 files changed (+91 additions, -4 deletions)

View changed files

📝 CMakeLists.txt (+3 -2)
📝 docs/SETTINGS.md (+1 -0)
➕ include/strata/core/exl3_mma_rows.hpp (+34 -0)
📝 src/core/glm_prefill.cu (+18 -2)
➕ tests/core/exl3_mma_rows_test.cpp (+35 -0)

📄 Description

Summary

In an EXL3 pack's prompt path, an expert routed more than MAYA_GLM_EXL3_MMA_ROWS (64) of a chunk's tokens is rebuilt to FP16 and multiplied by cuBLAS - a fixed cost per expert and chunk - while lighter ones go through the tensor-core kernels, whose cost grows with the rows. In short chunks most experts have tens to a few hundred rows and the rebuild is most of the MoE time; in long chunks the FP16 product is cheaper, so raising the switch for every chunk makes long reads slower.

MAYA_GLM_EXL3_MMA_ROWS_SHORT=<rows>[,<max chunk tokens>] (off by default) sends experts of up to <rows> rows to the tensor-core kernels in chunks of up to <max chunk tokens> (4096); longer chunks keep MAYA_GLM_EXL3_MMA_ROWS. 91 lines; decode unchanged.

Why

Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls) through the Anthropic Messages API with --parallel 8: most reads are short increments onto restored conversations - in a 45-minute sample, 95% of 319 reads had under 8K new tokens and a third under 512 - so short chunks are where the prompt time goes.

Measured

Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x8 from its own CPU root port (no fast P2P); Intel Core Ultra 9 285K; 96 GB DDR5; driver 615.71.09, CUDA 13.4. Model: GLM-5.3-Flash EXL3 sc 3.10 bpw, every expert in VRAM, 2-GPU split. Wall time per chunk on each GPU (ms):

chunk tokens default (64 rows) 192 rows 256 rows every expert on the tensor cores
1024 562 / 548 484 / 433 483 / 427 483 / 427
2048 1051 / 960 814 / 734 808 / 721 814 / 731
3072 1390 / 1275 1175 / 1074 1166 / 1052 1188 / 1070
7552 2477 / 2300 2606 / 2237 2638 / 2267 2863 / 2602

Whole reads with MAYA_GLM_EXL3_MMA_ROWS_SHORT=192 (these runs also cut reads into at least 4 chunks, #392), alone / with 3 requests decoding: 4K -15% / -14%, 8K -23% / -21%, 16K -16% / -15%, 2K -6% / -4%; 30K and a cold 60K read (chunks of 7-8K) unchanged. Without #392 a split reads up to 8192 tokens as one chunk, so the gain applies to reads of up to 4096 tokens (the first rows of the table).

Recommendation

With EXL3 packs, set MAYA_GLM_EXL3_MMA_ROWS_SHORT=192: short chunks get 14-24% faster and long chunks keep the default path (192 and 256 are within noise; 128 keeps most of the gain). It does nothing for GGUF / native packs (their prompt experts take MMQ). Leave it off if greedy output must match the setting off bit for bit. One GPU and experts streamed from RAM were not measured.

Exactness

Not bit-exact: the tensor-core kernels decode and accumulate in another order than the FP16 rebuild plus cuBLAS. With identical chunking and the switch at 192 rows, greedy tokens differed from the default after 0-22 tokens in 42 of 44 short-chunk reads. A read whose chunks are all longer than <max chunk tokens> takes the unchanged path: the cold 60K read gave identical tokens.

How it was verified

  • tests/core/exl3_mma_rows_test.cpp (CPU): the parse and the rows by chunk length (the base when off, for long chunks and an unknown length; the setting's rows for short chunks).
  • On v1.1.23 (this branch): builds (nvcc 13.4, sm_75 and sm_120); exl3_mma_rows_test passes on the box above; tools/check_hip_compat.py is clean.
  • The table and reads: the same change on v1.1.21, fresh engines, alone and with 3 greedy decoders; then several hours live with 8 conversations, 0 engine errors.

🔄 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/388 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr/glm-exl3-mma-short` --- ### 📝 Commits (1) - [`40dddb9`](https://github.com/mw00/project-maya/commit/40dddb9d806429e5af22283ff0da58533f229779) GLM prompt: EXL3 experts' tensor-core path by chunk length, opt-in (MAYA_GLM_EXL3_MMA_ROWS_SHORT) ### 📊 Changes **5 files changed** (+91 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+3 -2) 📝 `docs/SETTINGS.md` (+1 -0) ➕ `include/strata/core/exl3_mma_rows.hpp` (+34 -0) 📝 `src/core/glm_prefill.cu` (+18 -2) ➕ `tests/core/exl3_mma_rows_test.cpp` (+35 -0) </details> ### 📄 Description ## Summary In an EXL3 pack's prompt path, an expert routed more than `MAYA_GLM_EXL3_MMA_ROWS` (64) of a chunk's tokens is rebuilt to FP16 and multiplied by cuBLAS - a fixed cost per expert and chunk - while lighter ones go through the tensor-core kernels, whose cost grows with the rows. In short chunks most experts have tens to a few hundred rows and the rebuild is most of the MoE time; in long chunks the FP16 product is cheaper, so raising the switch for every chunk makes long reads slower. **`MAYA_GLM_EXL3_MMA_ROWS_SHORT=<rows>[,<max chunk tokens>]`** (off by default) sends experts of up to `<rows>` rows to the tensor-core kernels in chunks of up to `<max chunk tokens>` (4096); longer chunks keep `MAYA_GLM_EXL3_MMA_ROWS`. 91 lines; decode unchanged. ## Why Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls) through the Anthropic Messages API with `--parallel 8`: most reads are short increments onto restored conversations - in a 45-minute sample, 95% of 319 reads had under 8K new tokens and a third under 512 - so short chunks are where the prompt time goes. ## Measured Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x8 from its own CPU root port (no fast P2P); Intel Core Ultra 9 285K; 96 GB DDR5; driver 615.71.09, CUDA 13.4. Model: GLM-5.3-Flash EXL3 sc 3.10 bpw, every expert in VRAM, 2-GPU split. Wall time per chunk on each GPU (ms): | chunk tokens | default (64 rows) | 192 rows | 256 rows | every expert on the tensor cores | |---|---|---|---|---| | 1024 | 562 / 548 | 484 / 433 | 483 / 427 | 483 / 427 | | 2048 | 1051 / 960 | 814 / 734 | 808 / 721 | 814 / 731 | | 3072 | 1390 / 1275 | 1175 / 1074 | 1166 / 1052 | 1188 / 1070 | | 7552 | **2477** / 2300 | 2606 / 2237 | 2638 / 2267 | 2863 / 2602 | Whole reads with `MAYA_GLM_EXL3_MMA_ROWS_SHORT=192` (these runs also cut reads into at least 4 chunks, #392), alone / with 3 requests decoding: 4K -15% / -14%, 8K -23% / -21%, 16K -16% / -15%, 2K -6% / -4%; 30K and a cold 60K read (chunks of 7-8K) unchanged. Without #392 a split reads up to 8192 tokens as one chunk, so the gain applies to reads of up to 4096 tokens (the first rows of the table). ## Recommendation With EXL3 packs, set `MAYA_GLM_EXL3_MMA_ROWS_SHORT=192`: short chunks get 14-24% faster and long chunks keep the default path (192 and 256 are within noise; 128 keeps most of the gain). It does nothing for GGUF / native packs (their prompt experts take MMQ). Leave it off if greedy output must match the setting off bit for bit. One GPU and experts streamed from RAM were not measured. ## Exactness Not bit-exact: the tensor-core kernels decode and accumulate in another order than the FP16 rebuild plus cuBLAS. With identical chunking and the switch at 192 rows, greedy tokens differed from the default after 0-22 tokens in 42 of 44 short-chunk reads. A read whose chunks are all longer than `<max chunk tokens>` takes the unchanged path: the cold 60K read gave identical tokens. ## How it was verified - `tests/core/exl3_mma_rows_test.cpp` (CPU): the parse and the rows by chunk length (the base when off, for long chunks and an unknown length; the setting's rows for short chunks). - On v1.1.23 (this branch): builds (nvcc 13.4, sm_75 and sm_120); `exl3_mma_rows_test` passes on the box above; `tools/check_hip_compat.py` is clean. - The table and reads: the same change on v1.1.21, fresh engines, alone and with 3 greedy decoders; then several hours live with 8 conversations, 0 engine errors. --- <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:11 +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#506
No description provided.