Skip to content

llama : reserve graph nodes for the MoE cache - #32636

Merged
am17an merged 1 commit into
ggml-org:masterfrom
am17an:moe-cache-max-nodes
Nov 20, 2026
Merged

am17an merged 1 commit into
ggml-org:masterfrom
am17an:moe-cache-max-nodes

Conversation

@am17an

@am17an am17an commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Overview

Fixes #32584.

graph_max_nodes() does not account for the nodes the MoE cache adds to each MoE layer: the slot lookup (plus the supports_op probe tensors), and with --moe-cache-cpu-share a second expert path. Archs on the 32x/64x budgets have enough headroom, but cohere2moe uses the default 8*n_tensors and has few tensors per layer (443 tensors, 49 layers -> 3544). Combined with a quantized KV cache (K/V rotation adds nodes too), the graph context runs out of space:

llama-completion -m North-Mini-Code-1.0-UD-IQ4_NL.gguf -ngl 99 --cpu-moe -ctk q8_0 -ctv q8_0 --moe-cache-mib 2048 ...
ggml/src/ggml.c:1823: GGML_ASSERT(obj_new) failed
  ggml_new_tensor <- ggml_scale <- llama_model_cohere2moe::graph::graph <- graph_reserve <- resolve_fused_ops <- sched_reserve

Graph-context tensors used, measured on GB10:

config tensors
f16 KV ~2757
q8_0 KV ~3345
f16 KV + MoE cache ~3189
q8_0 KV + MoE cache ~3777 (> 3544, abort)
q8_0 KV + MoE cache + cpu-share 0.5 ~4113 (abort)

This adds 32*n_layer_all nodes when the MoE cache is enabled. That covers the ~16 tensors per MoE layer of the worst case, with 2x margin.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES - Claude was used to reproduce and locate the crash, write the fix, and draft this description. I reviewed the change.

The MoE cache adds a slot lookup to every MoE layer, and with
--moe-cache-cpu-share a second expert path, but graph_max_nodes() did
not account for it. Models on the default 8*n_tensors budget with few
tensors per layer (cohere2moe: 443 tensors, 49 layers) overflow the
graph context when the cache is combined with a quantized KV cache
(K/V rotation), aborting in ggml_new_tensor with GGML_ASSERT(obj_new).

Fixes ggml-org#32584

Assisted-by: Claude Opus 5.5
@am17an
am17an marked this pull request as ready for review November 20, 2026 03:41
@am17an
am17an requested a review from a team as a code owner November 20, 2026 03:41
@Abrosimov-a-a

Copy link
Copy Markdown

It works.

@am17an
am17an merged commit 4c4a0f0 into ggml-org:master Nov 20, 2026
16 checks passed
Kidplayer666 pushed a commit to Kidplayer666/llama.cpp that referenced this pull request Nov 20, 2026
The MoE cache adds a slot lookup to every MoE layer, and with
--moe-cache-cpu-share a second expert path, but graph_max_nodes() did
not account for it. Models on the default 8*n_tensors budget with few
tensors per layer (cohere2moe: 443 tensors, 49 layers) overflow the
graph context when the cache is combined with a quantized KV cache
(K/V rotation), aborting in ggml_new_tensor with GGML_ASSERT(obj_new).

Fixes ggml-org#32584

Assisted-by: Claude Opus 5.5
Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
The MoE cache adds a slot lookup to every MoE layer, and with
--moe-cache-cpu-share a second expert path, but graph_max_nodes() did
not account for it. Models on the default 8*n_tensors budget with few
tensors per layer (cohere2moe: 443 tensors, 49 layers) overflow the
graph context when the cache is combined with a quantized KV cache
(K/V rotation), aborting in ggml_new_tensor with GGML_ASSERT(obj_new).

Fixes ggml-org#32584

Assisted-by: Claude Opus 5.5
Wizard815 pushed a commit to Wizard815/mx-llama.cpp-Rocm10 that referenced this pull request Nov 25, 2026
The MoE cache adds a slot lookup to every MoE layer, and with
--moe-cache-cpu-share a second expert path, but graph_max_nodes() did
not account for it. Models on the default 8*n_tensors budget with few
tensors per layer (cohere2moe: 443 tensors, 49 layers) overflow the
graph context when the cache is combined with a quantized KV cache
(K/V rotation), aborting in ggml_new_tensor with GGML_ASSERT(obj_new).

Fixes ggml-org#32584

Assisted-by: Claude Opus 5.5
(cherry picked from commit 4c4a0f0)
Mr-J-369 pushed a commit to Mr-J-369/llama.cpp-Android that referenced this pull request Nov 25, 2026
The MoE cache adds a slot lookup to every MoE layer, and with
--moe-cache-cpu-share a second expert path, but graph_max_nodes() did
not account for it. Models on the default 8*n_tensors budget with few
tensors per layer (cohere2moe: 443 tensors, 49 layers) overflow the
graph context when the cache is combined with a quantized KV cache
(K/V rotation), aborting in ggml_new_tensor with GGML_ASSERT(obj_new).

Fixes ggml-org#32584

Assisted-by: Claude Opus 5.5
(cherry picked from commit 4c4a0f0)
twinlunarstarz-dev pushed a commit to twinlunarstarz-dev/llama.cpp-optium that referenced this pull request Nov 26, 2026
Nindaleth pushed a commit to Nindaleth/llama.cpp that referenced this pull request Nov 26, 2026
The MoE cache adds a slot lookup to every MoE layer, and with
--moe-cache-cpu-share a second expert path, but graph_max_nodes() did
not account for it. Models on the default 8*n_tensors budget with few
tensors per layer (cohere2moe: 443 tensors, 49 layers) overflow the
graph context when the cache is combined with a quantized KV cache
(K/V rotation), aborting in ggml_new_tensor with GGML_ASSERT(obj_new).

Fixes ggml-org#32584

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash loading cohere2moe model with --moe-cache-mib and KV cache q8_0 (0xC0000409)

4 participants