mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4856] [Engine] MTP: an opt-in window rule on the drafts' joint probability, scheduled by depth (STRATA_SPEC_PCUM) #5216
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#5216
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4856
Author: @Keoian
Created: 10/31/2026
Status: 🔄 Open
Base:
main← Head:mtp-spec-pcum📝 Commits (1)
4fb2974[Engine] MTP: a depth-scheduled cumulative-probability window rule (STRATA_SPEC_PCUM, opt-in)📊 Changes
4 files changed (+71 additions, -3 deletions)
View changed files
📝
docs/DETAILS.md(+8 -0)📝
serve/server.py(+2 -2)📝
serve/test_server.py(+5 -0)📝
src/program/generate.cpp(+56 -1)📄 Description
Problem and result
The serial decode loop ends an MTP window at the first draft below
--spec-min-p. Each draft is judged on its own, so a window can pass the floor token by token while the chance that the whole window is accepted is low (four drafts at p = 0.85 pass a 0.8 floor; all four are accepted about 52% of the time). Every drafted token is verified, and where a verify token is expensive the tail of such a window costs more than it returns.With
STRATA_SPEC_PCUM=base[,deep[,d0,d1]]the window also ends where the product of the drafted tokens' top-1 probabilities falls below a threshold that follows the depth. The drafter stops at the same token. Unset, nothing changes (byte-identical to main on the P100 machine below).Measured on two machines with Qwen3.8-Flash-Next, the gain is small or negative, because this model's verify cost hardly grows with depth:
--spec-min-pchanges (Validation).Related discussion
#4729 (scope). The idea comes from the depth-scheduled draft cutoff in https://github.com/Keoian/dual-p100-qwen-3-8-27b (branch
p100-optimizations,OPTLOG.mdattempts 198 and 218). That is a llama.cpp fork serving the dense Qwen3.8-27B, where every verify token costs an attention pass over the whole cache, so its numbers do not apply here. Qwen3.8-Flash-Next's sparse attention keeps the verify cost nearly flat with depth (#4729: a ~1.7-token window took 45.7 ms at 31K and 46.7 ms at 101K), which is why the rule saves little on this model.Approach
baseup to positiond0,deepfromd1(16384 / 49152 by default), and a straight line between.deepdefaults tobase.mtp.set_chain_rule): float compares and a double product, operation for operation the window rule, so it drafts nothing the window drops.strata_tunetakesspec_p_cum(base and deep) andspec_p_cum_deep;serve/server.pypasses both through, range 0-1.docs/DETAILS.md: the switch, and a row in "Opt-in switches measured and left off".Validation
2x RX 5700 XT (HIP)
Environment: 2x RX 5700 XT 8 GB (gfx1010, layer split 27), i7-3770 (AVX, no AVX2), 32 GB DDR3-1600, Ubuntu with kernel 7.0, ROCm 7.14.0a20260612 (TheRock gfx101X-dgpu), HIP build
-DCMAKE_HIP_ARCHITECTURES=gfx1010 -DSTRATA_ISA_FLOOR=avx, base870aedd9. Qwen3.8-Flash-Next ISTA-DASLab Q2_0,--spec 4 --spec-min-p 0.8 --mtp --kv int8, 256-token answers, thinking off.Passed:
Build of this branch (
4fb2974e),ninja strata: 0 errors.python -m unittest serve.test_server: 359 tests OK. The new assertions intest_tune_keysfail against main'sserve/server.py.Exact, on this branch's build: a fixed expert placement (
--adapt-swaps 0 --prompt-cache 0,pcie_frac0),STRATA_SPEC_PCUM=0, 6 greedy prompts (up to 256 tokens). Rule off (spec_p_cum0) against 0.75: 6 of 6 texts byte-identical.Speed. These runs were on my fork's branch, which has this change plus the AVX-only CPU change (#4728), gfx1010 SDWA dot4 and the HC_Q8 split gate (#2427), the same in every arm:
spec_min_p0.5 with product 0.7). That is noise.Per-run decode tok/s, sampled
Failed:
none observed.
Not run (this machine):
sycl/src/program/generate.cpp, which this PR does not change, so the variable has no effect there (not built).2x Tesla P100 (CUDA)
Environment: 2x Tesla P100-PCIE-16GB (sm_60; the second card on a PCH x4 slot, no P2P), i7-7700 (4 cores, AVX2), 47 GiB RAM, CUDA 12.4, driver 580, Linux. This branch (
4fb2974e) built with-DSTRATA_ENABLE_CUDA=ON -DSTRATA_EXPERIMENTAL_SM60=ON, base870aedd9. Qwen3.8-Flash-Next ISTA-DASLab IQ3_XXS with a Q8_0 copy of the dense weights (tools/q8_dense_gguf.py),--resident-experts --layer-split 30 --spec 3 --spec-min-p 0.7 --mtp --kv int8 --max-context 262144,STRATA_Q8_SM60=1 STRATA_STAGE_TRIM=1,STRATA_SPEC_PCUM=0with the rule set per request (strata_tune.spec_p_cum), 256-token answers, thinking off. Six fixed prompts (story, code, explanation, math, list, advice).Passed:
CUDA build of this branch for sm_60,
ninja strata: 0 errors. One warning:pcum_curset but not used (src/program/generate.cpp:12334; requests usereq_pcum).python -m unittest serve.test_server: 359 tests OK.Unset path: this branch's build with the variable unset against main's engine (
870aedd9), fixed expert placement (--adapt-swaps 0 --prompt-cache 0,pcie_frac0), 6 greedy prompts: 6 of 6 texts byte-identical.Speed, production placement (the adaptive expert cache on):
Per-run decode tok/s, sampled
Failed:
--adapt-swaps 0 --prompt-cache 0,pcie_frac0), 6 greedy prompts, and every arm in a fresh server, because later requests in a session also vary run to run on this machine. Rule off against main's engine: 6 of 6 identical. Rule on: 0.75 gives 0 of 6, 0.9 gives 1 of 6.Control without this PR: main's engine with
spec_min_p0.8 or 0.9 instead of 0.7 gives 0 of 6 and 1 of 6.So on this backend greedy text depends on where the draft window is cut, whatever cuts it. The texts part mid-answer into coherent alternatives ("he spotted something bobbing in the churning foam" / "he spotted a glint on the rocks"). The rule changes the text no more than
--spec-min-pdoes, but the byte-identity seen on the RX cards does not hold here.Not run (this machine):
Limits
On both machines the gain is small or negative for Qwen3.8-Flash-Next, so the switch stays off by default. It should only pay where a verify token's cost grows with depth (a dense model with full attention), which neither machine has measured with Strata.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N976Q4DZqzvqFCT56yvVXy
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.