[GH-ISSUE #4413] [Engine] MTP chain_launch() lacks the max_cells clamp draft() has - pipelined chains stage drafter cells past max-context near the context end #1967

Closed
opened 2026-11-04 01:55:39 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @udqe on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4413

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

Note

AI-assisted static analysis — model: Qwen3.8-Flash-Next (Unsloth UD-Q4_K_XL) served by this repo's own engine 0.1.52, driven by a DeepSeek-based harness; not observed as a failure on my machine. The maintainer verified the cited code paths in the v0.2.7 source snapshot line by line.

MtpDrafter::draft() guards the chain end explicitly (mtp.cpp ~1628-1630):

// Draft j writes its K/V at cell p + a + j, and the K/V ends at max_cells (its page table has no page past it): ...
max_steps = std::min<int64_t>(std::min(max_t_ - 1, max_drafts_), st_.max_cells - (p + a));

The pipelined decode path (--pipeline-windows 2) never calls draft(); the verdict handlers call chain_launch(..., chain_n, chain_n, ...) with chain_n = kVerifyMaxT - 1 (7) and no clamp — chain_launch (mtp.cpp ~1825-1876) holds no st_ reference at all. The only context-end check is the front-stage guard if (st == 0 && A.p + A.T > o.max_context) { ending = true; continue; } (generate.cpp ~16186): ending breaks the loop only at the next iteration (~16098), while the current window's verdict still launches the chain at the bottom of the same iteration (~16306/16337, gated by last alone — and last covers nf/eos/max_new/stop but not the context end, ~16275). A window ending within 7 tokens of --max-context therefore stages cells up to max_context+6: in ring mode the K/V write wraps to old slots and rope cos/sin read past the table (layer.hpp calls that class "a wrong rotation rather than a fault") — garbage drafts at the boundary; with --mtp-window 0 the same cells index past page_table — an out-of-arena device write.

Expected: the same clamp as draft() on every chain path. Actual: none on the pipelined path.

A context limit exists on every other drafting path in the file — GatedDraftLimit(mtp, ..., p + a + 1, o.max_context) (generate.cpp ~16737/~18077/~18383), the window room = std::min(..., o.max_context - p) sizing (~16416/~18213/~18253), and the batch guard sl.p + 3 <= o.max_context ? 2 : 1 (~12738) — the pipelined chain is the one path without one, and chain_launch takes no context parameter at all (mtp.cpp ~1825-1826). The pipelined last flag covers stop/eos/max_new but not the context end (const bool last = nf || eos || produced_n >= max_new || stop_req.load();, ~16275), so a near-full-context window still launches the full 7-output chain.

Smallest steps or command that reproduce it

Static finding (no fault observed on my machine). What would verify: a debug build with a small --max-context (e.g. 2048), --pipeline-windows 2 --spec 4 and --mtp-window 0, a conversation driven to within ~7 tokens of the cap under compute-sanitizer (expect writes past the drafter page table near the boundary); or a ring-K/V run with the old cells' slots poisoned, checking whether they change at the boundary.

Reproduction status

unconfirmed static analysis (recipe above). The pipelined chain path itself is live on this machine every request; only the near-cap boundary condition has not been reached here.

Strata version

Terminal and app 0.2.7, engine 0.1.52 (release store build windows-x86_64-cuda-cuda13); code citations checked against the v0.2.7 source checkout, re-read twice on two separate days.

Graphics card, memory and system

2x RTX 4090 24 GiB (both PCIe 4.0 x16, engine probe 26.3-26.4 GB/s), Threadripper 3970X, 128 GiB RAM, Windows 11 (WDDM), driver 610.88.

Model, size and settings

Qwen3.8-Flash-Next Unsloth UD-Q4_K_XL, --max-context 307200 --kv int8 --kv-resident 32768 --spec 4 --mtp rt --pipeline-windows 2 --layer-split auto (K=22) --vram-reserve-mib 1728 --vram-reserve-later-mib 972 --pcie-frac 0.20 --spec-min-p 0.70 --adapt-async 1 --conversation-cache-mib 12288 --conversation-cache-slots 4 --expert-cache auto --prefill auto. The pipelined chain path this report is about runs on every decode request of this machine (no fault seen here yet).

Originally created by @udqe on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4413 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened > [!NOTE] > AI-assisted static analysis — model: **Qwen3.8-Flash-Next (Unsloth UD-Q4_K_XL)** served by this repo's own engine 0.1.52, driven by a DeepSeek-based harness; not observed as a failure on my machine. The maintainer verified the cited code paths in the v0.2.7 source snapshot line by line. `MtpDrafter::draft()` guards the chain end explicitly (mtp.cpp ~1628-1630): ``` // Draft j writes its K/V at cell p + a + j, and the K/V ends at max_cells (its page table has no page past it): ... max_steps = std::min<int64_t>(std::min(max_t_ - 1, max_drafts_), st_.max_cells - (p + a)); ``` The pipelined decode path (`--pipeline-windows 2`) never calls `draft()`; the verdict handlers call `chain_launch(..., chain_n, chain_n, ...)` with `chain_n = kVerifyMaxT - 1` (7) and no clamp — `chain_launch` (mtp.cpp ~1825-1876) holds no `st_` reference at all. The only context-end check is the front-stage guard `if (st == 0 && A.p + A.T > o.max_context) { ending = true; continue; }` (generate.cpp ~16186): `ending` breaks the loop only at the **next** iteration (~16098), while the current window's verdict still launches the chain at the bottom of the same iteration (~16306/16337, gated by `last` alone — and `last` covers nf/eos/max_new/stop but not the context end, ~16275). A window ending within 7 tokens of `--max-context` therefore stages cells up to max_context+6: in ring mode the K/V write wraps to old slots and rope cos/sin read past the table (layer.hpp calls that class "a wrong rotation rather than a fault") — garbage drafts at the boundary; with `--mtp-window 0` the same cells index past `page_table` — an out-of-arena device write. Expected: the same clamp as `draft()` on every chain path. Actual: none on the pipelined path. A context limit exists on every other drafting path in the file — `GatedDraftLimit(mtp, ..., p + a + 1, o.max_context)` (generate.cpp ~16737/~18077/~18383), the window `room = std::min(..., o.max_context - p)` sizing (~16416/~18213/~18253), and the batch guard `sl.p + 3 <= o.max_context ? 2 : 1` (~12738) — the pipelined chain is the one path without one, and `chain_launch` takes no context parameter at all (mtp.cpp ~1825-1826). The pipelined `last` flag covers stop/eos/max_new but not the context end (`const bool last = nf || eos || produced_n >= max_new || stop_req.load();`, ~16275), so a near-full-context window still launches the full 7-output chain. ### Smallest steps or command that reproduce it Static finding (no fault observed on my machine). What would verify: a debug build with a small --max-context (e.g. 2048), --pipeline-windows 2 --spec 4 and --mtp-window 0, a conversation driven to within ~7 tokens of the cap under compute-sanitizer (expect writes past the drafter page table near the boundary); or a ring-K/V run with the old cells' slots poisoned, checking whether they change at the boundary. ### Reproduction status unconfirmed static analysis (recipe above). The pipelined chain path itself is live on this machine every request; only the near-cap boundary condition has not been reached here. ### Strata version Terminal and app 0.2.7, engine 0.1.52 (release store build windows-x86_64-cuda-cuda13); code citations checked against the v0.2.7 source checkout, re-read twice on two separate days. ### Graphics card, memory and system 2x RTX 4090 24 GiB (both PCIe 4.0 x16, engine probe 26.3-26.4 GB/s), Threadripper 3970X, 128 GiB RAM, Windows 11 (WDDM), driver 610.88. ### Model, size and settings Qwen3.8-Flash-Next Unsloth UD-Q4_K_XL, --max-context 307200 --kv int8 --kv-resident 32768 --spec 4 --mtp rt --pipeline-windows 2 --layer-split auto (K=22) --vram-reserve-mib 1728 --vram-reserve-later-mib 972 --pcie-frac 0.20 --spec-min-p 0.70 --adapt-async 1 --conversation-cache-mib 12288 --conversation-cache-slots 4 --expert-cache auto --prefill auto. The pipelined chain path this report is about runs on every decode request of this machine (no fault seen here yet).
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660437043 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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#1967
No description provided.