You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RFC: Multi-Bucket CUDA Graphs (b=1..8) + Lossless Zero-ML Renewal-Reward Stopping for MTP Speculative Decoding
#33229
This proposal summarizes an empirical study of Multi-Token Prediction (MTP) speculative decoding across dense (Qwen3.5-4B/9B) and MoE (Qwen3.6-35B-A3B, Gemma-4-26B-A4B, GLM-4.7-Flash-30B, and Qwen3.8-Flash-Next via Strata) on an RTX 3060 12 GB + Xeon E5-2695 v4.
Full datasets, exact CLI flags, scripts, charts, and a standalone MIT C++17 header are published here: https://github.com/piwoMazda/draft-gate (including FOR_LLMS.md and docs/ANTIDRAFT_RFC.md).
Disclosure: The core intuition came from the author, while benchmarking, analysis, and C++17 code were conducted with Gemini 4 Neon. The author will not be actively replying to follow-ups, so all evidence and reproduction details are self-contained in the repository.
Why this fits llama.cpp's conservative upstream design
Specialized engines like Strata use several aggressive engine-level optimizations that llama.cpp rightly avoids or treats conservatively. By contrast, this proposal isolates two small, general-purpose, 100% lossless improvements that directly fix a measured bottleneck in llama.cpp's existing--spec-draft-p-min and work cleanly with standard speculative verification:
Part 1: Multi-Bucket CUDA Graph Cache for Small Decode Batches (b = 1..8)
In llama.cpp b12800 (CUDA 13.5), enabling --spec-draft-p-min on dense GPU models currently crashes wall-clock speed by −15% to −44% despite raising acceptance to ~98%:
2×3 CUDA Graph ablation (data/windows_llamacpp/ablation_cuda_graphs.json):
pt_prose_physics, GRAPHS=ON: p_min=0.0 gets 83.8 tok/s (112 graph hits) vs. p_min=0.30 at 49.3 tok/s (31 hits — 72% of graph hits destroyed, +14.9 ms/step).
With GGML_CUDA_DISABLE_GRAPHS=1, p_min=0.30 actually speeds up low-acceptance prose (43.6 → 45.1 tok/s, +3.4%).
Live cross-engine validation: On the exact same RTX 3060 12 GB, Strata 0.1.54 captures one CUDA Graph per verify window size (T=1..8, ~13–35 MiB VRAM each) and achieves +8.06% live (--spec 4, p = 2.1e-7) and +22.46% live (--spec 5, p = 9.4e-7) with dynamic pruning.
Already winning live in unmodified llama.cpp (offloaded MoE): On Qwen3.6-35B-A3B IQ4_XS (where disjoint expert loading dominates), --spec-draft-p-min already wins live (+6% to +20.7% overall; +56.3% on PT prose).
Keeping a small pool of decode CUDA Graphs keyed by (n_tokens, graph_sig) for n_tokens ∈ [1..8] (or even a minimal 2-bucket pool) immediately unblocks adaptive speculative decoding on GPU.
Part 2: Zero-ML Renewal-Reward Stopping + Online Depth Calibration (common/speculative.cpp)
Cross-architecture telemetry (100% aligned) shows why a single static --spec-draft-p-min cannot generalize across models:
Gemma 4 26B-A4B (Shared-KV MTP):+8 to +11 pp overconfident across all depths.
GLM-4.7-Flash 30B (Q3_K_XL + Q8_0 MTP): swings from −5.1 pp underconfident at depth +1 to +23.9 pp overconfident at +3/+4 (making static K=4 27.3% slower than K=0).
Word-start boundary penalty: Tokens starting a new word drop conditional acceptance by −5.7 to −18.9 pp ($p < 10^{-7}$).
Nonlinear MoE verify costs: On 512-expert MoE (Strata), drafts +1..+3 cost +4.1 ms each while draft +4 jumps +9.1 ms.
We provide a standalone, zero-dependency, Zero-ML C++17 controller (draftgate::ZeroMLRenewalController in include/antidraft_controller_v2.h, ~25 lines of core math, MIT):
Measures online wall-clock ver_ms[0..K] and mtp_ms[0..K] via EMA.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Context & Transparency
Qwen3.5-4B/9B) and MoE (Qwen3.6-35B-A3B,Gemma-4-26B-A4B,GLM-4.7-Flash-30B, andQwen3.8-Flash-Nextvia Strata) on an RTX 3060 12 GB + Xeon E5-2695 v4.FOR_LLMS.mdanddocs/ANTIDRAFT_RFC.md).Why this fits
llama.cpp's conservative upstream designSpecialized engines like Strata use several aggressive engine-level optimizations that
llama.cpprightly avoids or treats conservatively. By contrast, this proposal isolates two small, general-purpose, 100% lossless improvements that directly fix a measured bottleneck inllama.cpp's existing--spec-draft-p-minand work cleanly with standard speculative verification:Part 1: Multi-Bucket CUDA Graph Cache for Small Decode Batches (
b = 1..8)In
llama.cppb12800 (CUDA 13.5), enabling--spec-draft-p-minon dense GPU models currently crashes wall-clock speed by −15% to −44% despite raising acceptance to ~98%:Qwen3.5-4B UD-Q4_K_XL(K=4):105.3 tok/s(p_min=0.0) →68.3 tok/s(p_min=0.50, −35.2%) →58.7 tok/s(p_min=0.90, −44.3%).data/windows_llamacpp/ablation_cuda_graphs.json):pt_prose_physics,GRAPHS=ON:p_min=0.0gets83.8 tok/s(112graph hits) vs.p_min=0.30at49.3 tok/s(31hits — 72% of graph hits destroyed, +14.9 ms/step).GGML_CUDA_DISABLE_GRAPHS=1,p_min=0.30actually speeds up low-acceptance prose (43.6 → 45.1 tok/s, +3.4%).T=1..8, ~13–35 MiB VRAM each) and achieves +8.06% live (--spec 4,p = 2.1e-7) and +22.46% live (--spec 5,p = 9.4e-7) with dynamic pruning.llama.cpp(offloaded MoE): OnQwen3.6-35B-A3B IQ4_XS(where disjoint expert loading dominates),--spec-draft-p-minalready wins live (+6% to +20.7% overall; +56.3% on PT prose).Keeping a small pool of decode CUDA Graphs keyed by
(n_tokens, graph_sig)forn_tokens ∈ [1..8](or even a minimal 2-bucket pool) immediately unblocks adaptive speculative decoding on GPU.Part 2: Zero-ML Renewal-Reward Stopping + Online Depth Calibration (
common/speculative.cpp)Cross-architecture telemetry (100% aligned) shows why a single static
--spec-draft-p-mincannot generalize across models:+8 to +11 ppoverconfident across all depths.Q3_K_XL+Q8_0MTP): swings from−5.1 ppunderconfident at depth+1to+23.9 ppoverconfident at+3/+4(making staticK=427.3% slower thanK=0).+1..+3cost+4.1 mseach while draft+4jumps+9.1 ms.We provide a standalone, zero-dependency, Zero-ML C++17 controller (
draftgate::ZeroMLRenewalControllerininclude/antidraft_controller_v2.h, ~25 lines of core math, MIT):ver_ms[0..K]andmtp_ms[0..K]via EMA.cal_bias[j]via fast Bayesian shrinkage.What has and has NOT been tested
Qwen3.8-Flash-NextIQ3_XXS, 360 runs),llama.cppb12800 (Qwen3.5-4BQ2/Q4/Q8,Qwen3.5-9BQ4,Qwen3.6-35B-A3BIQ4/Q2,Gemma-4-26B,GLM-4.7-Flash-30B).llama.cpp(controller numbers are calibrated trace simulations), non-Latin scripts (CJK/Arabic),FP16/BF16, concurrent-np > 1batching, and non-NVIDIA backends (Metal/ROCm/Vulkan).All reactions