[PR #1700] [CLOSED] generate, mtp: near the context's end the spec window and its drafts stay inside it #3618

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1700
Author: @midagedev
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: spec-window-context-end


📝 Commits (1)

  • 93346bb generate, mtp: near the context's end the spec window and its drafts stay inside it

📊 Changes

2 files changed (+10 additions, -3 deletions)

View changed files

📝 src/core/mtp.cpp (+3 -1)
📝 src/program/generate.cpp (+7 -2)

📄 Description

Summary

strata generate --spec S fails near the end of the context. The admission checks prompt + max_new <= max_context, but the loop still opens a full window there. So a request that fits ends with "ran out of context" (rc 2) and prints nothing. Near the end, MtpDrafter::draft can also draft into cell max_cells, past the page table.

What changed

  • src/program/generate.cpp: a window takes only the rows that fit, min(spec, max_context - p). The lookup chain stays inside them.
  • src/core/mtp.cpp: a draft round caps its steps at max_cells - (p + a). Serve calls the same drafter, so it gets the cap too. The cap binds only at the end of the context.

Extra Notes

  • CUDA 13.3 on Linux, RTX A6000, Qwen3.8-Flash-Next UD-Q4_K_XL, fb58e0db against this branch:
    • 4094-token prompt, --max-context 4096 --max-new 2 --spec 4: before, rc 2 and no output. After, rc 0 and 2 tokens.
    • 4084-token prompt, --max-new 12 --spec 5 --suffix-draft 0 --mtp, with a probe print: before, a round drafts into cell 4096 (max_cells 4096), then rc 2. After, its last cell is 4095, and the run ends with rc 0 and 12 tokens.
    • 512-token prompt, --max-new 64 --spec 4 --mtp, CPU share off: the same 64 tokens from both builds, twice each.
  • Not built: HIP and SYCL. The SYCL copies have the same lines. I can port the fix there.
  • I used Claude Code to find this and draft the change. I ran the tests myself.

🔄 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/1700 **Author:** [@midagedev](https://github.com/midagedev) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `spec-window-context-end` --- ### 📝 Commits (1) - [`93346bb`](https://github.com/Niko1221/Strata/commit/93346bb1c040a91b191c056bc18c50aebbd1f643) generate, mtp: near the context's end the spec window and its drafts stay inside it ### 📊 Changes **2 files changed** (+10 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/core/mtp.cpp` (+3 -1) 📝 `src/program/generate.cpp` (+7 -2) </details> ### 📄 Description ## Summary `strata generate --spec S` fails near the end of the context. The admission checks `prompt + max_new <= max_context`, but the loop still opens a full window there. So a request that fits ends with "ran out of context" (rc 2) and prints nothing. Near the end, `MtpDrafter::draft` can also draft into cell `max_cells`, past the page table. ## What changed - `src/program/generate.cpp`: a window takes only the rows that fit, `min(spec, max_context - p)`. The lookup chain stays inside them. - `src/core/mtp.cpp`: a draft round caps its steps at `max_cells - (p + a)`. Serve calls the same drafter, so it gets the cap too. The cap binds only at the end of the context. ## Extra Notes - CUDA 13.3 on Linux, RTX A6000, Qwen3.8-Flash-Next UD-Q4_K_XL, `fb58e0db` against this branch: - 4094-token prompt, `--max-context 4096 --max-new 2 --spec 4`: before, rc 2 and no output. After, rc 0 and 2 tokens. - 4084-token prompt, `--max-new 12 --spec 5 --suffix-draft 0 --mtp`, with a probe print: before, a round drafts into cell 4096 (`max_cells` 4096), then rc 2. After, its last cell is 4095, and the run ends with rc 0 and 12 tokens. - 512-token prompt, `--max-new 64 --spec 4 --mtp`, CPU share off: the same 64 tokens from both builds, twice each. - Not built: HIP and SYCL. The SYCL copies have the same lines. I can port the fix there. - I used Claude Code to find this and draft the change. I ran the tests myself. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29: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#3618
No description provided.