[BUG] Multi-GPU tensor-split offloads all physical layers to GPU0 on looped architectures
还没有人认领这个 Issue。
评估
调研方向
Start in src/llama-model.cpp at llama_model_base::create_tensor, where tn.bid (the GGUF physical block id) indexes pimpl->dev_layer, which is sized to n_layer_all; read loop_visit and loop_layer in the hparams/model code to confirm the mapping described. Apply the proposed change so the index goes through hparams.loop_visit(tn.bid) and check that non-looped models still get identity mapping. Done means a looped model loaded with --tensor-split places postlude blocks on the second GPU and no CUDA0 OOM occurs, which needs multi-GPU hardware.
由索引模型根据 Issue 内容生成。
描述
[BUG] Multi-GPU tensor-split offloads all physical layers to GPU0 on looped architectures
Description
When loading a looped model (such as Inkling-2-Mini, where 24 physical layers expand to 48 graph execution layers) with --tensor-split across multiple GPUs, all physical layers are erroneously assigned to device 0 (CUDA0), starving secondary GPUs (CUDA1) and causing an immediate out-of-memory crash:
ggml_backend_cuda_buffer_type_alloc_buffer: allocating 11383.97 MiB on device 0: cudaMalloc failed: out of memory
ggml_backend_buft_alloc_buffer_n_default: failed to allocate CUDA0 buffer of size 11936954112
Root Cause
-
In GGUF files for looped models, physical layer blocks are numbered
blk.0toblk.23(n_layer_weights = 24), whereas the graph execution sequence containsn_layer_all = 48layers:0..5: prelude (physical0..5)6..17: loop pass 0 (physical6..17)18..29: loop pass 1 (physical6..17)30..41: loop pass 2 (physical6..17)42..47: postlude (physical18..23)
-
In
llama_model_base::create_tensor:if (tn.bid != -1) { buft_list_layer = (size_t) tn.bid < pimpl->dev_layer.size() ? pimpl->dev_layer.at(tn.bid).buft_list : pimpl->dev_output.buft_list; }Here
tn.bidis the physical block index in the GGUF file (0..23).
pimpl->dev_layeris sized ton_layer_all(48), wherepimpl->dev_layer[il] = get_layer_buft_list(loop_layer(il)).When
create_tensoris called for postlude physical blocks18..23:
It indexesdev_layer.at(tn.bid), which evaluates todev_layer.at(18..23).
Because graph slots18..23are pass 1 of the looped core,loop_layer(18..23)maps to6..11(GPU0).
Consequently, physical layers18..23(which were intended for GPU1) receive the device assignment of physical layers6..11(GPU0).
Physical layers0..17are also mapped to0..17(GPU0).
Thus, all 24 physical layers in the file are allocated on GPU0, regardless of--tensor-split.
Proposed Fix
In src/llama-model.cpp:
Map tn.bid to its canonical graph visit slot via hparams.loop_visit(tn.bid):
ggml_tensor * llama_model_base::create_tensor(llama_model_loader & ml, const LLM_TN_IMPL & tn, const std::initializer_list<int64_t> & ne, int flags) {
const buft_list_t * buft_list_layer = nullptr;
if (tn.bid != -1) {
// blocks that are not model layers (e.g. the blocks of a head) go with the output
const size_t iv = (size_t) hparams.loop_visit(tn.bid);
buft_list_layer = iv < pimpl->dev_layer.size() ? pimpl->dev_layer.at(iv).buft_list : pimpl->dev_output.buft_list;
}
return ml.create_tensor(
hparams, &pimpl->cpu_buft_list, pimpl->dev_input.buft_list, pimpl->dev_output.buft_list, buft_list_layer,
tn, ne, flags);
}
For non-looped models, loop_visit(tn.bid) == tn.bid, preserving existing behavior.
For looped models, loop_visit(18..23) yields 42..47, correctly retrieving the device placement assigned to the postlude layers.
- 主要语言
- C++
- 星标
- 1.2k
- 派生
- 80
- 平均合并
- 4 天 20 小时
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Anbeeld/beellama.cpp 的其他 Issue
-
[BUG] KVarN assertion failure in build_inp_mem_hybrid_iswa() due to uninitialized self_kvarn_rot未关闭
难度 2/5 1-3 小时 新手友好度 68/100
Anbeeld/beellama.cpp#205 ·
-
难度 3/5 1-2 天 新手友好度 57/100
Anbeeld/beellama.cpp#204 ·
-
难度 4/5 3-5 天 新手友好度 45/100
Anbeeld/beellama.cpp#203 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
Anbeeld/beellama.cpp#202 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
Anbeeld/beellama.cpp#200 ·
查看 Anbeeld/beellama.cpp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
CachyOS/packageinstaller#144 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 82/100
TomerAberbach/profiler-md#951 ·
维护者通常 1 天内回复
-
[Bug] Default key routing (JavaStringHash) picks a different partition than the Java client for about half of keys可能已有人在做 @0z5a 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
apache/pulsar-client-go#1575 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
pocoproject/poco#5764 ·
维护者通常 2 天内回复
-
bug cpp-core-guidelines low-priority
难度 2/5 1-3 小时 新手友好度 62/100
NatronGitHub/openfx-supportext#164 ·
维护者通常 1 天内回复