place: the caching layer -- hot VRAM cache, deposits, copyless relabels

Routing-aware reads leave a routed expert's bytes on the drive when the
pass routes nothing to it, but the reads that DO happen still have two
wasteful fates: they land in a per-pass buffer thrown away at the next
layer, and they cross the link even when the same bytes already sit in a
host pool slot that just went cold. This commit gives both bytes
somewhere to stay.

The hot VRAM cache: a routed expert whose read heat ranks past the
admission bar lands in a shadow slab slot and stays there. The slot is
its address from then on, until heat evicts it -- eviction is a copyless
relabel (back to Tier::SSD, publish null); the container is ground
truth. The planner budgets the shadow slots for it (per-class on_disk
count); the mover admits (Kind::Admit), evicts, and retires the
admissions.

Deposits: a free pool slot takes the O_DIRECT read directly -- the
read's destination IS the slot -- and the unit becomes a pool unit the
GEMM reads zero-copy, with heat promoting it at PCIe speed later. Its
demotion is a copyless drop (the slot still holds the bytes). A full
pool evicts its coldest unrouted unit by relabel, copyless, and the
freed slot feeds the next deposit.

The counters follow the traffic: the file stager's family is renamed
file_* -> ssd_* (ssd_layers, ssd_units, ssd_read_bytes, ssd_preads,
ssd_read_ns, ssd_wait_ns) beside the existing ssd_reads/ssd_bytes, and
the new legs are counted (ssd_staging_bytes, ssd_promotions and
ssd_promoted_bytes, ssd_deposits and ssd_deposit_bytes, pool_evictions).
The dashboard's expert plane gains the matching staging, promotions and
deposits rows, and --weights-disk-tier's help text names the tier.

Measured on GLM-5.3-Flash TP2 (2x Radeon R9700), 250-token essay at
temp 0: 5.49 tok/s at ~104 GiB of SSD reads per run, against main's
2.05 tok/s at ~378 GiB.

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 9efdd00c4c
commit 8da043c246
13 files changed
+485 -73

No files matched your search

+7 -5
View File
@@ -529,13 +529,15 @@ TEST(deterministic_mode_pins_placement_to_static) {
TEST(planner_reads_routed_experts_it_cannot_hold_from_the_container) {
/* Two routed layers of eight 1.5 MiB experts, a VRAM budget for a few and a host pool for
* two. With the file tier on, the rest go there and the plan still fits: they are served by
* reading the whole layer into one of two buffers charged to the same VRAM budget. */
* reading the whole layer into one of two buffers charged to the same VRAM budget. The
* budget also carries the unconditional hot cache — each resident expert may hold a shadow
* slot (up to the cap) — so it is sized for residents plus their shadow slots. */
Fixture f;
build_moe_layers(f, 2, 8, 1 * MiB, MiB / 2);
Config c = base_config();
c.placement = "expert_tiered";
c.vram_weights_mib = 24;
c.vram_weights_mib = 26;
/* The file staging reserve (four slots of the widest unit plus the read windows) and room
* for two pooled experts. */
const int64_t reserve = 4 * (MiB + MiB / 2) + RAD_PLACE_FILE_WINDOWS * RAD_PLACE_FILE_WINDOW_BYTES;
@@ -1448,9 +1450,9 @@ TEST(the_file_stager_reads_each_routed_layer_from_the_container) {
}
/* Three layers per pass, each at least two reads (the resident expert between the file-tier
* ones is skipped, not read), and every unit read once. */
CHECK_EQ(m.stats().file_layers, (uint64_t)(2 * L));
CHECK_EQ(m.stats().file_units, (uint64_t)(2 * L * 2));
CHECK(m.stats().file_preads >= (uint64_t)(2 * L * 2));
CHECK_EQ(m.stats().ssd_layers, (uint64_t)(2 * L));
CHECK_EQ(m.stats().ssd_units, (uint64_t)(2 * L * 2));
CHECK(m.stats().ssd_preads >= (uint64_t)(2 * L * 2));
rad_stream_sync(m.transfer_stream());
rad_stream_destroy(s);
std::remove(path.c_str());