mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1252] DraftPolicy: a lookup window size priced during a slow stretch stays over-priced for the rest of the process #514
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#514
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @guthirry on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1252
Summary.
DraftPolicyupdates a window size's cost (cost_[t], an EMA of round times) only when that size is chosen. ThekProbesre-probing covers only sizes measured fewer than three times. The policy lives for the whole process (generate.cpp: "learned over the whole process"). Suppose the wide lookup sizes are measured during a slow stretch, for example right after a prompt while the cache refills. Their cost stays high, sochoose()keeps preferring short lookup windows. They are not measured again, and the speed loss carries over to every later request. The answers do not change; only decode speed does.What we saw. Engine
82f46a8, 2026-10-06. Two GPUs: RTX 3090 (PCIe 4.0 x4) + RTX 3080 Ti, no P2P,--peer-device 1, UD-Q4_K_XL,--spec 4, default--suffix-draft 3. The workload was a 3,437-token prompt that asks for a 10 KB Python module back with two classes renamed (3,221 tokens, greedy). In the second build, the prompt pass split the experts between the GPUs differently. That was an experimental change to the prompt path only; decode was untouched.suffix drafts(server log)In build B, the lookup windows stay as frequent and as accurate (99.7-99.8% accepted). They carry about 3.0 drafts instead of about 4.9. Each round is cheaper (47 vs 56 ms), but fewer tokens are committed per round, so decode is 15-18% slower. This persists across consecutive requests in the same process. In another process of a similar build, request 1 showed the same pattern (4.04 tokens per window, 79.7 tok/s) and request 2 recovered (5.51, 95.0 tok/s). That fits a learned, process-wide state rather than anything in the request.
What we did not measure. We did not log
cost_[]itself, so the slow stretch that priced the wide sizes is inferred. The best candidate is the first decode rounds after a prompt that borrowed cache slots (lent slots refilled ...), when the second GPU is also busier. Printingcost_[1..8]andcost_n_[]at the end of each request would confirm or refute this quickly.Why it can lock in. In
choose(), a lookup ofkdrafts is taken only ifE(k) / cost_ms(k + 1)beats the MTP's rate bymargin. Ifcost_[6]was set high early,best_tlands on a smallerk, whose cost is measured often because the MTP uses those sizes. Size 6 is then rarely chosen, and its EMA (kCostAlpha = 0.1) never gets the samples it would need to come back down.cost_n_[6] >= kProbes, so the probe path does not re-try it either.Possible fixes. These are suggestions only; we have not tested them.
cost_n_(asok_/bad_already decay) so thekProbespath re-opens after a while.cost_[t] / cost_[t_mtp]), so a global slow stretch does not price one size against the others.observe()for rounds that overlap a known transient (the post-prompt refill), or reset the cost table per request.The prompt-path change that exposed this is unrelated to the policy; its PR is https://github.com/Niko1221/Strata/pull/1251. On stock
82f46a8the trigger would be any slow stretch that happens to coincide with the first samples of a wide size.🤖 Generated with Claude Code
@Niko1221 commented on GitHub (Oct 7, 2026):
Fixed in 0.1.40.2. A lookup window size that has not been measured for 300 rounds is now tried again when a confident lookup could use it, so one slow stretch cannot price a wide size out for the rest of the process. Output is unchanged; only which window gets verified moves. The unit test has a case that fails without the change. Thanks for the detailed analysis.