Commit 78e2964c2 for llama.cpp
commit 78e2964c23dc98e97d381bb1edb15cd82d3ecd65
Author: Johannes Gäßler <johannesg@5d6.de>
Date: Thu Oct 1 21:52:40 2026 +0200
llama: refer to segment documentation [no ci] (#29074)
diff --git a/ggml/include/ggml-backend.h b/ggml/include/ggml-backend.h
index cc3f8cd36..2a0957436 100644
--- a/ggml/include/ggml-backend.h
+++ b/ggml/include/ggml-backend.h
@@ -383,6 +383,7 @@ extern "C" {
// - most tensors have n_segments == 1 and a contiguous slice of the tensor data
// - some tensors have an inhomogenenous data layout along the split axis,
// those tensors are divided into segments which are each individually split across devices
+ // (this usually happens when multiple tensors are fused into a single one)
// - ne has one entry per segment and device and that segment repeats nr times,
// in total when accounting for repetitions the segments add up to ggml_tensor::ne for that axis,
// the outer/inner loops are over segments/devices like [seg0_dev0_r0, seg0_dev1_r0, seg0_dev0_r1, seg0_dev1_r1, seg1_dev0_r0, seg1_dev1_r0],
diff --git a/src/llama-model.cpp b/src/llama-model.cpp
index 404509888..742bcd5d5 100644
--- a/src/llama-model.cpp
+++ b/src/llama-model.cpp
@@ -604,8 +604,8 @@ struct ggml_backend_meta_split_state llama_meta_device_get_split_state(const str
return get_tensor_config_impl(GGML_BACKEND_SPLIT_AXIS_MIRRORED);
};
+ // if a model has fused tensors they need to be separated into "segments", see the comments on ggml_backend_meta_split_state struct
auto get_split_segments = [&](int axis, uint32_t il) -> std::vector<std::pair<int64_t, uint32_t>> {
- // TODO: clarify why this is necessary specifically for these models
// TODO: deduplicate condition [TAG_SPLIT_QGATE_QWEN]
if (ud->model->arch == LLM_ARCH_QWEN3NEXT || ud->model->arch == LLM_ARCH_QWEN35 || ud->model->arch == LLM_ARCH_QWEN35MOE ||
ud->model->arch == LLM_ARCH_QWEN4EXP) {