Skip to content

Commit d384d93

Browse files
kmbandyclaude
andcommitted
fix(wp): anchor paged weights to pool_buf so view-only leaves get a backend
A paged weight consumed ONLY via a reshape/view (not a direct matmul src) inherited buffer_id -1 from ggml_backend_sched_split_graph pass 4: the view's id comes from its view_src (paged leaf, buffer==NULL -> -1), then the src loop assigns the leaf = the view's still-(-1) id before the view's own fallback runs. gallocr then asserts buffer_id>=0 on that leaf (before its data!=NULL skip). This crashed every DeepSeek V4 paged load (wo_a = ggml_reshape_3d(...)->mul_mat), and recurs for any arch that reshapes weights. Set paged weights' buffer=pool_buf at init so the scheduler can name a backend; gallocr still skips them (data!=NULL), eval_cb still re-patches ->data per op. Matches the steady state eval_cb already creates (it sets ->buffer=pool_buf on every patch). Root-caused via codex+Fable consults converging on ggml-backend.cpp:1217-1241. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ZRfPpL8XFzk1hep9MMg9P
1 parent 3faad72 commit d384d93

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/llama.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,17 @@ static bool init_weight_pager(llama_model & model, llama_model_loader & ml, cons
284284
continue;
285285
}
286286
t->data = placeholder;
287-
t->buffer = nullptr;
287+
// Anchor paged weights to the pool's device buffer so the backend
288+
// scheduler can name a backend for them (buffer_id) even when a
289+
// weight is reached only as a reshape/view's view_src — a leaf with
290+
// buffer==NULL whose sole consumer is a view op falls through every
291+
// split_graph assignment pass and gets buffer_id -1, tripping the
292+
// gallocr assert (DeepSeek V4 wo_a = ggml_reshape_3d(...)->mul_mat).
293+
// gallocr still skips it (is_allocated checks data != NULL first);
294+
// eval_cb re-patches ->data (and already sets ->buffer = pool_buf)
295+
// per op. This just brings load-time state to the post-first-decode
296+
// steady state the eval_cb already produces.
297+
t->buffer = pool_buf;
288298
++n_placed;
289299
}
290300
LLAMA_LOG_INFO("%s: placeholder data set on %zu weight tensors (placeholder=%p, skipped %zu not in catalog)\n",

0 commit comments

Comments
 (0)