arch/common: GLM-5.3's blocks, and f32 scales, MXFP4 experts and sigmoid routing in the shared ones

New blocks: mHC (rad_block_mhc.h), KDA and its state (rad_block_glm_kda.h,
rad_block_kda_state.h), absorbed MLA over a latent cache (rad_block_glm_mla.h,
rad_block_mla_latent.h), the DSA indexer and its paged key cache (rad_block_glm_indexer.h,
rad_block_dsa_cache.h), the correction-bias router (rad_block_glm_router.h), and rad_tp_split.h:
a replicated f32 projection computed column-split over the ranks and all-gathered, so every value
is the replicated one's bits (from RADIANCE_GLM_TP_SPLIT_ROWS rows, 256 by default).

The shared blocks gain what GLM's checkpoint stores, each off unless a model asks for it:

- LinearFP8 reads a block-fp8 weight whose scale plane is f32 (dtype fp8a8f32), and the import
  check accepts that form beside bf16 scales.
- GateQuantFP8 serves a clamped SwiGLU (swiglu_clamped), optionally fused with its quantiser.
- MoeFP8 takes MXFP4 experts (format 8) and block-fp8 experts with f32 scales (format 9), the
  sigmoid router with f32 weights, an ungated shared arm, the router/scatter fusion and the
  sort's inverse handed to the gather (moe_scatter_inv, moe_gather_inv) where they resolve.
- The MLP's gated fold excludes the forms it cannot serve (f32 scales, a clamped product).

share_test checks that KDA's convolution weight shards per head across its three parts at TP4.
This commit is contained in:
John McDonough authored and StillDeadcode committed 2026-10-19 20:13:47 +02:00
1 parent 78c58841bf
commit 544753fc40
13 files changed
+1296 -61

No files matched your search

+16
View File
@@ -300,4 +300,20 @@ TEST(a_unit_inner_dimension_is_sharded_as_the_matrix_it_leaves) {
CHECK_EQ(weight_share(w, e, 3, stack, 2, 0, s, &why), RAD_E_SHAPE);
}
TEST(glm_kda_tp4_takes_each_head_shard_from_all_three_convolution_parts) {
const auto e = rad_enc_plain(RAD_BF16);
const auto w = decl(e, { 0 }, 3 * 8192, 4, RAD_SHARD_ROW, 4, { 2048, 2048, 2048 });
const int64_t shape[] = { 3 * 8192, 1, 4 };
for (int rank = 0; rank < 4; ++rank) {
PlaneShare s[RAD_ENC_MAX_PLANES];
REQUIRE_EQ(weight_share(w, e, 3, shape, 4, rank, s, nullptr), RAD_OK);
REQUIRE_EQ(s[0].rects.size(), (size_t)3);
for (int part = 0; part < 3; ++part) {
CHECK_EQ(s[0].rects[part].row0, (int64_t)(part * 8192 + rank * 2048));
CHECK_EQ(s[0].rects[part].rows, (int64_t)2048);
CHECK_EQ(s[0].rects[part].bytes, (int64_t)8);
}
}
}
RAD_TEST_MAIN()