mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #41] [MERGED] GLM KV cache for 128K context: indexer key/gate ring, INT8 latent cache #295
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#295
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/41
Author: @merbanan
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @mw00
Base:
main← Head:kv-128k📝 Commits (1)
3cba358GLM KV cache for 128K context: indexer key/gate ring, INT8 latent cache📊 Changes
10 files changed (+264 additions, -77 deletions)
View changed files
📝
README.md(+2 -0)📝
include/strata/core/glm_model.hpp(+11 -0)📝
include/strata/kernels/glm_batch.hpp(+6 -4)📝
include/strata/kernels/glm_fast.hpp(+7 -1)📝
src/core/glm_fast_path.cu(+71 -10)📝
src/core/glm_model.cu(+17 -5)📝
src/core/glm_prefill.cu(+25 -10)📝
src/kernels/cuda/glm_batch.cu(+66 -26)📝
src/kernels/cuda/glm_fast.cu(+44 -20)📝
src/program/generate.cpp(+15 -1)📄 Description
Makes 128K context cheaper in VRAM on the GLM fast path, which leaves more room for experts. There are two parts and one debug option:
ik/igcaches (FP32, 2 x 128 per token and layer) are only read to pool each 4-token block. After that they are dead. The fast path now keeps a ring of 8192 + 64 positions instead of the whole context. That covers a prompt sub-batch (at most 8192) plus one open pool, and the NextN block's prompt cache fill writes in pieces of the ring. Kernels index the caches modulo the ring.ik/igruns. The slot magic changes toMAYALST2, so old slot files are refused and the conversation is read again.STRATA_GLM_SLOW) still keeps every position.STRATA_GLM_KV_INT8=1, or--kv int8). The MLA latent is stored as 512 int8 codes plus one FP16 scale per 32 values: 544 bytes per token and layer instead of 1024.dsa_prepkernels quantize (warp absmax).mla/mla_attn/mla_split, and promptmla_attnF32 / tensor-core / tensor-core-register / mma.sync (sm_80+) / rocWMMA (HIP).STRATA_GLM_SCORE_PREFILL=1(debug). It reads the unscored context ofSTRATA_GLM_SCOREthrough the prompt path, so a long context is scored in minutes.The README's Tuning table gets rows for both new settings.
Measurements
All on 1x Tesla V100-PCIE-32GB (PCIe 3.0 x16), Ryzen 9 7950X, 62 GB RAM, Maya-S v2 IQ2_XXS,
--max-context 131072, v1.0.16 vs v1.0.16 + this PR.Memory, from the engine's own
glm fast:lines:STRATA_GLM_KV_INT8=1Long-context recall. Three facts are placed at 5 / 50 / 90% of a 60K-token prompt (README and docs text, repeated). They are asked in three turns, so the 2nd and 3rd go through conversation reuse; one run also sets
STRATA_GLM_SLOT_ROUNDTRIP=1. All 3 were found in every run: stock x4, ring x2, ring + INT8 x4.Speed, same harness.
--benchquestions, 256 tokens, greedy): stock 23.0 / 22.6 / 21.1 / 20.6, patched 22.7 / 22.4 / 21.8 / 21.8 / 21.4 tok/s. Same within noise.INT8 quality. I scored 512 tokens after a 30K-token context (
STRATA_GLM_SCORE) and compared KL against an FP16 log-softmax dump.Output: with the defaults, only the ring changes, and it computes the same values (the same pooled keys, read from a ring instead of the full array). Runs differ in their last bits the usual way, depending on which experts run on the CPU or the GPU.
Tests run
glm_dsa_parity,glm_ffn_parity,glm_hc_parity,glm_kda_parity --selftest: PASS.glm_layer_paritycould not run here: nodata/glm5-synth-dumps.python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok: 102 tests OK (3 skipped).Not tested
STRATA_USE_HIP; the NVIDIA code path is as above.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.