[PR #46] [CLOSED] GLM fast path: STRATA_GLM_LAT8=1 keeps the DSA latent cache in INT8 (opt-in) #300

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/46
Author: @sociolog
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: pr2-lat8


📝 Commits (5)

  • 67da11d GLM fast path: the indexer key/gate rows in a ring (8196 positions) instead of max_ctx rows
  • 1d59720 score mode: STRATA_GLM_SCORE_PREFILL=1 reads the unscored context through the prompt path
  • 97e24ba README: the Tuning table's row for this change's setting
  • 7456d00 GLM fast path: STRATA_GLM_LAT8=1 keeps the DSA latent cache in INT8
  • 5b6e714 README: the Tuning table's row for STRATA_GLM_LAT8

📊 Changes

10 files changed (+314 additions, -109 deletions)

View changed files

📝 README.md (+2 -0)
📝 include/strata/core/glm_model.hpp (+12 -0)
📝 include/strata/kernels/glm_batch.hpp (+5 -3)
📝 include/strata/kernels/glm_fast.hpp (+3 -1)
📝 src/core/glm_fast_path.cu (+94 -30)
📝 src/core/glm_model.cu (+32 -5)
📝 src/core/glm_prefill.cu (+42 -24)
📝 src/kernels/cuda/glm_batch.cu (+64 -25)
📝 src/kernels/cuda/glm_fast.cu (+44 -20)
📝 src/program/generate.cpp (+16 -1)

📄 Description

Stacked on #45 (the indexer ring): this branch contains PR1's 3 commits plus 2 of its own - the
last 2 commits are this PR. Opt-in; default unchanged.

What

With STRATA_GLM_LAT8=1 a latent row becomes kv_lora int8 codes followed by one FP16 scale per 32 values
(kv_lora * 17 / 16 bytes: 544 at kv_lora 512 instead of FP16's 1024). Scale = absmax / 127 of the 32 values,
rounded to FP16 before the codes are taken from it.

  • Writers: both dsa_prep kernels (decode and prompt), one scale a warp (kv_lora % 32 == 0 checked at load).
  • Readers hand out the same FP16 bits an FP16 row would hold, so the attention arithmetic is untouched: decode
    mla_kernel / mla_attn_kernel / mla_split_kernel through lat_ld(); the prompt's F32 / tensor-core / register /
    mma.sync kernels through lat_ld4() / lat_ld8() (the 4- and 8-value loads they already do).
  • HIP: the WMMA prompt kernel reads FP16 latents only - with an INT8 cache the prompt takes mla_attn there (not
    built or run on HIP here; NVIDIA path unchanged when the setting is off).
  • Slot files carry the INT8 rows. README row added.

Why

131072 context, RTX 3090 + 3060 split, with PR1: state/KV 1.13 -> 0.72 GB (3090) and 0.79 -> 0.50 GB (3060), expert
slots 80 -> 82 and 48 -> 50 a layer. --bench (RAM_RESIDENT=1, CPU plan pinned, two runs each): 19.2 / 19.2 ->
19.5 / 19.5 tok/s. Prefill unchanged (313 / 587).

Quality (score mode, pool and CPU plan pinned, so only the cache differs)

KL vs FP16 cache NLL
3,935 tokens through the decode path 0.027 nats/token 1.8684 -> 1.8713
3,499-token prefilled context, 499 scored 0.0177 (prefill run-to-run floor 0.018) -

For scale: the CPU-lane vs GPU arithmetic of the same expert moves KL by ~0.02 whenever the tiers differ. A
16-value-group variant measured only marginally better (KL 0.0249), so the 32-value layout stays.

Checks run on this branch (run on v1.0.16; the branch is rebased onto v1.0.20 - upstream's engine changes since are one INFO line and one comment; the server tests re-run on v1.0.20: 124 OK): builds (sm_75, sm_86); glm_dsa_parity, glm_ffn_parity, glm_hc_parity, glm_kda_parity, glm_layer_parity --selftest: all PASS; python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok: 102 tests OK (3 skipped); the --bench request sequence (3 answers, 2K and 8K prompts) on the real model: runs clean.


The code, the measurements and this description were produced with the help of Claude, an AI assistant by Anthropic.


🔄 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/46 **Author:** [@sociolog](https://github.com/sociolog) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr2-lat8` --- ### 📝 Commits (5) - [`67da11d`](https://github.com/mw00/project-maya/commit/67da11d8d493d20ec4114b3d1277aff1d6ceea7e) GLM fast path: the indexer key/gate rows in a ring (8196 positions) instead of max_ctx rows - [`1d59720`](https://github.com/mw00/project-maya/commit/1d59720520326e2e6e1678deef92ec8ad92769e6) score mode: STRATA_GLM_SCORE_PREFILL=1 reads the unscored context through the prompt path - [`97e24ba`](https://github.com/mw00/project-maya/commit/97e24ba47c302f567fb9a7d7942b5a8bf9cbf7cf) README: the Tuning table's row for this change's setting - [`7456d00`](https://github.com/mw00/project-maya/commit/7456d00d54f9da3d9084d6cfbf4522cd50a624f6) GLM fast path: STRATA_GLM_LAT8=1 keeps the DSA latent cache in INT8 - [`5b6e714`](https://github.com/mw00/project-maya/commit/5b6e7144b661cd65f52bc3ec99d5f26f572658f6) README: the Tuning table's row for STRATA_GLM_LAT8 ### 📊 Changes **10 files changed** (+314 additions, -109 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+2 -0) 📝 `include/strata/core/glm_model.hpp` (+12 -0) 📝 `include/strata/kernels/glm_batch.hpp` (+5 -3) 📝 `include/strata/kernels/glm_fast.hpp` (+3 -1) 📝 `src/core/glm_fast_path.cu` (+94 -30) 📝 `src/core/glm_model.cu` (+32 -5) 📝 `src/core/glm_prefill.cu` (+42 -24) 📝 `src/kernels/cuda/glm_batch.cu` (+64 -25) 📝 `src/kernels/cuda/glm_fast.cu` (+44 -20) 📝 `src/program/generate.cpp` (+16 -1) </details> ### 📄 Description **Stacked on #45** (the indexer ring): this branch contains PR1's 3 commits plus 2 of its own - the last 2 commits are this PR. Opt-in; default unchanged. ## What With `STRATA_GLM_LAT8=1` a latent row becomes `kv_lora` int8 codes followed by one FP16 scale per 32 values (`kv_lora * 17 / 16` bytes: 544 at kv_lora 512 instead of FP16's 1024). Scale = absmax / 127 of the 32 values, rounded to FP16 before the codes are taken from it. - Writers: both `dsa_prep` kernels (decode and prompt), one scale a warp (`kv_lora % 32 == 0` checked at load). - Readers hand out the same FP16 bits an FP16 row would hold, so the attention arithmetic is untouched: decode `mla_kernel` / `mla_attn_kernel` / `mla_split_kernel` through `lat_ld()`; the prompt's F32 / tensor-core / register / mma.sync kernels through `lat_ld4()` / `lat_ld8()` (the 4- and 8-value loads they already do). - HIP: the WMMA prompt kernel reads FP16 latents only - with an INT8 cache the prompt takes `mla_attn` there (not built or run on HIP here; NVIDIA path unchanged when the setting is off). - Slot files carry the INT8 rows. README row added. ## Why 131072 context, RTX 3090 + 3060 split, with PR1: state/KV 1.13 -> 0.72 GB (3090) and 0.79 -> 0.50 GB (3060), expert slots 80 -> 82 and 48 -> 50 a layer. `--bench` (RAM_RESIDENT=1, CPU plan pinned, two runs each): 19.2 / 19.2 -> 19.5 / 19.5 tok/s. Prefill unchanged (313 / 587). ## Quality (score mode, pool and CPU plan pinned, so only the cache differs) | | KL vs FP16 cache | NLL | |---|---:|---:| | 3,935 tokens through the decode path | 0.027 nats/token | 1.8684 -> 1.8713 | | 3,499-token prefilled context, 499 scored | 0.0177 (prefill run-to-run floor 0.018) | - | For scale: the CPU-lane vs GPU arithmetic of the same expert moves KL by ~0.02 whenever the tiers differ. A 16-value-group variant measured only marginally better (KL 0.0249), so the 32-value layout stays. **Checks run on this branch (run on v1.0.16; the branch is rebased onto v1.0.20 - upstream's engine changes since are one INFO line and one comment; the server tests re-run on v1.0.20: 124 OK):** builds (sm_75, sm_86); `glm_dsa_parity`, `glm_ffn_parity`, `glm_hc_parity`, `glm_kda_parity`, `glm_layer_parity` `--selftest`: all PASS; `python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok`: 102 tests OK (3 skipped); the `--bench` request sequence (3 answers, 2K and 8K prompts) on the real model: runs clean. --- *The code, the measurements and this description were produced with the help of Claude, an AI assistant by Anthropic.* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:57 +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#300
No description provided.