Repository navigation
llama : size the fork's per-token graph budgets from n_ubatch again - #304
Merged
Merged
Conversation
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
force-pushed
the
hb/graph-nodes-ubatch
branch
from
November 20, 2026 12:08
0c2f221 to
920c0ca
Compare
dzannotti
approved these changes
Nov 20, 2026
dzannotti
left a comment
Collaborator
There was a problem hiding this comment.
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 withGGML_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 mainon 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #301: Qwen3.8-Flash-Next with the separate MTP GGUF aborts at load at long context (
GGML_ASSERT(obj_new)inggml_new_object, frombuild_qsa_top_kingraph_mtp). It is the graph metadata pool running out, not GPU memory.Upstream ggml-org#32078 (in the 11-18 sync) made
graph_max_nodesindependent of the ubatch and dropped then_tokens * 40term for qwen4exp and friends (andn_tokens * 160 / 80for 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 onlymax(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
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.-c-ubGGML_ASSERT(obj_new)inbuild_qsa_top_kfromgraph_mtpCorrectness: 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 2048halves the strip count and loads at 563k.Requirements
belong in halo-box/llama.cpp instead
Written with Claude, tested by me.
Assisted-by: Claude Opus 5.5