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

Closed
opened 2026-11-07 15:33:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2529
Author: @MrKop-git
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: pr/mtp-adaptive


📝 Commits (1)

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

📊 Changes

5 files changed (+82 additions, -0 deletions)

View changed files

📝 docs/DETAILS.md (+11 -0)
📝 include/strata/spec/draft_policy.hpp (+7 -0)
📝 src/program/generate.cpp (+9 -0)
📝 src/spec/draft_policy.cpp (+21 -0)
📝 src/spec/draft_policy_test.cpp (+34 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2529 **Author:** [@MrKop-git](https://github.com/MrKop-git) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/mtp-adaptive` --- ### 📝 Commits (1) - [`931e1da`](https://github.com/Niko1221/Strata/commit/931e1daca0b888f50ae80bcc2a297c6ca374b045) spec: STRATA_MTP_ADAPTIVE=1, the MTP window's own size from the draft policy's learned expected-commits-per-ms ### 📊 Changes **5 files changed** (+82 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+11 -0) 📝 `include/strata/spec/draft_policy.hpp` (+7 -0) 📝 `src/program/generate.cpp` (+9 -0) 📝 `src/spec/draft_policy.cpp` (+21 -0) 📝 `src/spec/draft_policy_test.cpp` (+34 -0) </details> ### 📄 Description ## 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:33:12 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4098
No description provided.