Repository navigation
serve: a third warm-up on speculating backends (n_predict 2) moves the last-token layout build (~5.6 GB, up to 10 s) to load - #2485
Conversation
…e last-token layout build to load A speculating llama-server decodes the last token of a request without a draft, so that step runs the plain one-token decode program, and its first run builds host layouts the verify pass does not use. On Qwen3.8-27B Q4_K_M with its own MTP head that is 76 Q6_K ffn weights, ~5.6 GB, 10.4 s, inside whichever client request first ends on such a step. A 16-token /completion with n_predict 2 makes that step at load. Only plans that speculate (--mtp, own MTP head, --dflash) carry it; the shipped pair is unchanged and the second request still does not sample (engine#1539). ONEBIT_WARMUP=spec selects it alone. tests/print_backend.sh: three new checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
VERDICT: READY A third warm-up request only where speculation is active is the right shape: the cost is paid by the configurations that benefit (a drafter whose first tokens are unrepresentative of steady state), and nothing is added to the plain path. Two things worth confirming:
And a documentation point: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 12e892a: READY
The third warm-up is selected exactly when the backend speculates, it does not touch the slot cache, and the test fails without it. Checked on git merge-tree origin/main 12e892a in a host build of onebit:
ctest -R ^print_backend$ Passed
mutant: want_spec forced false in warmup_requests(), rebuilt: ***Failed
So the new print_backend.sh arm sees whether the spec warm-up is selected.
What I checked in the code:
- "Speculates" covers all three drafters.
warmup_requests(l.mtp)andwarm_backend(…, b.mtp)key onmtp, andl.mtp = trueis set for--mtp,--dflashand a model's own MTP head, all in the same branch (serve.cpp~1242–1245). So the "(--mtp, an own MTP head, --dflash)" claim holds;--dflashis not left out. - It does not reopen #1539. The new body is
warmup_short_body()plusn_predict 2:temperature 0andcache_prompt false, so it samples greedily and leaves nothing in the slot cache. The sampling warm-up was already the long chat request, and the shipped pair is byte-for-byte unchanged. ONEBIT_WARMUP=specon a non-speculating backend yields an empty list.out["warmup"]/out["warmups"]are then left unset rather than set to an empty element, and the code comment says so.
Not re-measured by me: the ~5.6 GB / 10.4 s layout build moving to load time, and the 23.55 tok/s next pass. That is a device run on the 27B, and I have no ticket for it. The mechanism, get_n_draft_max() = n_remaining - 1 = 0 on the last token, is the right reason a 2-token request reaches the plain decode step. The ci build is green, and the branch is level with main.
On a backend that speculates (
--mtp, a model's own MTP head,--dflash),1bit servenow sends a third warm-up request: the same 16-token/completionprompt withn_predict2. It moves a one-time host layout build out of a client request and into load time. The shipped pair is unchanged, and the second request still does not sample (engine#1539).Why
A speculating llama-server decodes the last token of a request without a draft:
get_n_draft_max()isn_remaining - 1, which is 0 on that token. That one step runs the plain one-token decode program. The first time it runs, ggml-hrx builds the host layout that program reads for any weight the verify pass reads in another layout.On Qwen3.8-27B Q4_K_M with its own MTP head, those are the mixed layers' Q6_K ffn weights. They show up as 76
HRX weight residency ... layouts={q6k-packed-k256-row64-scalerow, ggml-native}lines, about 5.6 GB.GGML_HRX_HOST_WEIGHT_TRACE=2names the readers:ggml_mul_mat_f32_f32_wmmaandggml_mul_mat_add_f32_f32_wmmafrom the 994-command plain decode program.Without a warm-up, this lands in whichever client request first ends on such a step. That depends on the request's acceptance pattern, which is deterministic under greedy decoding, so on one prompt set it hit 4 of 4 servers of one build and 2 of 6 of another. It was a large part of the run-to-run spread in tonight's DECODE-BW measurements.
The alternative was to not pack for that step (read the stored copy). That costs ~5 % in plain
--no-mtpserving, where the same stored copy exists, so it was measured and parked.Change
app/serve.cpp:warmup_requests(bool speculative)addswarmup_spec_body()(warmup_short_body()withn_predict2) when the launch speculates (Launch::mtp).warm_backendcall sites and the--print-backendplan pass the flag.ONEBIT_WARMUP=specselects this request alone, for the same kind of bisect aslong/short.--print-backendleaveswarmupsout when the selection is empty, rather than printing[].docs/serve.md: a "Why the 2-token request" paragraph, andspecadded toONEBIT_WARMUP.tests/print_backend.sh: three new checks.('/completion', 2, 16).ONEBIT_WARMUP=specon it sends only that one.specon a plan without a drafter sends none.Evidence (strixhalo gfx1151, one gpu-hold ticket; Qwen3.8-27B Q4_K_M, its own MTP head; same llama-server for both arms, fork
1bit/hrx-vulkan-patched+ llama.cpp#392, gpu-kernels2022afb74)1bitperf.pypassdecode_tps/_2k/completion(0) 562,/completion(2) 2681/completion(0) 484perf.pypass of 23.55 tok/s.tests/print_backend.sh: 42 ok on this branch. The current main1bitfails exactly the three new checks.1bit serve --print-backendplans:--no-mtp: 2, unchanged;ONEBIT_WARMUP=spec: 1 on the MTP plan, none without a drafter.🤖 Generated with Claude Code