Archived
glm5next: the MLA row form, opt-in with RADIANCE_GLM_MLA_ROWS=1 -- a prefill-sized step by rows over the ranks, each rank with all 64 heads
From GlmTp::kSplitRows each rank runs its run of the step's rows (GlmTp::run_of: ceil(T / world) rows, the last run shorter) through q_b, absorption, attention with all 64 heads (mla_attn_rows_bf16), expansion and o, and an all_gather of whole runs takes the all-reduce's place. The latent cache and the DSA selection are whole on every rank, so nothing is exchanged before the attention; each rank sends its run to seven peers, half the bytes of the two-shot all-reduce, through the same exchange instance. In a 4096-row chunk at 16k of context a rank's attention drops from 14.0 to 3.9 ms a layer on the kernel bench. The price is q_b, kv_b and o at full width on every rank: 120 MiB a layer, 1.29 GiB a card over the 11 trunk layers, and about 0.1 GiB of activations; the MTP layer keeps its heads. The full-width weights are whole views (RadWeightDecl::source) of blk.N.attn_q_b, attn_kv_b and attn_output, the head form's container entries, so they take the stored encoding (fp8a8f32, bf16) and need no name map; LinearFP8 gets `stored` for that, served by its block-fp8 branch only, and LinearFP8::step writes a run of rows from a given output row. The head form stays the default, unset or RADIANCE_GLM_MLA_ROWS=0, and declares none of it: that graph is the one before this change, byte for byte (the pinned hashes). The row form is not bit-identical to the head form, and GLM-5.3 turns that into a measurable divergence: over a 43k-position KL corpus at TP8 (English prose, German prose, code) the row form scores a mean KL of 0.033 against the head form (median 0.004, top-1 agreement 93.5 %), with greedy text unchanged. The projections are not the cause: q_b and o over a rank's rows give the head form's bytes (r4d_emu), and o summed as eight rank partials in the all-reduce's order (RADIANCE_GLM_MLA_ROWS=2, a test form, GlmMla::Form::rows_sliced_o) scores 0.032. The attention's rounding is: the rows kernel parts from the paired union tile in about 0.1 % of every row's outputs by one bf16 step (the union pairing sums a pair's second row in another order), and the 16-head tile, which parts in the same share of every second row only, halves the KL to 0.015. A bit-identical row form would run the union tile eight times a row over its own group of eight heads, without this kernel's gain, or need a rows kernel with the union's arithmetic; neither is here, so the form is opt-in. Measured on eight R9700 at Gen5 links, the same build: a 20k-token prefill 5074 tok/s in the row form against 4270 in the head form, BetterBench prefill at 22k 4984 against 4151, single stream 181.8 against 180.2 tok/s, eight streams 468 against 454. glm5next_test declares the block at one to eight ranks and checks the full-width views and their sources, the fp8a8f32 GEMMs, the gather's bound against the all-reduce's, each rank's operands at 300 rows (runs of 38, the last 34 at eight ranks) and the head form at 255; the o-slices form's eight GEMMs and seven adds; the model's counts and the TP8 pin under RADIANCE_GLM_MLA_ROWS=1 (0x1d378152c40f8834 / 0x82ed1094dbf4b637), with the default pins unchanged; and the row rule against both formulas it replaced. plugin_test resolves every band of every op the row form adds at eight ranks against libr4d, with no card. 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
7d7c66da55
commit
eb14e4f642
9 files changed
+717
-76
No files matched your search
+54
-32
@@ -427,18 +427,19 @@ declared beside it when the container carries the tower and the deployment asks
|
||||
654df43; for the tower and its processor, transformers' `glm5_next`.
|
||||
|
||||
The plugin is one file over blocks in `arch/common`, one block a file; it declares the buffers
|
||||
the blocks share, places them and issues the step's order.
|
||||
the blocks share, places them and issues the step's order, and reads its one deployment switch
|
||||
(`RADIANCE_GLM_MLA_ROWS`, docs/GUIDE.md) once a declare.
|
||||
|
||||
| file | block | what |
|
||||
|---|---|---|
|
||||
| `rad_block_glm_mhc.h` | `ManifoldConn` | the four-stream residual's read and write |
|
||||
| `rad_block_glm_kda.h` | `GlmKda`, `KdaState` | the 34 linear layers and their recurrence |
|
||||
| `rad_block_glm_mla.h` | `GlmMla`, `MlaLatent` | the 11 sparse MLA layers and their absorbed core |
|
||||
| `rad_block_glm_mla.h` | `GlmMla`, `MlaLatent` | the 11 sparse MLA layers, in the head form or the row form |
|
||||
| `rad_block_glm_indexer.h` | `GlmIndexer`, `DsaCache` | the DSA indexer, 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_block_glm_vision.h` | `GlmVision`, `MediaRows` | the tower, and its rows over the embeddings |
|
||||
| `rad_glm_tp.h` | `GlmTp`, `SplitF32Proj` | the shards, the split threshold, the column split of a replicated f32 projection |
|
||||
| `rad_glm_tp.h` | `GlmTp`, `SplitF32Proj` | the shards, the one row rule, the split thresholds, the column split of a replicated f32 projection |
|
||||
|
||||
```
|
||||
45 layers, hidden 4096, vocab 154880 (embedding and lm_head separate, bf16)
|
||||
@@ -534,45 +535,66 @@ at eight ranks each card holds 22.06 GiB of them, 19.67 GiB the routed experts.
|
||||
layer's latent, index and tail for every row and runs its MoE on the proposal rows only.
|
||||
|
||||
**Tensor parallelism.** At 1, 2, 4 or 8 ranks; declare refuses any other. `tests/glm5next_test.cpp`
|
||||
declares and steps the whole plugin at 1, 4 and 8, against pinned graph and step hashes at 1 and
|
||||
8, the connection, router and index-gate splits at 1, 2, 4 and 8, the indexer's row split at 2
|
||||
and 8, the row rule at every world, each issue's operand count against the loaded kernel
|
||||
libraries' schemas, and every declared weight against the served container's names and encodings.
|
||||
declares and steps the whole plugin at 1 and 8 against pinned graph and step hashes (the head form,
|
||||
the row form), the connection, router and index-gate splits at 1, 2, 4 and 8,
|
||||
the indexer's row split at 2 and 8, the MLA row split at 1, 2, 4 and 8, the row rule at every
|
||||
world, each issue's operand count against the loaded kernel libraries' schemas, and every declared
|
||||
weight against the served container's names and encodings.
|
||||
|
||||
One row rule (`GlmTp::run_rows`): from a pass of `GlmTp::kSplitRows` = 256 rows, a replicated
|
||||
piece of work splits by rows over the ranks instead, each rank taking one run of ceil(T / world)
|
||||
rows rounded up to whole 16-byte words of the row it gathers, because an `all_gather` moves whole
|
||||
words: multiples of four rows for the indexer's one i32 length a row. The last run may be short;
|
||||
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 indexer also splits a smaller step, from
|
||||
16 rows once rows x live blocks reach 2^18 (`GlmTp::kSplitWork`). Below the thresholds, as in
|
||||
decode, the collective costs more than it saves and every rank runs the replicated form.
|
||||
One row rule (`GlmTp::run_rows`): from a pass of `GlmTp::kSplitRows` = 256 rows, a replicated or
|
||||
head-split piece of work splits by rows over the ranks instead, each rank taking one run of
|
||||
ceil(T / world) rows rounded up to whole 16-byte words of the row it gathers, because an
|
||||
`all_gather` moves whole words: whole rows for the MLA's 4096-wide bf16 output, multiples of four
|
||||
rows for the indexer's one i32 length a row. The last run may be short; 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 indexer alone also splits a smaller step, from 16 rows once rows x
|
||||
live blocks reach 2^18 (`GlmTp::kSplitWork`). Below the thresholds, as in decode, the collective
|
||||
costs more than it saves and every rank runs the replicated or head-split form.
|
||||
|
||||
- The routed and the shared experts split their 2048 width into equal contiguous slices, 256 a
|
||||
rank at eight; each rank computes its slice of every expert, and the block's all-reduce sums
|
||||
them. The dense feed-forward splits its 12288 the same way.
|
||||
- MLA splits by whole heads: the rows of q_b and kv_b (8 heads a rank at eight) and the columns
|
||||
of o. q_a, kv_a and the latent are replicated.
|
||||
of o. q_a, kv_a and the latent are replicated. With `RADIANCE_GLM_MLA_ROWS=1`, from the
|
||||
threshold, it splits by rows instead (`GlmMla::Form::rows`): each rank takes its run under the row rule, the last run shorter,
|
||||
through q_b, absorption, attention with all 64 heads
|
||||
(`mla_attn_rows_bf16`, docs/OPS.md), expansion and o, and an `all_gather` of whole runs takes the
|
||||
all-reduce's place. The latent cache and the DSA selection are whole on every rank, so nothing
|
||||
is exchanged before the attention. Each rank sends its run to seven peers, half the bytes of the
|
||||
two-shot all-reduce, and the gather shares that all-reduce's exchange instance. The price is
|
||||
q_b, kv_b and o at full width on every rank, 120 MiB a layer and 1.29 GiB a card over the 11
|
||||
trunk layers (the MTP layer keeps its heads), about 0.1 GiB of activations besides; `2` is the
|
||||
row form with o summed as the head form sums it (`GlmMla::Form::rows_sliced_o`), a test of the
|
||||
two forms' difference. The head form is the default because the row form is not bit-identical
|
||||
to it, and this model turns that into a measurable divergence: against the head form over a
|
||||
43k-position corpus the row form scores a mean KL of 0.033 (median 0.004, top-1 agreement
|
||||
93.5 %), greedy text unchanged. The projections are not the cause (q_b and o give the head
|
||||
form's bytes when o is summed as eight rank partials, and the KL stays at 0.032); the
|
||||
attention's rounding is: the rows kernel parts from the paired tile in about 0.1 % of every
|
||||
row's outputs by one bf16 step, and the 16-head tile, which parts in the same share of every
|
||||
second row only, halves the KL to 0.015. Measured
|
||||
on eight R9700 at Gen5 links, the same build: a 20k-token prefill 5074 tok/s in the row form
|
||||
against 4270 in the head form; BetterBench single stream 181.8 against 180.2 tok/s, eight
|
||||
parallel 468 against 454.
|
||||
- KDA splits its 64 heads, with them the q/k/v rows, the convolution taps and the state; the two
|
||||
rank-128 projections into the gates are replicated.
|
||||
- The indexer's key side is replicated: every rank keeps the whole index cache and its tail. Its
|
||||
query side splits by rows from the threshold: each rank scores its run under the row rule,
|
||||
R = 4 * ceil(T / (4 * ranks)) query rows (`DsaCache::part_rows`), against the whole cache
|
||||
(`dsa_score` with `row_part`, the last run's rows past the step scoring `-inf`) and selects for
|
||||
the rows of its run that exist, under the bounds the scorer rebased to the run's first row
|
||||
(`cu_part`, docs/OPS.md); two `all_gather`s lay the runs' page tables and lengths end to end,
|
||||
513 and 1 i32 a row, 8 MiB a layer at a 4096-row chunk. 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 need no 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 one
|
||||
rank's and MLA reads it unchanged. The scoring grows with the context (every row scores every
|
||||
complete block of its sequence), so this is where long prompts gain: the score plane shrinks to
|
||||
one run (256 MiB to 32 MiB at 64k of context and a 4096-row chunk). A smaller step splits too
|
||||
from 16 rows once rows x live blocks reach 2^18 (`GlmTp::kSplitWork`): eight sequences
|
||||
verifying five drafts from about 22k of context, where the scoring of 48 rows outweighs the two
|
||||
gathers; a single sequence's decode never does, and below both thresholds the indexer runs
|
||||
whole.
|
||||
R = 4 * ceil(T / (4 * ranks)) query rows (`DsaCache::part_rows`), against the whole cache (`dsa_score` with `row_part`,
|
||||
the last run's rows past the step scoring `-inf`) and selects for the rows of its run that exist,
|
||||
under the bounds the scorer rebased to the run's first row (`cu_part`, docs/OPS.md); two
|
||||
`all_gather`s lay the runs' page tables and lengths end to end, 513 and 1 i32 a row, 8 MiB a layer
|
||||
at a 4096-row chunk. 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 need no 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 one rank's and MLA reads it unchanged.
|
||||
The scoring grows with the context (every row scores every complete block of its sequence), so
|
||||
this is where long prompts gain: the score plane shrinks to one run (256 MiB to 32 MiB at 64k of
|
||||
context and a 4096-row chunk). A smaller step splits too from 16 rows once rows x live blocks
|
||||
reach 2^18 (`GlmTp::kSplitWork`): eight sequences verifying five drafts from about 22k of
|
||||
context, where the scoring of 48 rows outweighs the two gathers; a single sequence's decode never
|
||||
does, and below both thresholds the indexer runs whole.
|
||||
- The vocabulary is row-sharded, 19360 rows a rank at eight; the embedding's all-reduce is exact.
|
||||
- The f32 projections (the router's 288 x 4096, the index head gates' 32 x 4096, each
|
||||
connection's mHC projection of 24 x 16384) are replicated. From a pass of 256 rows
|
||||
|
||||
Reference in new issue
Block a user