[PR #2830] [CLOSED] STRATA_MTP_ROOM_MIN — a long prompt takes the MTP drafter's 512 experts (decode-only) as ring #4287

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2830
Author: @gopinath87607
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: prefill-mtp-room


📝 Commits (3)

  • 67146ca serve: STRATA_MTP_ROOM_MIN - a long prompt takes the MTP drafter's 512 experts (decode-only) as ring
  • ce88207 serve: STRATA_MTP_ROOM_MIN counts the tokens a request reads, not the whole prompt
  • 41bff1d docs: the prompt room's read threshold, measured on the Q8_0 4-way rig

📊 Changes

7 files changed (+567 additions, -37 deletions)

View changed files

📝 docs/DETAILS.md (+14 -0)
➕ docs/MTP_PROMPT_ROOM.md (+237 -0)
📝 include/strata/core/mtp.hpp (+31 -0)
📝 include/strata/prefill/prefill.hpp (+31 -0)
📝 src/core/mtp.cpp (+53 -0)
📝 src/prefill/prefill.cpp (+49 -1)
📝 src/program/generate.cpp (+152 -36)

📄 Description

What this changes

STRATA_MTP_ROOM_MIN=TOKENS (--serve with --mtp): a request that reads at least TOKENS prompt tokens (0:
every request) uses the MTP drafter's 512 routed experts as the prompt path's ring while it is read. TOKENS counts the
tokens this request reads, not the whole prompt: a turn that reuses a cached conversation prefix and reads a few
hundred tokens gains nothing from the room. Those experts are 708 MB (675 MiB) that only the decode reads —
record_rest is their only reader; a prompt's passes run the draft layer's dense tensors and its K/V — so the prompt
path's ring is pointed at the block itself: slot i = experts_base + (i - rule) * MAXBLOB (135 slots on a Q8_0
pack, whose largest blob is 4.98 MiB). Opening and closing a room moves the ring count alone
(Prefill::set_ring_room_active): the block is never freed, never allocated again and never moves, so no prompt path
is laid out again, the decode's captured round/step graphs stay valid (nothing is dropped), and what comes back before
the first window is the decode's own bytes (MtpDrafter::experts_reclaim). In the measured shape's successor this is
two 675 MiB DMAs around the read.

The room is opened after the reused prefix is known (read_from) and immediately before lend(), so a relayout still
re-carves with the room; a request that must be re-read from 0 (STRATA_CKPT_REREAD) counts all of its tokens.

Limits, refused with the reason at start: --serve only, --mtp needed, --batch not supported (its slot drafters
share the solo drafter's weights). A layer split is fine (the room goes to the prompt path on the drafter's card),
--pipeline-windows is fine (the room closes before the request's first window), and --prefill-head-alias is fine.

From the Maya checkout (project-maya), local commits 7df369c (STRATA_GLM_ROOM_MIN), d4d0792 (the tail's
slots rounded up to the largest blob) and 5ccf9a4 (the in-place shape, for the MTP config's NextN block). Counting
what a request reads is this port's change, made after the report below.

What it leaves alone

Unset (the default) mtp_room_min is -1 and not one line of the room runs; the prompt path is laid out exactly as
before. The new code is reachable only behind that check. This is by construction, not by a measurement. =0 keeps
the behaviour that was measured: every request takes the rod, on 7-token continuations).

Measurements

  • Reported on an 8 GB RTX 2060 SUPER (2026-10-18, merbana branch, not run by us): the
    room works and pays where the ring is the limit.
    Qwen3.8-Flash-Next IQ3_XXS, --serve --mtp (Q2_0 drafter,
    675 MiB), --resident-budget-gib 40 (fully page-locked), --kv k8v4 --kv-resident 20480, --prefill auto; the
    auto chunk was 6,656 tokens with a 96-slot ring, the in all), chunk unchanged.
    STRATA_MTP_ROOM_MIN=0 against the same build unset (paired A/B, 3 pairs, prompt tok/s): 4K 448.4 -> 527.2 (+17%),
    16K 558.9 -> 658.1 (+17%), 32K 584.0 -> 719.7 (+23%); dec17 (noise). The lend cost
    107 ms per roomed request. STRATA_PREFILL_RING alone showed the ring was the limit (192 slots: +9.8% / +6.2% /
    +2.3%, decode -3.1 to -3.6 tok/s), so this is the case thn logits after a
    15,521-token prompt were bitwise equal to the unset run (two runs per arm, all four identical), the 48-token
    greedy replies matched, and the drafter's acceptance after reclaim was normal (27 of 34).
  • The first shape was measured on our Q8_0 4-way rig (202ught no time. The room
    opened, the 675 MiB really went into the ring, the block came back before the first window and the decode ran
    unchanged — but a deeper ring was not what the prompt waiens. That shape laid the
    prompt path out again around the block and cost **3.4–4.0p of the read.
  • The in-place shape and the read threshold were measured on our Q8_0 4-way rig (2026-10-19): the room is skipped,
    and its ~206 ms goes with it.
    Two engines from the sameainst this one), one start
    each, MIN=1024: one 5,042-token chat and three continuations that echoed the answer back. The parent lent the
    room for the whole 5,096-token prompt on continuations thend ~102 ms + reclaim
    ~104 ms); this commit lent nothing. Read time 2,054 -> 1,813 ms, 360 -> 153 ms, 344 -> 152 ms; time to first token
    2.110 -> 1.869 s, 0.409 -> 0.203 s, 0.390 -> 0.199 s. A still opened the room on the 7-token continuations (time to first token 0.432 / 0.415 the difference is the room, not the binary. The cold request still took the room in bver: more than one run per timing, HIP/SYCL,--prefill-head-alias`.
  • 7df369c records the room as not yet measured, with its 23 tok/s) on its
    byte-identical 100,535-token read.
  • No blanket speedup is claimed. The knob is how you meh the variable set and unset,
    PP line against PP line. The ring gain appears where GB card above) and is nil
    where it is not (our Q8_0 rig). The read threshold's gainend on the ring: it removes
    the room's own DMA from turns that reuse a conversation, ~0.2 s per short turn on our rig.

Checks

  • Default path: unset = off by construction (the parsed threshold is -1 and every room call is behind it).
  • Threshold: the room opens only when n - read_from >= TOKENS, after read_from is known and before lend(),
    so the prompt path's relayout re-carves with the ring rooes the ring count alone; the
    room's slot pointers are laid out by carve whether or nning it after the head-alias
    rebuild still adds the slots.
  • Build: both the parent commit and this commit built fild strata`, CUDA 13.2,
    sm_86 + sm_120) and ran on the Q8_0 4-way rig; the two binaries differ by this commit.
  • HIP / SYCL: not compiled here (no toolchain on the machine). generate.cpp carries no per-backend code, so both
    builds compile the same change.
  • On a start: the engine prints the read-token threshold, MiB and slots. Per roomed request it prints the tokens
    this request reads (so a reused prefix is visible againstrafter's block ever moved, the
    first shape said so — the in-place shape cannot.

🤖 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/2830 **Author:** [@gopinath87607](https://github.com/gopinath87607) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `prefill-mtp-room` --- ### 📝 Commits (3) - [`67146ca`](https://github.com/Niko1221/Strata/commit/67146ca2987f627297d7dd841cd8f44267b1d92e) serve: STRATA_MTP_ROOM_MIN - a long prompt takes the MTP drafter's 512 experts (decode-only) as ring - [`ce88207`](https://github.com/Niko1221/Strata/commit/ce882077973880bd585a5fc3ba227b1a0742139f) serve: STRATA_MTP_ROOM_MIN counts the tokens a request reads, not the whole prompt - [`41bff1d`](https://github.com/Niko1221/Strata/commit/41bff1d3d02f238cc5f7bda21d787ab19bbc42cd) docs: the prompt room's read threshold, measured on the Q8_0 4-way rig ### 📊 Changes **7 files changed** (+567 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+14 -0) ➕ `docs/MTP_PROMPT_ROOM.md` (+237 -0) 📝 `include/strata/core/mtp.hpp` (+31 -0) 📝 `include/strata/prefill/prefill.hpp` (+31 -0) 📝 `src/core/mtp.cpp` (+53 -0) 📝 `src/prefill/prefill.cpp` (+49 -1) 📝 `src/program/generate.cpp` (+152 -36) </details> ### 📄 Description ## What this changes `STRATA_MTP_ROOM_MIN=TOKENS` (`--serve` with `--mtp`): a request that **reads** at least TOKENS prompt tokens (`0`: every request) uses the MTP drafter's 512 routed experts as the prompt path's ring while it is read. TOKENS counts the tokens this request reads, not the whole prompt: a turn that reuses a cached conversation prefix and reads a few hundred tokens gains nothing from the room. Those experts are 708 MB (675 MiB) that only the **decode** reads — `record_rest` is their only reader; a prompt's passes run the draft layer's dense tensors and its K/V — so the prompt path's ring is pointed **at the block itself**: `slot i = experts_base + (i - rule) * MAXBLOB` (135 slots on a Q8_0 pack, whose largest blob is 4.98 MiB). Opening and closing a room moves the ring count alone (`Prefill::set_ring_room_active`): the block is never freed, never allocated again and never moves, so no prompt path is laid out again, the decode's captured round/step graphs stay valid (nothing is dropped), and what comes back before the first window is the decode's own bytes (`MtpDrafter::experts_reclaim`). In the measured shape's successor this is two 675 MiB DMAs around the read. The room is opened after the reused prefix is known (`read_from`) and immediately before `lend()`, so a relayout still re-carves with the room; a request that must be re-read from 0 (`STRATA_CKPT_REREAD`) counts all of its tokens. Limits, refused with the reason at start: `--serve` only, `--mtp` needed, `--batch` not supported (its slot drafters share the solo drafter's weights). A layer split is fine (the room goes to the prompt path on the drafter's card), `--pipeline-windows` is fine (the room closes before the request's first window), and `--prefill-head-alias` is fine. From the Maya checkout (`project-maya`), local commits `7df369c` (`STRATA_GLM_ROOM_MIN`), `d4d0792` (the tail's slots rounded up to the largest blob) and `5ccf9a4` (the in-place shape, for the MTP config's NextN block). Counting what a request reads is this port's change, made after the report below. ## What it leaves alone Unset (the default) `mtp_room_min` is `-1` and not one line of the room runs; the prompt path is laid out exactly as before. The new code is reachable only behind that check. This is by construction, not by a measurement. `=0` keeps the behaviour that was measured: every request takes the rod, on 7-token continuations). ## Measurements - **Reported on an 8 GB RTX 2060 SUPER (2026-10-18, merbana branch, not run by us): the room works and pays where the ring is the limit.** Qwen3.8-Flash-Next IQ3_XXS, `--serve --mtp` (Q2_0 drafter, 675 MiB), `--resident-budget-gib 40` (fully page-locked), `--kv k8v4 --kv-resident 20480`, `--prefill auto`; the auto chunk was 6,656 tokens with a **96-slot ring**, the in all), chunk unchanged. `STRATA_MTP_ROOM_MIN=0` against the same build unset (paired A/B, 3 pairs, prompt tok/s): 4K 448.4 -> 527.2 (+17%), 16K 558.9 -> 658.1 (+17%), 32K 584.0 -> 719.7 (+23%); dec17 (noise). The lend cost 107 ms per roomed request. `STRATA_PREFILL_RING` alone showed the ring was the limit (192 slots: +9.8% / +6.2% / +2.3%, decode -3.1 to -3.6 tok/s), so this is the case thn logits after a 15,521-token prompt were **bitwise equal** to the unset run (two runs per arm, all four identical), the 48-token greedy replies matched, and the drafter's acceptance after reclaim was normal (27 of 34). - **The first shape was measured on our Q8_0 4-way rig (202ught no time.** The room opened, the 675 MiB really went into the ring, the block came back before the first window and the decode ran unchanged — but a deeper ring was not what the prompt waiens. That shape laid the prompt path out again around the block and cost **3.4–4.0p of the read. - **The in-place shape and the read threshold were measured on our Q8_0 4-way rig (2026-10-19): the room is skipped, and its ~206 ms goes with it.** Two engines from the sameainst this one), one start each, `MIN=1024`: one 5,042-token chat and three continuations that echoed the answer back. The parent lent the room for the whole 5,096-token prompt on continuations thend ~102 ms + reclaim ~104 ms); this commit lent nothing. Read time 2,054 -> 1,813 ms, 360 -> 153 ms, 344 -> 152 ms; time to first token 2.110 -> 1.869 s, 0.409 -> 0.203 s, 0.390 -> 0.199 s. A ` still opened the room on the 7-token continuations (time to first token 0.432 / 0.415 the difference is the room, not the binary. The cold request still took the room in bver: more than one run per timing, HIP/SYCL, `--prefill-head-alias`. - `7df369c` records the room as not yet measured, with its 23 tok/s) on its byte-identical 100,535-token read. - **No blanket speedup is claimed.** The knob is how you meh the variable set and unset, `PP` line against `PP` line. The ring gain appears where GB card above) and is nil where it is not (our Q8_0 rig). The read threshold's gainend on the ring: it removes the room's own DMA from turns that reuse a conversation, ~0.2 s per short turn on our rig. ## Checks - **Default path:** unset = off by construction (the parsed threshold is `-1` and every room call is behind it). - **Threshold:** the room opens only when `n - read_from >= TOKENS`, after `read_from` is known and before `lend()`, so the prompt path's relayout re-carves with the ring rooes the ring count alone; the room's slot pointers are laid out by `carve` whether or nning it after the head-alias rebuild still adds the slots. - **Build:** both the parent commit and this commit built fild strata`, CUDA 13.2, sm_86 + sm_120) and ran on the Q8_0 4-way rig; the two binaries differ by this commit. - **HIP / SYCL:** not compiled here (no toolchain on the machine). `generate.cpp` carries no per-backend code, so both builds compile the same change. - **On a start:** the engine prints the read-token threshold, MiB and slots. Per roomed request it prints the tokens this request reads (so a reused prefix is visible againstrafter's block ever moved, the first shape said so — the in-place shape cannot. 🤖 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:34:35 +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#4287
No description provided.