Repository navigation
ggml-hrx: stop the sleeping wait from oversleeping decode after a prompt - #87
Merged
bong-water-water-bong merged 1 commit intoOct 5, 2026
Merged
Conversation
The sleeping graph wait (fork #44) predicts a wait from the shortest of the last four waits at its call site and sleeps 80% of it. Two faults: - a wait still asleep when the work finished recorded the sleep, not the work, so the estimate could only shrink by 0.8x per wait; - every replayed graph shared one history, so prompt graphs set the sleep of decode graphs. After a prompt graph (98-123 ms waits on Qwen3-4B pp512) the 13 ms decode tokens slept 98, 78, 63, 50, 40, ... ms, paid after every prompt. This was the penalty blamed on "graph replay recapture": the replay log shows no rebuild after the prompt (258 hits, 2 first builds), only the waits. Fix (our file hrx-sleeping-wait.cpp; two-line hook in the replay wait): - a wait that finds the work already done when it wakes forgets its history instead of recording the sleep, so the next wait blocks and measures; - the graph replay wait keeps one history per replayed graph exec (wait_history_for, bounded at 256 keys). Measured, performance mode (120 W), strixhalo, interleaved before/after. llama-bench -fa 1 -r 3, tg128 samples after pp in the same process (2 rounds): Qwen3-4B after pp512 [67.8 76.7 76.9][67.9 76.9 76.8] -> [77.1 77.1 77.1][76.4 76.9 77.0] Qwen3-4B after pp2048 [67.6 77.2 77.2][67.3 76.7 76.7] -> [77.1 77.1 77.1][77.1 77.3 77.2] Qwen3-8B after pp512 [37.5 42.4 42.4][37.5 42.4 42.4] -> [42.4 42.4 42.5][42.3 42.4 42.5] Qwen3.8-27B after pp512 [9.23 12.1 12.1][9.23 12.1 12.1] -> [12.2 12.1 12.1][12.1 12.1 12.1] hip-all ZAYA1-8B pp512 [82.9 91.3 94.6][82.9 91.2 92.3] -> [92.0 91.7 94.6][91.7 91.5 94.3] pp512/pp2048 unchanged within run-to-run spread (4B 4215-4221 vs 4172-4192, 27B 354.5-357.0 vs 352.5-355.8, 8B 2360-2380 vs 2354-2397). llama-server, decode tok/s per request after a 2002-token prompt (3 requests x 2 runs): Qwen3-4B 48.2-51.2 -> 54.2-57.6, Qwen3-8B 31.2-31.4 -> 35.6-35.7, Qwen3.8-27B 8.89-9.02 -> 11.51-11.59; 507-token prompts and 1-token prompts unchanged. Correctness: generated text identical before/after (md5 per prompt, every request), Qwen3-4B KLD vs before 0.000000 (100% same top token, 40 x 512), test-backend-ops HRX0 MUL_MAT/ADD/FLASH_ATTN_EXT/RMS_NORM/SOFT_MAX OK x2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
merged commit Oct 5, 2026
f3c771f
into
1bit/hrx-vulkan-patched
9 of 24 checks passed
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.
Fixes the decode slowdown after a prompt run. The cause was the sleeping stream wait (#44), not graph recapture: the replay log shows only hits after the prompt.
Root cause (
runtime/hrx-sleeping-wait.cpp, ours):wait_stream_commandsinruntime/command-program-executor.cpp). So 98-123 ms prompt waits set the sleep for 13 ms decode tokens. Measured on Qwen3-4B after pp512, decode tokens slept 98, 78, 63, 50, 40, 32, 26, 21, 17 ms before settling. The 27B lost about 3.7 s per llama-bench rep.Fix:
wait_history_for(key), capped at 256 keys).wait_stream_commandstakes a key, and the replay call passesrecorded.exec.It is host-side only and allocates no GPU memory.
Checks (strixhalo gfx1151, performance mode):
Generated text: byte-identical before vs after for every server request: Qwen3-4B, 8B, 27B and ZAYA1-8B, 1/507/2002-token prompts, 4 runs each.
KLD: Qwen3-4B KLD vs before 0.000000; PPL 13.1187 both.
test-backend-ops -b HRX0: MUL_MAT, ADD, FLASH_ATTN_EXT, RMS_NORM, SOFT_MAX OK, run twice.
Memory: 50 mixed requests with GTT bounded: Qwen3-4B flat at 10.1 GiB; ZAYA bounded by the existing cap-64 program cache.
Decode, first llama-bench rep after the prompt:
Server decode after a 2002-token prompt:
Prompt speed: unchanged within noise.
🤖 Generated with Claude Code