budget: an uneven world's cheaper rank pages the common tokens and keeps its experts

The resolver derives one split, the dearest rank's, for every card, and one
block table serves every rank. An attention-zero rank keeps no attention cache:
at TP3 on Flash-Next it pages the common 1.45M tokens in ~1.8 GiB of its
10.6 GiB KV pool, the rest is an address reservation nothing ever commits or
lends, and 1091 of its experts can never reach the card even with the cache
idle.

Such a rank now gets a KV pool that pages exactly the common token count (the
new KVManager::pool_mib_for_tokens, the inverse of paged_tokens, plus a 64 MiB
margin) and the difference in its weights pool, no further than every weight
resident. The per-rank split reaches BOTH readers of the resolved sizes --
Pools::configure and the planner -- so the grown pool is planned into. The
token count, the carve, the loan and the dearest ranks' pools are unchanged;
configure_kv names it if a re-sized pool ever binds.

Only a derived split under expert_tiered is re-split: a stated pool is the
operator's, and under auto a fully resident rank would choose all_vram while
its peers spill. Where every rank's cache costs the same -- every world the
heads divide -- no rank qualifies and every rank takes cfg_ as before.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-07 11:09:36 +02:00
1 parent 6fd7421f79
commit 33778b2b8c
10 files changed
+242 -11

No files matched your search

+18
View File
@@ -38,6 +38,24 @@ it, and the tiers skip it when they move an entry. Every rank carves the same bl
is planned, asked what it could page (`KVManager::paged_tokens`; a rank whose only paged groups are
zero limits nobody) and capped at the least before any carves.
**The attention-zero rank's pools are its own.** The budget resolver derives one split for every
card, the dearest rank's -- and an attention-zero rank's cache costs a fraction of its peers' per
token (at TP3 on Flash-Next it keeps only the QSA block keys: 2.3 GiB at the worst case where an
attention rank's costs 15.2). Under `expert_tiered` with both pools derived, `Engine::plan` gives
such a rank a KV pool that pages exactly the common token count (`KVManager::pool_mib_for_tokens`,
the inverse of `paged_tokens`, plus a 64 MiB margin) and moves the difference into its weights pool,
no further than every one of its weights resident. Both readers of the resolved sizes take the
rank's own split -- `Pools::configure` and the planner -- so the grown pool is planned into. The
token count, the carve, the loan and the attention ranks' pools are unchanged; a stated
`--vram-kv-mib` / `--vram-weights-mib` keeps meaning "this many on every card", and `auto` keeps the
common split (a fully resident rank would choose all_vram while its peers spill). At TP2/TP4 every
rank costs the same and nothing is re-split. The log line, and its effect on the third rank:
```
kv: rank 2's cache costs 2.27 GiB at the worst case where its dearest peer's costs 15.16 GiB, so its KV pool pages the common 1446302 tokens in 1875 MiB instead of 10881; its weights pool grows 19747 -> 21692 MiB (every weight resident wants 21.18 GiB), and 7061 MiB stay unclaimed
I[2] mover: 25142 slab slots (64 shadow), 0 pinned pool slots (was 22479 slots, 2663 pinned)
```
Under a smaller attention world the plain even shard over `world` is the wrong cut for every
attention projection, so the attention ranks declare **spans** (`rad_weight_shard_span`, the same
call the KV replication uses for k/v): q|gate rows and output columns `[attn_rank * n_head,