add --split-output-tensor / -sot CLI parameter#2056
Draft
Nexesenex wants to merge 4 commits into
Draft
Conversation
Owner
If you want to do this, then please do it properly. The output normalization needs to be mirrored, and the |
Nexesenex
marked this pull request as draft
June 30, 2026 12:38
Contributor
Author
|
I will. Thanks for the hints! |
Nexesenex
force-pushed
the
arg_split_output_tensor
branch
from
June 30, 2026 13:06
436ea72 to
974f073
Compare
Adds a CLI flag to force-split the output tensor (output.weight, output_extra.weight) across GPUs when using split mode graph. When enabled, the output tensor is allocated on buft_matrix (split-capable buffer type) instead of buft_output, allowing it to participate in tensor parallelism. The output norm tensors remain on buft_output (except gemma4/gemma4_mtp, which also split output_norm). - common/common.h: split_output_tensor field in gpt_params - common/common.cpp: -sot / --split-output-tensor CLI arg, help, yaml - include/llama.h: split_output_tensor field in llama_model_params - src/llama-model.h: split_output_tensor flag in llama_model - src/llama.cpp: pass split_output_tensor to llm_load_tensors - src/llama-load-tensors.cpp: * LOADING_PRELUDE sets ctx_output_split conditionally * get_context_for_tensor skips -ot overrides for output tensor names * create_embd_output / create_default_embd_output use ctx_output_split * All architecture tensor functions use ctx_output_split for output * Single centralized log when split_output_tensor = ON
I mistakenly added routed output_norm for GEMMA4 and GEMMA4_MTP to ctx_output_split. output_norm is a 1D vector that gains no benefit from being split across GPUs and incurs unnecessary communication overhead. Reverted it to ctx_output instead.
Ikawrakow's review: output norm tensors remain on buft_output.buft (the per-device offload buft) instead of being on the split context. With -sot, the output weight IS split across devices, but the norm weights stay on a single device and never get mirrored. Fix: in get_context_for_tensor(), when split_output_tensor is on, route output_norm (and output_norm_bias, output.bias) to ctx_output_split (= split_buft context). This puts them in split_tensors so prepare_split_tensors(-1, ...) at tensor-load time creates per-device mirrored copies. build_output() already handles output_norm->extra correctly: line 2107 checks for it and line 2115 uses per-device norm copies when available.
Nexesenex
force-pushed
the
arg_split_output_tensor
branch
from
July 8, 2026 02:00
974f073 to
550fde8
Compare
…stead of per-site ctx_output_split Instead of changing ctx_output to ctx_output_split at 67 per-architecture create_tensor call sites, route output.weight, output_extra.weight, token_embd.weight (when ctx==ctx_output), output_norm.*, and output.bias through get_context_for_tensor(). This centralizes the split-output logic to a single location and reverts all per-site changes back to plain ctx_output.
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.
Adds a CLI flag to force-split the output tensor (output.weight,
output_extra.weight) across GPUs when using split mode graph. When
enabled, the output tensor is allocated on buft_matrix (split-capable
buffer type) instead of buft_output, allowing it to participate in
tensor parallelism. The output norm tensors remain on buft_output
(except gemma4/gemma4_mtp, which also split output_norm).
Note : @ikawrakow, we talked about it a while ago, but that was BEFORE
-wgt N(with a low value, up to 64 on GLM 4.5 Air), which solves the buffer inflation. And it can be activated or not. Works on my GLM model, performances are on par with the monolithic output, but VRAM management is much nicer, especially for heterogenous GPU setups like mine: I'm already VRAM tight for big MOEs!I'll be back tonight or tomorrow for corrections.