Repository navigation
llama : reserve the incremental QSA graph at its worst case (fixes test-qwen4exp-mtp-cache-only) - #299
Merged
Conversation
The incremental QSA route (a ubatch on the tracked prefix, qwen4exp) builds its own graph structure, and sched_reserve never built it: the reservation context took the live prefix test, which is false for an empty cache. The first incremental ubatch then planned that structure at the current n_kv, and the next one with a larger n_kv had to plan it again. On a scheduler with more than one buffer (ROCm, Vulkan, CPU+BLAS) that is a re-plan and a backend sync per n_kv step, and GGML_SCHED_DEBUG_REALLOC aborts on it: test-qwen4exp-mtp-cache-only failed on ROCm0, Vulkan0, CI llvmpipe and CI Windows CPU+BLAS. A reservation context can now be told to take the prefix route or the fast route. sched_reserve reserves both at 1 token, at the largest ubatch the route allows and at the end of each token range the live pass found, with and without outputs (the MTP cache-only graph exists only without outputs, so graph_reserve accepts zero outputs). Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKmjzcT1LTvKtbw9EzBVGE
dzannotti
force-pushed
the
hb/qsa-reserve
branch
from
November 19, 2026 01:49
56a02f3 to
46e03cd
Compare
dzannotti
marked this pull request as ready for review
November 19, 2026 02:49
dzannotti
pushed a commit
to rcfa/strix-llama.cpp
that referenced
this pull request
Nov 21, 2026
reserve_qsa_routes (halo-box#299) reserved the prefix and fast QSA routes with one sequence. With a non-unified KV cache and more than one slot the qwen4exp graph splits the tokens across n_seq_max streams, so the 1-token reservation hit GGML_ASSERT(n_tokens % n_stream == 0) in build_qsa_top_k and every Flash-Next server with -np >= 2 and no -kvu aborted at load. Reserve with one sequence per stream, as reserve_token_ranges already does; graph_reserve rounds the token count up to a multiple of it. Assisted-by: Claude Opus 5.5
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 the last red check on
master:test-qwen4exp-mtp-cache-only(CI (vulkan) / ubuntu-llvmpipe, CI (cpu) / windows / x64-openblas). Root cause from #298, section 3.The incremental QSA route (a qwen4exp ubatch on the tracked prefix) builds its own graph structure.
sched_reservenever built it, because the reservation context asked the live prefix, which is false for an empty cache. The first incremental ubatch therefore planned that structure at the currentn_kv, and the next one with a largern_kvplanned it again. With more than one scheduler buffer (ROCm, Vulkan, CPU+BLAS) that is a re-plan and a backend sync pern_kvstep;GGML_SCHED_DEBUG_REALLOC=1aborts on it.Change
llama_memory_hybrid_idx_context: a reservation context can be set to theprefixorfastroute; the live path is unchanged.llama_context::reserve_qsa_routes: reserves both routes at 1 token, at the largest ubatch the route allows (512 forfast) and at the end of each token range the live pass found (no new probing), with and without outputs. The MTP cache-only graph exists only with zero outputs, sograph_reserveno longer assertsn_outputs >= 1.No kernel, graph or math change: the same graphs run, only their buffers are planned up front.
Verification
Strix Halo (gfx1151), ROCm 10.1 and RADV, master
4032d8f07vs this branch46e03cdeb, same flags.Correctness:
GGML_SCHED_DEBUG_REALLOC=1 ctest -L main: CPU, Vulkan0, ROCm0 36/36 (master 35/36 on Vulkan0 and ROCm0:test-qwen4exp-mtp-cache-only); lavapipe with the CI env (subset qwen4exp / llama-context / draft-vocab / llama-archs) 5/5 (master 4/5).ubuntu-llvmpipeand CI (cpu)windows / x64-openblaspass.llama-debugfinal f32 logits + prompt tokens on the fourtests/corpusfiles at-ub 512and-ub 2048: byte-identical, ROCm and Vulkan (16/16 pairs). Greedy decode 256 tokens identical on both backends.llama-serverwith the shared MTP draft (--spec-draft-n-max 3,-c 32768 -b/-ub 2048), 2.3k and 16k-token prompts, arms base/fix/fix/base, 3 requests each: identical text and drafted/accepted counts on both backends.Performance (all within run-to-run spread):
-r 3, alternated x2Costs and limits:
sched_reserve; inllama-serverthat lands on the first request: about +0.3 s once (ROCm 4.15 -> 4.47 s, Vulkan 3.63 -> 3.91 s for the first 2.3k prompt).Assisted-by: Claude Opus 5.5
🤖 Generated with Claude Code
https://claude.ai/code/session_01YKmjzcT1LTvKtbw9EzBVGE