Archived
glm5next: the DSA indexer scores and selects by query rows over the ranks -- the prefill op that grows with context runs a run of rows a rank, bit for bit
Every rank scored every query row of a step against every complete block of its sequence and selected its 512 blocks, the same work eight times: 58 ms of a 1029 ms step at a 4096-row chunk and 20k of context, about 185 ms at 64k, the largest op that grows with the context. From GlmTp::kSplitRows each rank now scores one run of the step's rows with dsa_score's row_part, selects for the rows of its run under the bounds the scorer rebased (cu_part), and two all_gathers lay the page tables and lengths end to end (8 MiB a layer at 4096 rows). The key side stays replicated. The run's queries are all a rank needs, so the query projection, its quantiser and the head gates run on the run's rows too, and the gates lose their column split and gather; the bf16 projection stays on the step's rows where a run would be 64 rows or fewer, the skinny band whose split count a tuned configuration may set. Each row's selection is the same kernels' answer to the same operands, so the joined table is bit-identical to the replicated one and MLA reads it unchanged. The rule for a run is GlmTp's, stated once: ceil(T / world) rows rounded up to whole 16-byte words of the gathered row, because an all_gather moves whole words; the indexer gathers one i32 length a row, so its runs are multiples of four (DsaCache::part_rows). A rank whose run lies wholly past a small step takes the first run and computes dead rows, so every plane it gathers is written (GlmTp::run_of). The selection planes hold world runs, which can reach past the step, and the score plane shrinks to one run, 256 MiB to 32 MiB at 64k of context and a 4096-row chunk. A decode step splits too once rows x live blocks reach 2^18 from 16 rows (GlmTp::kSplitWork): eight sequences verifying five drafts from about 22k of context, where scoring 48 rows over 8000 blocks (250 us on one R9700) outweighs the two eight-rank gathers (about 50 us); a single sequence's six rows never pay. The replicated issue passes cu_part absent as its tenth operand, because the engine counts operands against the schema and refused the nine-operand issue at a served engine's first long prompt. On eight R9700s (TP8, two ranks on Gen4 x8 that day) a 19887-token prompt prefills 3927 tok/s against 3748 on 1.9.0, 7881 tokens 3990 against 3655, 2k 3849 against 3663; greedy text with the adaptive draft window is identical. r4d_emu splits decode rows beside a prefill chunk at 2, 4 and 8 ranks and joins the runs as the gather does, byte for byte against the unsplit scorer; glm5next_test declares the split at 2 and 8 ranks with the lint, holds the row rule to the formula it replaced at every world, and pins the graph and steps (world 1 0xed3fc26c486ea1b5 / 0x33e5f136f0dbba15, world 8 0x712f01858dbe1047 / 0xf9e357b1333c638f). dsa_score_fp8's selftest passes 62 of 62 on eight cards, and --perfdsa times the indexer whole and as one rank's run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
66812280bb
commit
1ad675e10c
5 files changed
+474
-58
No files matched your search
@@ -12,7 +12,7 @@
|
||||
* rad_block_glm_indexer.h GlmIndexer the DSA indexer, DsaCache its key cache and selection
|
||||
* rad_block_glm_router.h GlmRouter the correction-bias router (through MoeFP8)
|
||||
* rad_block_glm_mtp.h GlmMtp the draft head around the plugin's layer 45
|
||||
* rad_glm_tp.h GlmTp the shards and the split threshold
|
||||
* rad_glm_tp.h GlmTp the shards, the row runs and the split thresholds
|
||||
*
|
||||
* This file declares the buffers the blocks share, places the blocks and issues the step's
|
||||
* order. Declaration order is liveness (the buffer plan takes lifetimes from it) and the issue
|
||||
@@ -125,7 +125,9 @@ static int kda_buffers(RadBuilder* b, Model& m) {
|
||||
kw.core.out = bf("recurrent_out", W);
|
||||
return RAD_OK;
|
||||
}
|
||||
/* The head form's buffers, then the selection planes the indexer writes and the MLA reads. */
|
||||
/* The head form's buffers, then the selection planes the indexer writes and the MLA reads. Under
|
||||
* TP the selection planes hold every rank's run of rows, which can reach past the step
|
||||
* (DsaCache::part_rows). */
|
||||
static int mla_buffers(RadBuilder* b, Model& m) {
|
||||
auto& g = m.g;
|
||||
auto& nm = m.nm;
|
||||
@@ -147,14 +149,18 @@ static int mla_buffers(RadBuilder* b, Model& m) {
|
||||
aw.attn.x = bf("expanded", Q);
|
||||
RAD_ARCH_TRY(aw.attn.declare_qs(b, nm, g, "expanded", Q));
|
||||
aw.core.out = aw.attn.x;
|
||||
aw.core.selected = decl_b(b, nm.f("selected"), RAD_I32, { T, 513 });
|
||||
aw.core.length = decl_b(b, nm.f("length"), RAD_I32, { T });
|
||||
const int64_t part = g.world > 1 ? DsaCache::part_rows(T, g.world) : 0;
|
||||
const int64_t TQ = g.world > 1 ? std::max(T, g.world * part) : T;
|
||||
aw.core.selected = decl_b(b, nm.f("selected"), RAD_I32, { TQ, 513 });
|
||||
aw.core.length = decl_b(b, nm.f("length"), RAD_I32, { TQ });
|
||||
return RAD_OK;
|
||||
}
|
||||
static int indexer_buffers(RadBuilder* b, Model& m) {
|
||||
auto& g = m.g;
|
||||
auto& nm = m.nm;
|
||||
const int64_t T = g.max_tok;
|
||||
const int64_t part = g.world > 1 ? DsaCache::part_rows(T, g.world) : 0;
|
||||
const int64_t TQ = g.world > 1 ? std::max(T, g.world * part) : T;
|
||||
const int64_t work = (T + 3) / 4 + g.max_seqs, blocks = (g.max_ctx + 3) / 4 + 1;
|
||||
auto bf = [&](const char* n, int64_t width) {
|
||||
return decl_b(b, nm.f("%s", n), RAD_BF16, { T, width });
|
||||
@@ -166,9 +172,9 @@ static int indexer_buffers(RadBuilder* b, Model& m) {
|
||||
iw.kg_raw = bf("index_key_gate", 256);
|
||||
auto& c = iw.cache;
|
||||
c.query = decl_b(b, nm.f("index_heads"), RAD_BF16, { T * 32, 128 });
|
||||
c.codes = decl_b(b, nm.f("index_codes"), RAD_F8E4M3, { T * 32, 128 });
|
||||
c.scales = decl_b(b, nm.f("index_scales"), RAD_F32, { T * 32, 1 });
|
||||
c.gate = decl_b(b, nm.f("index_head_weights"), RAD_F32, { T, 32 });
|
||||
c.codes = decl_b(b, nm.f("index_codes"), RAD_F8E4M3, { TQ * 32, 128 });
|
||||
c.scales = decl_b(b, nm.f("index_scales"), RAD_F32, { TQ * 32, 1 });
|
||||
c.gate = decl_b(b, nm.f("index_head_weights"), RAD_F32, { TQ, 32 });
|
||||
c.kg = bf("index_normalized_key_gate", 256);
|
||||
c.stage = decl_b(b, nm.f("pool_stage"), RAD_BF16, { work * 4, 256 });
|
||||
c.page = decl_b(b, nm.f("pool_page"), RAD_I32, { work });
|
||||
@@ -176,10 +182,18 @@ static int indexer_buffers(RadBuilder* b, Model& m) {
|
||||
c.nc = decl_b(b, nm.f("pool_count"), RAD_I32, { g.max_seqs });
|
||||
c.pooled = decl_b(b, nm.f("pool_codes"), RAD_F8E4M3, { work, 128 });
|
||||
c.pool_scale = decl_b(b, nm.f("pool_scales"), RAD_F32, { work, 1 });
|
||||
c.score = decl_b(b, nm.f("index_scores"), RAD_F32, { T, blocks });
|
||||
/* A split step scores one run of rows a rank and an unsplit one is under GlmTp::kSplitRows:
|
||||
* at 64k of context the whole step's plane would be 256 MiB. */
|
||||
const int64_t scored = g.world > 1 ? std::min(T, std::max(part, GlmTp::kSplitRows)) : T;
|
||||
c.score = decl_b(b, nm.f("index_scores"), RAD_F32, { scored, blocks });
|
||||
c.selected = m.aw.core.selected;
|
||||
c.length = m.aw.core.length;
|
||||
c.nsel = decl_b(b, nm.f("selected_count"), RAD_I32, { T });
|
||||
if (g.world > 1) {
|
||||
c.cu_part = decl_b(b, nm.f("index_part_bounds"), RAD_I32, { g.max_seqs + 1 });
|
||||
c.sel_part = decl_b(b, nm.f("selected_part"), RAD_I32, { part, 513 });
|
||||
c.len_part = decl_b(b, nm.f("length_part"), RAD_I32, { part });
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
static int ffn_buffers(RadBuilder* b, Model& m) {
|
||||
|
||||
Reference in new issue
Block a user