glm5next: the latent and index caches are declared replicated -- the host tier holds each once a slot

Every rank computes the whole normed latent (kv_store over the replicated kv_a) and pools
into the whole index cache, in the head form and the row form alike, so both cached groups
carry rad_kv_group_replicated. At eight ranks a 4-token block costs 49.59 KiB a slot
(kv_latent 48.00 KiB over its 12 layers, kv_dsa_index 1.59 KiB) rather than 396.75 KiB,
12.4 KiB a token rather than 99.2 KiB: --prefix-cache-mib 32768 holds 2.7M tokens rather
than 338K.

glm5next_test pins the two flags at 1, 2 and 8 ranks; the flag is outside the recording
fake's graph hash, so the pinned graphs and steps stand.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Fable 5.1 committed 2026-10-22 09:08:44 +00:00
1 parent 66a1d5aa15
commit 4f821ce0b9
3 files changed
+40 -3

No files matched your search

+4
View File
@@ -430,6 +430,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
m.expand = copy(b, g, m.x, m.h0);
m.layers.resize(45);
for (int l = 0; l < 45; ++l) RAD_ARCH_TRY(layer(b, m, m.layers[l], nm, l, false));
// Every rank computes the whole normed latent and pools into the whole index cache
// (rad_block_glm_mla.h, rad_block_glm_indexer.h), so the host tier keeps each once a slot.
RAD_ARCH_TRY(rad_kv_group_replicated(b, m.latent));
if (m.index) RAD_ARCH_TRY(rad_kv_group_replicated(b, m.index));
m.contract = rw(b,
RAD_OP(b, "mhc_contract",
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", 4096),
+7 -3
View File
@@ -506,9 +506,13 @@ declare.
| `kv_kda` | `RAD_KV_LINEAR`, f32, 128 x 128 a head | the recurrent state, 64 / tp heads a rank | 34 KDA |
| `kv_kda_conv` | `RAD_KV_CONV`, bf16, width 4 | the convolution history, 3 x 8192 / tp channels a rank | 34 KDA |
The latent and the index are replicated: every rank keeps the whole latent cache. The model is a
hybrid, so a prefix-cache hit is usable only from a state checkpoint at or below it, and
`--checkpoint-interval` decides how much of a shared system prompt is reused.
The latent and the index are replicated: every rank keeps the whole latent cache, and the plugin
declares both so (`rad_kv_group_replicated`), which lets the host tier (`--prefix-cache-mib`) hold
each once a slot: 49.59 KiB a 4-token block at any rank count (`kv_latent` 48.00 KiB over its 12
layers, `kv_dsa_index` 1.59 KiB), 12.4 KiB a token, where a copy per rank would make a slot
396.75 KiB at eight. The model is a hybrid, so a prefix-cache hit is usable only from a state
checkpoint at or below it, and `--checkpoint-interval` decides how much of a shared system prompt
is reused.
**Linears.** Each weight is served as the export stores it:
+29
View File
@@ -1440,6 +1440,35 @@ RadBuildCtx glm53_vl_ctx(int rank, int world, int64_t patches, int max_spec = 3)
} /* namespace */
/* The latent and the index cache are computed whole on every rank (rad_block_glm_mla.h,
* rad_block_glm_indexer.h) and the plugin says so, which lets the host tier keep each once a slot
* under tensor parallelism instead of once a rank. The linear groups travel in the checkpoint
* store and carry no such flag. The flag is outside graph_hash(), so the pinned graphs stand. */
TEST(glm53_declares_its_latent_and_index_caches_replicated) {
MetaKV mk = glm53_vl_meta();
auto ends_with = [](const std::string& s, const char* t) {
const size_t n = std::strlen(t);
return s.size() >= n && s.compare(s.size() - n, n, t) == 0;
};
for (int world : { 1, 2, 8 }) {
for (int rank : { 0, world - 1 }) {
RadBuilder b;
glm53_encs(b);
RadBuildCtx ctx = glm53_vl_ctx(rank, world, 0);
REQUIRE_EQ(glm5next::declare(&b, mk.meta(), &ctx), RAD_OK);
REQUIRE_EQ(b.kv_groups.size(), 5u);
int replicated = 0;
for (const RecKV& g : b.kv_groups) {
const bool want = ends_with(g.name, "kv_latent") || ends_with(g.name, "kv_dsa_index");
CHECK(g.replicated == want);
CHECK(!g.zero);
replicated += g.replicated;
}
CHECK_EQ(replicated, 2);
}
}
}
/* The tower is declared only with an encoder budget, last, its weights replicated in their own
* groups past the 45 layers and the MTP layer's, its 2-D rotary the axial one at sixteen
* frequencies an axis, gate and up joined gate first; one scatter over the trunk's embedding and