Pull requests / #2529

#2529 spec: STRATA_MTP_ADAPTIVE=1, the MTP window's own size from the draft policy's learned expected-commits-per-ms

open · @MrKop-git · 0 コメント · GitHub で見る

BenchmarksSetup & installServer & APIMulti-GPUAMD / HIPModels & quantsWindows

本文

## Summary

The draft policy already measures every window size it sees (the round's time, and how many tokens that size committed) to decide MTP-vs-lookup. This makes it also pick **the MTP window's own size** (`STRATA_MTP_ADAPTIVE=1`, opt-in): among the sizes up to the drafter's own, the best expected-commits-per-ms, taking a smaller one only when it beats the full window by the policy's margin (3%).

The rule that matters is the probe order: **every size is measured before a guess can price one out** - the full window first (the incumbent), then the smaller ones largest-first. My first cut measured only the smaller sizes, and the pinned-text bench below caught it locking T4 out forever on a machine whose window rows are cheaper than the prior cost shape assumes (T2:89 windows, 21.12 tok/s).

## What it changes and what it leaves alone

`DraftPolicy::choose_mtp` (new), called from the one-shot and single-GPU serve decode loops only when the flag is set. **Without the flag nothing asks the policy and every window is the drafter's own.** The window only decides how many drafts one round checks - verification keeps the output whatever the window is.

## How it was checked

- `src/spec/draft_policy_test.cpp` (7 new checks): the probe order (full 4→3→2→1), the margin rule picking the best expected-commits-per-ms size, and both extremes (a paying full window stays; a window whose drafts never land shrinks to 1).
- **Pinned-text A/B on this box's GTX 1080 Ti** (IQ3_S, `--spec 4 --spec-min-p 0.5`, 192 tokens, `--spec-follow` pins the text to the model's own greedy continuation of a 42x128 prompt - the repo's own mechanism for comparing speculation settings on the same text - ABBA interleaved):

| stream | fixed | adaptive |
|---|---|---|
| steady (draftable continuation) | 25.12 / 24.62 tok/s, T4:52/54 of 68 rounds | **26.43 / 26.26**, T4:48/50 of 69 |
| shifting (same vocabulary, second half shuffled) | 22.57 / 22.74, T1:89 T4:29 of 132 | 23.05 / 22.03, T1:94/95 |

Same acceptance counts in every pair (123-124 of ~168 steady; 58-60 shifting). On the steady stream both adaptive runs beat both fixed runs (about 5%); on the shifting one the min-p gate already shrinks the windows and the policy stays level with it. The first cut's failure (never measuring the full window) is in the commit message as the counter-example the probe rule is for.

## Not tested

Free-running (unpinned) runs cannot resolve this comparison: issue #152's text variance moved acceptance between 31% and 81% on the same synthetic prompts and tok/s by ±20% - noted so nobody quotes those. Also untested: HIP (no toolchain here), SYCL (separate engine tree), `--batch` windows, the layer-split pipeline's windows (the policy learns there but the hook is not added), and non-greedy draws (the window rule does not touch the draws; `STRATA_IQ_MT_MIN=1` remains the recipe for byte-stable greedy text). Two early flagged runs died at the expert-arena setup before any window - environmental (a 46 GiB arena on a memory-pressured box), the site precedes the flag's first use, not reproduced in a dozen later runs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

関連リンク

インストール・モデル・リリースへの站内リンク。