Repository navigation
feat(capacity): PlacementRequest + layer-granular residency — slice-1 buft-override seam - #2037
Merged
Merged
Conversation
…ce-1 buft-override seam The K3 relaunch places experts via llama.cpp -ot, which places WHOLE stacked tensors (blk.N.ffn_*_exps = all of layer N's experts in one blob). So slice-1 placement is LAYER-granular, not per-expert (per-expert is slice-2's upload fork). This lands the pager's half of the seam with M5's -ot builder (#2036): - plan_layer_residency (expert_residency.rs): aggregates the per-expert priority (the ONE ranking authority) to a per-layer score, fits whole layers by layer_bytes (= expert_bytes * n_experts_per_layer) within the 0.80 serving VRAM budget. Returns real blk.N indices, ascending. Degenerate-safe (unsized → place nothing). The pager owns the fit so the launcher never overflows. - PlacementRequest { gguf_id, n_layers, hot_layers } (placement.rs): the shared seam type M5's llama_server.rs consumes — hot_layers = GPU-resident blk.N, complement -ot'd to CPU; n_layers = total block count (the -ot ceiling). - ServingExpertPager::tick_layer_placement + mark_layer_relaunched (serving_pager.rs): the slice-1 driver pass — builds the decayed+predicted activation (shared with the per-expert tick via current_activation), plans hot layers, and decides relaunch on hot-layer-set churn beyond the threshold (a process respawn reloads every weight, so a 1-layer flap must not thrash it). LayerPlacementOutcome carries the request + needs_relaunch. Seam locked with M5 on airc: I own the VRAM fit, she owns the -ot args + the ServingTarget.expert_placement relaunch diff. Two new tests pin the layer fit and the driver relaunch-signal. cargo check --lib --tests clean on the 5090 (capacity files); the only build errors are the pre-existing tests/ unix harness (Windows). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
joelteply
added a commit
that referenced
this pull request
Jul 27, 2026
…K3 slice-1 consumer) Completes my consumer half of the buft-override relaunch joint. ServingTarget now carries Option<PlacementRequest> (BigMama's #2037 seam type); ServingTarget::expert_ot_value() delegates to cold_expert_offload_ot(hot_layers, n_layers); and the spawn Command build injects --override-tensor <value> right after --lora when a placement is present (None / all-hot → no flag, since llama-server rejects an empty -ot). The relaunch on a hot-set change is DECIDED by the pager (serving_pager's relaunch_needed), NOT the probe-based ensure_model_serving diff — there is no API to read a running server's -ot, so the placement can't be probed; the pager tracks served-vs-desired and drives the respawn, which rebuilds the ServingTarget with the new placement and this applies it. All existing ServingTarget construction sites default expert_placement: None (eval lanes run the whole model; the base serving target starts unpaged). The one remaining bridge — the ServingExpertPager attaching Some(placement) to the live lane's target — is BigMama's serving_pager lane; the consumer is ready for it. NOTE: this branch temporarily merges feat/layer-placement-seam (#2037) for the PlacementRequest type; rebases onto canary once #2037 lands (dropping the merged commits). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Jul 27, 2026
…physical expert paging (#2036) * feat(inference): cold_expert_offload_ot — the -ot builder for K3 slice-1 physical expert paging My half of the buft-override relaunch joint (#22, with BigMama's ServingExpertPager). Experts are STACKED per layer (blk.N.ffn_*_exps is one tensor = all that layer's experts), so -ot/--override-tensor — which places WHOLE tensors — pages MoE experts at LAYER granularity. The residency planner owns the VRAM fit and produces PlacementRequest.hot_layers (the real blk.N indices that fit GPU); this emits the inverse: cold = (0..n_layers) minus hot_layers, offloaded to CPU as one -ot value `blk\.(c1|c2|..)\.ffn.*_exps=CPU`. Robustness by construction: dense (non-MoE) blocks in the range are HARMLESS — they have no ffn_*_exps tensor so their pattern is inert, which is why the builder needs only the hot set + the total block count, never the exact MoE-layer set. Block index is `\.`-anchored on both sides so blk.3 never matches blk.31; the pattern covers all four stacked projections (gate/up/down/gate_up). Returns None when nothing is cold (never an empty -ot, which llama-server rejects) — the caller omits the flag. Pure + unit-tested (mixed hot/cold, all-hot→None, empty-hot→all, out-of-range hot ignored, zero layers→None). The wiring — ServingTarget.expert_placement + the -ot injection at the Command build + the relaunch diff beside adapter_paths() — lands when BigMama's PlacementRequest struct merges. True per-expert paging (no relaunch) is slice-2: a ~5-line llama.cpp fork exposing the internal llama_model::get_tensor + the already-public ggml_backend_tensor_set sub-range upload. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * feat(capacity): PlacementRequest + layer-granular residency — the slice-1 buft-override seam The K3 relaunch places experts via llama.cpp -ot, which places WHOLE stacked tensors (blk.N.ffn_*_exps = all of layer N's experts in one blob). So slice-1 placement is LAYER-granular, not per-expert (per-expert is slice-2's upload fork). This lands the pager's half of the seam with M5's -ot builder (#2036): - plan_layer_residency (expert_residency.rs): aggregates the per-expert priority (the ONE ranking authority) to a per-layer score, fits whole layers by layer_bytes (= expert_bytes * n_experts_per_layer) within the 0.80 serving VRAM budget. Returns real blk.N indices, ascending. Degenerate-safe (unsized → place nothing). The pager owns the fit so the launcher never overflows. - PlacementRequest { gguf_id, n_layers, hot_layers } (placement.rs): the shared seam type M5's llama_server.rs consumes — hot_layers = GPU-resident blk.N, complement -ot'd to CPU; n_layers = total block count (the -ot ceiling). - ServingExpertPager::tick_layer_placement + mark_layer_relaunched (serving_pager.rs): the slice-1 driver pass — builds the decayed+predicted activation (shared with the per-expert tick via current_activation), plans hot layers, and decides relaunch on hot-layer-set churn beyond the threshold (a process respawn reloads every weight, so a 1-layer flap must not thrash it). LayerPlacementOutcome carries the request + needs_relaunch. Seam locked with M5 on airc: I own the VRAM fit, she owns the -ot args + the ServingTarget.expert_placement relaunch diff. Two new tests pin the layer fit and the driver relaunch-signal. cargo check --lib --tests clean on the 5090 (capacity files); the only build errors are the pre-existing tests/ unix harness (Windows). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc * feat(inference): wire ServingTarget.expert_placement → -ot at spawn (K3 slice-1 consumer) Completes my consumer half of the buft-override relaunch joint. ServingTarget now carries Option<PlacementRequest> (BigMama's #2037 seam type); ServingTarget::expert_ot_value() delegates to cold_expert_offload_ot(hot_layers, n_layers); and the spawn Command build injects --override-tensor <value> right after --lora when a placement is present (None / all-hot → no flag, since llama-server rejects an empty -ot). The relaunch on a hot-set change is DECIDED by the pager (serving_pager's relaunch_needed), NOT the probe-based ensure_model_serving diff — there is no API to read a running server's -ot, so the placement can't be probed; the pager tracks served-vs-desired and drives the respawn, which rebuilds the ServingTarget with the new placement and this applies it. All existing ServingTarget construction sites default expert_placement: None (eval lanes run the whole model; the base serving target starts unpaged). The one remaining bridge — the ServingExpertPager attaching Some(placement) to the live lane's target — is BigMama's serving_pager lane; the consumer is ready for it. NOTE: this branch temporarily merges feat/layer-placement-seam (#2037) for the PlacementRequest type; rebases onto canary once #2037 lands (dropping the merged commits). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The pager's half of the slice-1 buft-override seam with M5's
-otbuilder (#2036).-otplaces whole stacked tensors (blk.N.ffn_*_exps= all of layer N's experts), so slice-1 placement is layer-granular (per-expert is slice-2's upload fork).plan_layer_residency— aggregates the per-expert priority (the one ranking authority) to a per-layer score, fits whole layers bylayer_byteswithin the 0.80 serving VRAM budget. Realblk.Nindices, ascending. The pager owns the fit, so the launcher never overflows.PlacementRequest { gguf_id, n_layers, hot_layers }— the shared seam typellama_server.rsconsumes:hot_layers= GPU-residentblk.N, complement-ot'd to CPU.ServingExpertPager::tick_layer_placement+mark_layer_relaunched— the slice-1 driver pass: builds the decayed+predicted activation (shared with the per-experttickviacurrent_activation), plans hot layers, decides relaunch on hot-layer churn beyond the threshold (a respawn reloads every weight — a 1-layer flap must not thrash it).Seam
Locked with M5 on airc: I own the VRAM fit, she owns the
-otargs +ServingTarget.expert_placementrelaunch diff. Hercold_expert_offload_ot(hot_layers, n_layers)(#2036) plugs straight intoPlacementRequest.hot_layers.Tests
Two new: the layer fit (hottest layers by aggregate priority, fit by layer_bytes) and the driver relaunch-signal (first placement relaunches, stable set goes quiet).
cargo check --lib --testsclean on the 5090 for the capacity files.🤖 Generated with Claude Code