place: routing-aware file-tier reads

The file tier read every file-tier unit of a routed layer whether or not
the router sent rows to it. A deep layer keeps whole experts on the drive
(288 per world), but a pass routes rows to a handful of them: the read
volume was ~18x what the router justified, and the engine streamed
~378 GiB from the SSD per run at 2.05 tok/s (GLM-5.3-Flash, TP2).

The layer's router has run by the time the stager triggers -- the
trigger is the layer's first expert op -- so the pass's route counts are
already on the device. Ctx::route_counts_device exposes them; the file
stager hands them to Mover::stage_file_units, and an expert counted
zero, which has no sorted rows and no GEMM run naming it, is left on the
drive: its weights are not read at all. Its table entries are published
at a valid dummy address (the calm region) for the pass and nulled again
with the staged units, because the kernels still issue the layer's table
and a null entry fails the step. Published even when EVERY unit of the
layer is skipped -- a decode step can route nothing to a layer.

The drafter's own weights (the "mtp." namespace) run on every draft pass
of every decode step, more often than anything a profile could rank, so
the planner pins them in the host pool ahead of everything ranked
(MoveUnit::draft_head) instead of letting the expert fill push them to
the file tier every step.

Read extents are also clamped to the container file's size, so a
truncated container fails a read loudly instead of reading past EOF.

Measured on GLM-5.3-Flash TP2 (2x Radeon R9700), 250-token essay at
temp 0: 3.4-3.6 tok/s where main gives 1.42 on the same prompt.

Assisted-by: GLM-5.3-Flash
This commit is contained in:
overchop authored and StillDeadcode committed 2026-10-30 15:02:09 +01:00
1 parent 9647b84ee0
commit 9efdd00c4c
9 files changed
+208 -24

No files matched your search

+15
View File
@@ -773,6 +773,21 @@ const RadRouting* Ctx::last_routing(int layer) const {
return route_[(size_t)layer].reported >= 0 ? &route_[(size_t)layer].routing : nullptr;
}
const int32_t* Ctx::route_counts_device(int layer, int64_t* n_expert) const {
if (n_expert) *n_expert = 0;
if (layer < 0 || (size_t)layer >= route_.size()) return nullptr;
const RouteSlot& s = route_[(size_t)layer];
/* No step gate: route_report lands at the END of the block's passes (heat consumes it a
* step later), but the reported buffer is the block's own ecnt, whose CONTENT the router
* kernel rewrote this pass -- and the file stager's trigger runs after that router on the
* same stream, so a stream-ordered copy reads this pass's counts. The counts are indexed
* by the rank's local expert slot (the kernel subtracts expert_base), which is also what
* the mover's units carry. */
if (!s.routing.expert_count || s.reported < 0) return nullptr;
if (n_expert) *n_expert = s.routing.n_expert ? s.routing.n_expert : route_n_expert_;
return s.routing.expert_count;
}
/* ================================================================== profiling (spec §16) */
int Ctx::bind_profiling() {