glm5next: experts split by width at four ranks and up, whole for the file tier

Whole experts on their rank let the routed weights live on the drive, which
a two-card host needs, but at four and eight ranks they leave the shapes the
MXFP4 kernels are tuned for: glm_prefill wants 288 experts an op and finds 72.
On 4 x R9700 that cost prefill two thirds and four-stream throughput 37%.

Keep the width split at four ranks and up, as the kernels expect, and take
whole experts at two ranks or when --weights-disk-tier needs them (ABI 37,
RadBuildCtx::expert_file_tier). The file tier's graph at eight ranks keeps
main's pin, and the route-count fix that came with expert parallelism stays.
This commit is contained in:
AnimusNull authored and AnimusNull committed 2026-11-05 14:19:17 +00:00
1 parent b954585f9f
commit 8ef50a7708
8 files changed
+56 -29

No files matched your search

+3 -2
View File
@@ -1,4 +1,4 @@
/* abi_layout_table.h -- every abi/ struct's size and field offsets at RAD_ABI_VERSION 36 and
/* abi_layout_table.h -- every abi/ struct's size and field offsets at RAD_ABI_VERSION 37 and
* RAD_FORMAT_VER 2, as { type, field, offset, size } rows ("" is the struct itself). A snapshot
* of the headers on x86-64 Linux, which abi_layout_test.cpp holds the layout to; regenerate it
* from the test's printout only together with a version bump. */
@@ -109,7 +109,7 @@
{ "RadBufDecl", "domain", 60, 4 },
{ "RadBufDecl", "derive", 64, 8 },
{ "RadBufDecl", "kv", 72, 4 },
{ "RadBuildCtx", "", 0, 200 },
{ "RadBuildCtx", "", 0, 208 },
{ "RadBuildCtx", "rank", 0, 4 },
{ "RadBuildCtx", "world_size", 4, 4 },
{ "RadBuildCtx", "max_tok", 8, 8 },
@@ -142,6 +142,7 @@
{ "RadBuildCtx", "calib_tokens", 176, 8 },
{ "RadBuildCtx", "gen_max_pixels", 184, 8 },
{ "RadBuildCtx", "gen_max_refs", 192, 8 },
{ "RadBuildCtx", "expert_file_tier", 200, 4 },
{ "RadAudioGenBatch", "", 0, 344 },
{ "RadAudioGenBatch", "n_lane", 0, 8 },
{ "RadAudioGenBatch", "lane", 8, 8 },
+3 -3
View File
@@ -8,7 +8,7 @@
*
* Checked: a C translation unit (abi_c_test.c, strict C11) lays every struct out as C++ does; every
* struct's listed fields account for its size, so the list in rad_abi_layout_rows.h is complete; and
* the layout agrees with the table below, taken at RAD_ABI_VERSION 36 and RAD_FORMAT_VER 2. Under
* the layout agrees with the table below, taken at RAD_ABI_VERSION 37 and RAD_FORMAT_VER 2. Under
* those versions a listed field may not move or change size, an ABI struct may only grow by fields
* past its old end, and an on-disk struct may not change at all. The table is a snapshot of the
* headers: nothing else states the layout. When it disagrees the test prints the live table.
@@ -58,8 +58,8 @@ std::vector<Row> cpp_rows() {
};
}
/* The layout at RAD_ABI_VERSION 36 / RAD_FORMAT_VER 2 (see the file header). */
constexpr uint32_t kTableAbi = 36, kTableFormat = 2;
/* The layout at RAD_ABI_VERSION 37 / RAD_FORMAT_VER 2 (see the file header). */
constexpr uint32_t kTableAbi = 37, kTableFormat = 2;
const AbiRow kTable[] = {
#include "abi_layout_table.h"
};
+13 -6
View File
@@ -1788,6 +1788,7 @@ TEST(glm53_is_the_pinned_graph_and_steps) {
int world;
uint64_t graph, steps;
bool heads_only = false; /* the default: the graph before the row form */
bool file_tier = false; /* --weights-disk-tier: whole experts at four ranks and up */
};
/* Pins from this test's own `pin:` printout: the head form (heads_only, which declares the
* streamed ops) and the row form, at one and eight ranks. Re-recorded after every graph
@@ -1795,10 +1796,15 @@ TEST(glm53_is_the_pinned_graph_and_steps) {
* expert ops, and the graphs again when the routing counts became RAD_BUF_PERSIST (the
* steps did not change). */
const Case cases[] = { { 1, 0xce4368c09bfdbbeeull, 0x19679d4fcc0321ebull },
/* World 8 is this branch's expert-parallel graph (288/world whole
* experts, file-direct), so its pins differ from main's. */
{ 8, 0x553f81a93cec76bfull, 0x17f0a90d3bed9713ull },
{ 8, 0x9685be82c8d55813ull, 0x75e775f0568636b5ull, true } };
/* Two ranks keep whole experts; four and eight split them by width. */
{ 2, 0xab04b95724840abeull, 0x76865603b1390635ull },
{ 4, 0xfdee91cd1c985b0aull, 0xde7ebe5b604c3cd2ull },
{ 8, 0x59112e7ad7d77fdeull, 0xb9c29d30003a6df7ull },
{ 8, 0xf1bb904ab21d8813ull, 0xfb28d3dcd8ec5ae1ull, true },
/* The file tier's whole experts, file-direct, at four and eight. */
{ 4, 0x1918906f91fad4e7ull, 0x07d518b9a0f32986ull, false, true },
{ 8, 0x553f81a93cec76bfull, 0x17f0a90d3bed9713ull, false, true },
{ 8, 0x9685be82c8d55813ull, 0x75e775f0568636b5ull, true, true } };
for (const Case& cs : cases) {
RadBuilder b;
b.kv_block = 4;
@@ -1815,11 +1821,12 @@ TEST(glm53_is_the_pinned_graph_and_steps) {
ctx.max_seqs = 8;
ctx.max_ctx = 200000;
ctx.tp_attn_rows = cs.heads_only ? 0 : 1;
ctx.expert_file_tier = cs.file_tier;
REQUIRE_EQ(glm5next::declare(&b, &meta, &ctx), RAD_OK);
const uint64_t g = graph_hash(b);
const uint64_t s = pinned_steps(b, glm5next::step, 0, cs.world);
fprintf(stderr, " pin: glm5next world %d%s: graph 0x%016llxull, steps 0x%016llxull\n",
cs.world, cs.heads_only ? " heads only" : "",
fprintf(stderr, " pin: glm5next world %d%s%s: graph 0x%016llxull, steps 0x%016llxull\n",
cs.world, cs.heads_only ? " heads only" : "", cs.file_tier ? " file tier" : "",
(unsigned long long)g, (unsigned long long)s);
CHECK_EQ(g, cs.graph);
CHECK_EQ(s, cs.steps);