From df18bee11e96557b07aa7b12db0976f3c7ac9165 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 14 Oct 2026 08:30:00 +0200 Subject: [PATCH] model: split layers evenly when no device reports free memory (#29677) When every device reports zero free memory the split points are normalized by a zero sum, the NaN split sends layers to a device index past the end and loading aborts with vector::_M_range_check. --- src/llama-model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llama-model.cpp b/src/llama-model.cpp index aeab7b75b..923c2c0a2 100644 --- a/src/llama-model.cpp +++ b/src/llama-model.cpp @@ -1645,7 +1645,7 @@ bool llama_model_base::load_tensors(llama_model_loader & ml) { splits[i] = split_sum; } for (size_t i = 0; i < n_devices(); ++i) { - splits[i] /= split_sum; + splits[i] = split_sum != 0.0f ? splits[i] / split_sum : float(i + 1) / n_devices(); } const int i_gpu_start = std::max(n_layer_all + 1 - n_gpu_layers, 0);