[PR #1290] [CLOSED] Fix shared MTP slot initialization and speculative row bounds #3362

Closed
opened 2026-11-07 14:40:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1290
Author: @jeremiahritchey
Created: 10/7/2026
Status: ❌ Closed

Base: main ← Head: fix/batch-mtp-shared-state


📝 Commits (3)

  • 7bb814c fix: initialize shared MTP slots and bound speculative rows
  • 145bbaf test: use a valid out-of-vocabulary EOS sentinel
  • ae706fa fix: bound retained batch MTP graph memory

📊 Changes

4 files changed (+141 additions, -8 deletions)

View changed files

📝 docs/BATCHING.md (+23 -2)
📝 src/core/mtp.cpp (+6 -1)
📝 src/program/generate.cpp (+17 -5)
➕ tools/batch_mtp_test.py (+95 -0)

📄 Description

With --batch 4 --batch-mtp and a native draft-vocabulary head, the first slot admission fails with mtp: unsupported native MMVQ GGML type. The slot borrows the head pointer but leaves its quantization type at -1. This fixes that shared initialization in the existing upstream multislot MTP path; it does not import the older experimental implementation.

The slot also inherits the shared Q4 projections, their offsets, per-stream normalization setting and host vocabulary mapping. Only the owning drafter frees shared projections. At a request's output or context limit, the batch stages one row instead of a speculative second row; this prevents verify: slot ... runs past its context at the final cell. The actual row count is used for residual copies and subsequent drafts.

Repeated live HTTP runs also exposed VRAM exhaustion while instantiating batch graphs: the previous 64-layout cache could outgrow the available reserve. Limit it to 16 layouts using the existing LRU eviction. The tested 24 GB configuration uses --vram-reserve-mib 1536; the 700 MiB reserve with 64 retained layouts failed after two successful benchmark rounds.

--batch-mtp remains opt-in and single-GPU, with one proposal per slot. Additive INFO batch_mtp=0/1 and an idle-time acceptance count make activation observable. The new GPU regression checks four-slot token parity, short output limits and the final context cell; the existing interleave test covers conversation reuse, preemption and slot-to-solo continuation.

Validation:

  • CUDA Release build passed (CUDA 13.4, architecture 89, Linux x86_64).
  • 55 focused Python server tests passed: serve.test_parallel, serve.test_slots, serve.test_control_cancel, serve.test_restart_waiters.
  • Python compilation and git diff --check passed.
  • GPU regressions passed on an RTX 4090 (24 GB), EPYC 7532 (32 physical cores), 247 GiB RAM, Linux/CUDA 13.4, IQ3_S model with its native Q5_K head:
    • batch_mtp_test.py: all four slots equal solo for 64 tokens each; limits 1–4 equal solo prefixes; all four slots reach the final context cell. Passed with the native draft head and again with --mtp-q4 all --mtp-hnorm stream. Both runs accepted batch drafts.
    • batch_interleave_test.py --max-new 100 --long 4096: token parity, next-turn reuse, turn checkpoints, BYIELD/resume, and BSTOP followed by solo resume passed.
    • batch_test.py --batch 4 --n 4 --max-new 64 --keys "temperature=0.7 top_k=20 seed=123": all four slots equal solo, 96 of 154 batch proposals accepted.
  • The test configuration used --prefill 1024 --vram-reserve-mib 1536 to leave room for the parity tests' owned prompt buffers. The native/Q4 boundary tests override context to 512; the interleave and sampled tests used context 8192. These are correctness runs, not performance measurements.
  • Deployed on the same machine with the existing 262144-token context, int8 KV, 32768 resident KV and four slots; INFO batch_mtp=1 confirmed. Final build ae706fa passed repeated four-client HTTP runs, six queued requests, mixed long/short prompts, solo/batch client disconnects, conversation reuse, Responses API and tool-call checks. The run captured 36 batch layouts, exercising eviction beyond the new 16-layout limit, and finished with about 700 MiB free on the GPU.

HTTP measurement on that machine/configuration: one warm-up round, then three rounds of four concurrent requests × 256 tokens, temperature 0, thinking disabled. Median aggregate throughput 110.7 tokens/s, median time to first token 1.17 s. This is a local workload measurement, not a general speedup claim.

Reproduction commands with an existing model config containing --mtp, --spec >= 2 and enough VRAM reserved for owned prompt buffers:

python tools/batch_mtp_test.py --exe build/strata --config strata-model.json
python tools/batch_mtp_test.py --exe build/strata --config strata-model.json \
    --extra "--mtp-q4 all --mtp-hnorm stream"
python tools/batch_test.py --exe build/strata --config strata-model.json --batch 4 --n 4 \
    --keys "temperature=0.7 top_k=20 seed=123" \
    --extra "--batch-mtp --pcie-frac 0 --adapt-every 1000000"
python tools/batch_interleave_test.py --exe build/strata --config strata-model.json \
    --extra "--batch-mtp --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow"

🔄 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/1290 **Author:** [@jeremiahritchey](https://github.com/jeremiahritchey) **Created:** 10/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/batch-mtp-shared-state` --- ### 📝 Commits (3) - [`7bb814c`](https://github.com/Niko1221/Strata/commit/7bb814c577a6d6ccb27ff17350855a6a59ed3bb0) fix: initialize shared MTP slots and bound speculative rows - [`145bbaf`](https://github.com/Niko1221/Strata/commit/145bbaf5ed64218a2250ac838e5e62e8df99b2e2) test: use a valid out-of-vocabulary EOS sentinel - [`ae706fa`](https://github.com/Niko1221/Strata/commit/ae706fabb541fc8ca60f6d3de5cb96241ac6bc20) fix: bound retained batch MTP graph memory ### 📊 Changes **4 files changed** (+141 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+23 -2) 📝 `src/core/mtp.cpp` (+6 -1) 📝 `src/program/generate.cpp` (+17 -5) ➕ `tools/batch_mtp_test.py` (+95 -0) </details> ### 📄 Description With `--batch 4 --batch-mtp` and a native draft-vocabulary head, the first slot admission fails with `mtp: unsupported native MMVQ GGML type`. The slot borrows the head pointer but leaves its quantization type at `-1`. This fixes that shared initialization in the existing upstream multislot MTP path; it does not import the older experimental implementation. The slot also inherits the shared Q4 projections, their offsets, per-stream normalization setting and host vocabulary mapping. Only the owning drafter frees shared projections. At a request's output or context limit, the batch stages one row instead of a speculative second row; this prevents `verify: slot ... runs past its context` at the final cell. The actual row count is used for residual copies and subsequent drafts. Repeated live HTTP runs also exposed VRAM exhaustion while instantiating batch graphs: the previous 64-layout cache could outgrow the available reserve. Limit it to 16 layouts using the existing LRU eviction. The tested 24 GB configuration uses `--vram-reserve-mib 1536`; the 700 MiB reserve with 64 retained layouts failed after two successful benchmark rounds. `--batch-mtp` remains opt-in and single-GPU, with one proposal per slot. Additive `INFO batch_mtp=0/1` and an idle-time acceptance count make activation observable. The new GPU regression checks four-slot token parity, short output limits and the final context cell; the existing interleave test covers conversation reuse, preemption and slot-to-solo continuation. Validation: - CUDA Release build passed (CUDA 13.4, architecture 89, Linux x86_64). - 55 focused Python server tests passed: `serve.test_parallel`, `serve.test_slots`, `serve.test_control_cancel`, `serve.test_restart_waiters`. - Python compilation and `git diff --check` passed. - GPU regressions passed on an RTX 4090 (24 GB), EPYC 7532 (32 physical cores), 247 GiB RAM, Linux/CUDA 13.4, IQ3_S model with its native Q5_K head: - `batch_mtp_test.py`: all four slots equal solo for 64 tokens each; limits 1–4 equal solo prefixes; all four slots reach the final context cell. Passed with the native draft head and again with `--mtp-q4 all --mtp-hnorm stream`. Both runs accepted batch drafts. - `batch_interleave_test.py --max-new 100 --long 4096`: token parity, next-turn reuse, turn checkpoints, BYIELD/resume, and BSTOP followed by solo resume passed. - `batch_test.py --batch 4 --n 4 --max-new 64 --keys "temperature=0.7 top_k=20 seed=123"`: all four slots equal solo, 96 of 154 batch proposals accepted. - The test configuration used `--prefill 1024 --vram-reserve-mib 1536` to leave room for the parity tests' owned prompt buffers. The native/Q4 boundary tests override context to 512; the interleave and sampled tests used context 8192. These are correctness runs, not performance measurements. - Deployed on the same machine with the existing 262144-token context, int8 KV, 32768 resident KV and four slots; `INFO batch_mtp=1` confirmed. Final build `ae706fa` passed repeated four-client HTTP runs, six queued requests, mixed long/short prompts, solo/batch client disconnects, conversation reuse, Responses API and tool-call checks. The run captured 36 batch layouts, exercising eviction beyond the new 16-layout limit, and finished with about 700 MiB free on the GPU. HTTP measurement on that machine/configuration: one warm-up round, then three rounds of four concurrent requests × 256 tokens, temperature 0, thinking disabled. Median aggregate throughput **110.7 tokens/s**, median time to first token **1.17 s**. This is a local workload measurement, not a general speedup claim. Reproduction commands with an existing model config containing `--mtp`, `--spec >= 2` and enough VRAM reserved for owned prompt buffers: ```sh python tools/batch_mtp_test.py --exe build/strata --config strata-model.json python tools/batch_mtp_test.py --exe build/strata --config strata-model.json \ --extra "--mtp-q4 all --mtp-hnorm stream" python tools/batch_test.py --exe build/strata --config strata-model.json --batch 4 --n 4 \ --keys "temperature=0.7 top_k=20 seed=123" \ --extra "--batch-mtp --pcie-frac 0 --adapt-every 1000000" python tools/batch_interleave_test.py --exe build/strata --config strata-model.json \ --extra "--batch-mtp --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow" ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:40:56 +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#3362
No description provided.