Repository navigation
feat(llama): Model::upload_expert — K3 slice-2 Model-A weight-write primitive - #2040
Merged
Merged
Conversation
…rimitive The per-expert weight-WRITE the genome path (#226 specialize an expert via LoRA, #228 surgical training) consumes. Replaces expert `expert_index`'s weights in the three resident stacked MoE projection tensors (blk.{layer}.ffn_{gate,up,down}_exps) with the given bytes, via the shipped llama_model_get_tensor (#2039) + ggml_backend_tensor_set. Offset is computed from each LIVE tensor's own nb[2] (ggml's quant-aware per-expert stride, expert dim outermost of {n_embd,n_ff,n_expert}) — no parsed-stride guessing, correct for any quant. This is weight-REPLACEMENT into a loaded model (full tensor resident), NOT paging — per the decided slice-2 split (roadmap Phase B.A): A = weight-write (this, now, feeds the genome); B = true K-slot per-expert paging (needs a router remap primitive, a kernel fork, gated on Gate-A numbers — BigMama holds LiveUploadPager for it). Fail-loud: absent tensor / expert out of range / byte-len ≠ live stride. Compile-validated; behavioral validation is Gate B (needs a loaded MoE). Dormant — nothing calls it until the genome path does. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
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.
The per-expert weight-write the genome path consumes
Model::upload_expert(layer, expert_index, gate, up, down)replaces one expert's weights in the three resident stacked projection tensors (blk.{layer}.ffn_{gate,up,down}_exps) of a loaded model — via the shippedllama_model_get_tensor(#2039) + the already-publicggml_backend_tensor_set.nb[2](ggml's quant-aware per-expert stride) — no parsed-stride guessing, correct for any quantization.expert_indexout of range, or byte-len ≠ the live stride.The decided split (roadmap Phase B, with BigMama)
The MoE kernel indexes the stacked tensor by the router's logical expert id, so writing at slot
expert_indeximplies the full tensor is resident. Therefore:page_in/evictis meaningless when all slots are resident.get_tensor). That's whereLiveUploadPagerlives; gated on Gate-A numbers (only build the fork if cold-CPU-compute measurably bottlenecks the K3 persona). BigMama holds it.Scope
Compile-validated (llama crate builds clean against the #2039 shim). Dormant — nothing calls it until the genome path does; behavioral validation is Gate B on a loaded MoE.
🤖 Generated with Claude Code