Skip to content

llama : size the fork's per-token graph budgets from n_ubatch again - #304

Merged
Nathanw1014 merged 1 commit into
masterfrom
hb/graph-nodes-ubatch
Nov 20, 2026
Merged

Nathanw1014 merged 1 commit into
masterfrom
hb/graph-nodes-ubatch

Conversation

@Nathanw1014

Copy link
Copy Markdown

Overview

Fixes #301: Qwen3.8-Flash-Next with the separate MTP GGUF aborts at load at long context (GGML_ASSERT(obj_new) in ggml_new_object, from build_qsa_top_k in graph_mtp). It is the graph metadata pool running out, not GPU memory.

Upstream ggml-org#32078 (in the 11-18 sync) made graph_max_nodes independent of the ubatch and dropped the n_tokens * 40 term for qwen4exp and friends (and n_tokens * 160 / 80 for Kimi K3 / HRM). Upstream's ubatch-dependent nodes were the non-fused GDN paths it removed, but the fork's qwen4exp indexer still scores in query strips: their count grows with the ubatch, and since the strip shrinks with depth, with the context length too. A model with few tensors keeps only max(1024, 32 * n_tensors). The Flash-Next MTP GGUF has 34 tensors, so 1088 nodes, and at 563k context with -ub 4096 (32 strips, against 8 at 256k) its graph no longer fits.

The budgets now come from cparams.n_ubatch, the same way the sync already sizes the vocab-subset term, so they stay independent of the ubatch of a given call. This restores the pre-sync budgets at the context's ubatch; no new graph or math change.

Measurements

Device:     Ryzen AI Max+ 395 / Framework Desktop
Memory:     64 GB LPDDR5X-8000
Power:      platform_profile balanced
BIOS:       UMA split 512 MB
Kernel:     6.17.0-35-generic, amdgpu.gttsize=59392 ttm.pages_limit=15204352 amd_iommu=off
Backend:    Vulkan RADV, Mesa 26.2.4
Build:      -DGGML_VULKAN=ON -DGGML_NATIVE=OFF -DCMAKE_BUILD_TYPE=Release
Baseline:   b9f3c0e87 (master), built and run in this same session
Change:     0c2f221bc
Model:      Qwen3.8-Flash-Next trunc8 UD-Q4_K_XL (8 layers) + unsloth MTP Q8_0 (mtp-Qwen3.8-Flash-Next-Q8_0.gguf)

Server load test, the reporter's settings: --spec-type draft-mtp --spec-draft-n-max 5 --rope-scaling yarn --rope-scale 2.2 --yarn-orig-ctx 262144 -b 4096 -fa on -np 1.

build -c -ub result
master 563200 4096 abort, GGML_ASSERT(obj_new) in build_qsa_top_k from graph_mtp
this PR 563200 4096 loads
master 563200 2048 loads
master 262144 4096 loads

Correctness: the change only raises the node budget of the graph metadata context, so it cannot change any graph that already fit. ctest -L main: 36/36 passed.

Additional information

Workaround on current master: --ubatch-size 2048 halves the strip count and loads at 563k.

Requirements

  • I have read and agree with the contributing guidelines
  • This change is Strix Halo specific, or justified by measurements on Strix Halo. General llama.cpp improvements
    belong in halo-box/llama.cpp instead
  • AI usage disclosure: AGENT-AUTHORED. Claude found the cause, wrote the change and ran the tests; I reviewed it.
  • What was NOT verified: ROCm (the reporter's backend; the budget is backend independent), the full Flash-Next target (trunc8 stands in, the MTP model is the real one), and the restored Kimi K3 / HRM budgets (no such model here).

Written with Claude, tested by me.

Assisted-by: Claude Opus 5.5

Upstream ggml-org#32078 made graph_max_nodes independent of the ubatch, which
dropped the n_tokens * 40 (and Kimi / HRM n_tokens * 160 / 80) terms in
the sync. Upstream's ubatch-dependent nodes were the non-fused GDN paths
it removed, but the fork's qwen4exp indexer still scores in query strips
whose count grows with the ubatch and, as the strip shrinks with depth,
with the context length. A model with few tensors keeps only
max(1024, 32 * n_tensors): the separate Flash-Next MTP GGUF (34 tensors)
gets 1088 nodes, and at 563k context with -ub 4096 its graph_mtp no
longer fits. The server aborts at load with GGML_ASSERT(obj_new) in
ggml_new_object from build_qsa_top_k (#301).

Take the budget from cparams.n_ubatch, as the vocab-subset term already
does after the sync, so it stays independent of the ubatch of a call.

Verified on gfx1151 Vulkan, Flash-Next trunc8 UD-Q4_K_XL + MTP Q8_0,
draft-mtp, yarn 2.2, -b 4096: -c 563200 -ub 4096 aborts on master
b9f3c0e and loads with this change; master loads at -ub 2048 and at
-c 262144 (controls).

Assisted-by: Claude Opus 5.5
@dzannotti
dzannotti force-pushed the hb/graph-nodes-ubatch branch from 0c2f221 to 920c0ca Compare November 20, 2026 12:08

@dzannotti dzannotti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Strix Halo (gfx1151), ROCm, with a real Qwen3.8-Flash-Next (qwen4exp, full model) + the shared MTP draft, rebased on master 058a058:

  • master at the #301 settings (-c 563200 --rope-scaling yarn --rope-scale 2.2 --yarn-orig-ctx 262144 -b 4096 -ub 4096 -np 1 -fa on --spec-type draft-mtp,ngram-mod): aborts with GGML_ASSERT(obj_new), "needed 418624, available 418256", the same numbers as the issue.
  • this PR, same settings: loads; an 8k prompt and a 268856-token passkey prompt (past the 262144 training context, so in the yarn range) run without errors, and the passkey is retrieved.
  • master vs this PR at -ub 2048 (where master loads), no draft: tokens and top-5 logprobs are bit-identical, so the change does not alter any graph that already fit.
  • ctest -L main on the combined branch (#304 + #305 + #306): CPU 36/36.

A regression test for this (reserve the main and MTP contexts at n_ctx 563200, n_ubatch 4096) is in #313 and can come in separately.

Approved.

@Nathanw1014
Nathanw1014 merged commit eda6f8d into master Nov 20, 2026
9 checks passed
@Nathanw1014
Nathanw1014 deleted the hb/graph-nodes-ubatch branch November 20, 2026 12:44
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.

Qwen 3.8 Flash Next no longer work at higher context size

2 participants