Repository navigation
llama : looped layers, device placement by weight layers and host weight views - #396
danielhanchen wants to merge 7 commits into
Conversation
… give later visits their own host weight views Device placement: n_gpu_layers and the tensor splits counted every cache slot, while the weights exist once per physical layer. On Inkling-2-Mini (48 slots, 24 physical layers) `-ts 1,1` put every weight on the first GPU and ran 23 later visits on the second, and `-ngl N` offloaded slots instead of layers. A model now reports the layer whose weights each layer uses (layer_weights), the splits count the layers that hold weights, and every slot runs on the device of its weights. llama_model_n_layer_weights() gives common/fit the same unit. Host weight views: the backend scheduler keys the device copy of a host weight (op offload) by tensor, so with experts or layers on the CPU every later visit of a shared weight read the copy of the first visit and the output was NaN. The later users of a shared host weight now get views of it, each with its own copy. Views keep the name and the buffer, the Hadamard and precision state keyed by tensor is given to them, and the saver writes each weight once. Models without shared layer weights are unchanged.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d96a8345a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The backend scheduler keys the device copy of a host weight (op offload) by tensor, so with one tensor for every | ||
| // visit the later visits read the copy of the first one, which is wrong once its memory is reused, and the copies of |
There was a problem hiding this comment.
Remove mid-sentence wrapping from the shared-weight comment
The new explanation hard-wraps several sentences across comment lines, contrary to the explicit rule in AGENTS.md prohibiting mid-sentence line breaks. Shorten the explanation where possible and keep each sentence on an unsplit line.
AGENTS.md reference: AGENTS.md:L84-L84
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in bff7247. The comment is shorter now, with each sentence on its own line. Only the comment changed.
Since ggml-org#32669 build_lora_mm and build_lora_mm_id look the .scale of a weight up by tensor (llama_model::w_scales) instead of taking the layer's *_s tensor. The per-visit views of shared host weights are new tensors, so the later visits of a looped layer lost their NVFP4 scales. Map each view to the view of its scale in the same layer, as the *_s fields were before.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Repinned to
The PR base moves to Evidence, B200:
All arms give the same PPL, mean KLD 0 (printed as -0.000000) and top-1 100%, so the gate passes. ( This PR on its own cannot load the published Inkling-2-Mini GGUFs (they need #395 for the looped layout), so the gate runs on the merged pin set. A = current
|
Fixes partial offload and multi-GPU placement for models whose loop layers are cache slots sharing the weights of physical layers (
inkling2_loop).--cpu-moe,-ngl 12and-ngl 0no longer produce NaN logits.-ngland-tscount physical layers (24 on Inkling-2-Mini, not 48 slots);llama_model_n_layer_weights()givescommon/fitthe same unit.Tests (b12600 + ggml-org#32704 + ggml-org#32218 + this), wikitext-2, 20 chunks of 512, against full single-GPU:
--cpu-moeand-ngl 12: max KLD at the run-to-run floor (0.000053), top-1 100%. Before: NaN.-ts 1,1on 2 GPUs: no slot placed off its weights' device, scheduler splits 419 -> 17.test-llama-archs: all configs pass on CPU and CUDA.