[PR #2511] [Engine] Report batch MTP draft counts across slot handoffs #4085

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2511
Author: @hotschmoe
Created: 10/14/2026
Status: 🔄 Open

Base: main ← Head: batch-mtp-restore-accounting


📝 Commits (1)

  • 9e73689 Report batch MTP draft counts across slot handoffs

📊 Changes

6 files changed (+119 additions, -9 deletions)

View changed files

📝 docs/BATCHING.md (+6 -1)
📝 serve/server.py (+11 -1)
📝 serve/test_parallel.py (+14 -1)
➕ serve/test_slot_drafts.py (+70 -0)
📝 src/program/generate.cpp (+11 -4)
📝 sycl/src/program/generate.cpp (+7 -2)

📄 Description

Problem and result

When a request's decode moves between the solo path and a batch slot (it is promoted into a slot when a second request arrives, and goes back to solo when that one ends, #1869), the API's timings.draft_n / draft_n_accepted and the /metrics totals reported only the last leg's drafts. BDONE carried no draft counts at all. Still the case on 0.2.0-beta: a 512-token request reported 220 accepted / 312 offered while the engine's own DONE lines for it summed to 300 / 435.

With this change every leg is counted: the same test reports 300 / 438, equal to the engine's per-DONE sums and to the /metrics delta.

none (a reporting fix; no change to decoding or defaults).

Approach

  • BDONE appends the slot leg's accepted / offered draft counts (CUDA src/program/generate.cpp and SYCL sycl/src/program/generate.cpp; 0 0 without --batch-mtp).
  • serve/server.py: _apply_bdone adds them to the admission's counts; carry_leg / add_carry keep them when a slot request goes back to the solo path, so a final solo DONE adds to the earlier counts instead of replacing them. An older engine's four-field BDONE leaves the admission's counts as they were; a missing count stays unreported, an explicit zero stays known.
  • docs/BATCHING.md: the optional protocol fields. serve/test_slot_drafts.py (new) and serve/test_parallel.py: the mixed-leg and handoff cases.

Validation

Setup: 0.2.0-beta main e88ee39d against this branch rebased on it (head 9e736891). 2x Intel Arc Pro B70 32 GB, kernel 7.1, Compute Runtime 26.22.38646.4, SYCL AOT bmg-g31 built with the repository dev image. Qwen3.8-Flash-Next ISTA GSQ-RCO IQ3_XXS, --layer-split 30, "parallel": 2, --max-context 16384 --vram-reserve-mib 512 --kv int8 --spec 4 --mtp <BF16 draft layer> --mtp-max-t 4.

Test (the same script for both builds): (1) a 512-token request decodes alone, a 64-token request arrives 4 s later (the first is promoted into a slot, then handed back to solo when the short one ends); (2) two 256-token requests together. The API's draft counts are compared with the sum of the engine's per-request DONE / BDONE draft lines in the same log window and with the /metrics totals delta.

Passed:

  • This branch, case 1: API 300 accepted / 438 offered = engine sum 300 / 438 (legs 80/123 solo, 0/0 and 0/0 in the slot, 220/315 solo) = /metrics delta. Case 2: 0 / 0 everywhere (a layer split runs no MTP in the slots).
  • main e88ee39d, case 1: API 220 / 312 against an engine sum of 300 / 435 (the first solo leg's 80 / 123 dropped); /metrics matches the API, so both under-report. Case 2: 0 / 0.
  • python -m unittest serve.test_slot_drafts serve.test_parallel in the runtime image: Ran 47 tests ... OK.
  • The SYCL engine of this branch builds (strata, AOT bmg-g31). Per-card health passed after both runs.

Failed: none observed.

Not run: CUDA build (the CUDA BDONE emitter was edited and reviewed, not compiled: no NVIDIA card here); non-zero slot-leg counts on SYCL (needs --batch-mtp, refused on a layer split; on 0.1.x an expert-parallel development stack gave BDONE 40 / 46 plus final DONE 304 / 371 = API 344 / 417, not re-run on 0.2.0).

Limits

  • Telemetry only; no throughput or quality effect.
  • "Accepted" means accepted by verification, including a draft not emitted because the request then stops.
  • Independent of #2526.
  • Prepared with AI assistance (Claude Code): the code, the measurements and this text were produced by Claude on the submitter's two Arc Pro B70s, at the submitter's request.

🤖 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/2511 **Author:** [@hotschmoe](https://github.com/hotschmoe) **Created:** 10/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `batch-mtp-restore-accounting` --- ### 📝 Commits (1) - [`9e73689`](https://github.com/Niko1221/Strata/commit/9e736891cb485220cd9dffe83a8e77b366e9c52e) Report batch MTP draft counts across slot handoffs ### 📊 Changes **6 files changed** (+119 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+6 -1) 📝 `serve/server.py` (+11 -1) 📝 `serve/test_parallel.py` (+14 -1) ➕ `serve/test_slot_drafts.py` (+70 -0) 📝 `src/program/generate.cpp` (+11 -4) 📝 `sycl/src/program/generate.cpp` (+7 -2) </details> ### 📄 Description ## Problem and result When a request's decode moves between the solo path and a batch slot (it is promoted into a slot when a second request arrives, and goes back to solo when that one ends, #1869), the API's `timings.draft_n` / `draft_n_accepted` and the `/metrics` totals reported only the last leg's drafts. `BDONE` carried no draft counts at all. Still the case on 0.2.0-beta: a 512-token request reported 220 accepted / 312 offered while the engine's own DONE lines for it summed to 300 / 435. With this change every leg is counted: the same test reports 300 / 438, equal to the engine's per-DONE sums and to the `/metrics` delta. ## Related discussion none (a reporting fix; no change to decoding or defaults). ## Approach - `BDONE` appends the slot leg's accepted / offered draft counts (CUDA `src/program/generate.cpp` and SYCL `sycl/src/program/generate.cpp`; `0 0` without `--batch-mtp`). - `serve/server.py`: `_apply_bdone` adds them to the admission's counts; `carry_leg` / `add_carry` keep them when a slot request goes back to the solo path, so a final solo DONE adds to the earlier counts instead of replacing them. An older engine's four-field `BDONE` leaves the admission's counts as they were; a missing count stays unreported, an explicit zero stays known. - `docs/BATCHING.md`: the optional protocol fields. `serve/test_slot_drafts.py` (new) and `serve/test_parallel.py`: the mixed-leg and handoff cases. ## Validation Setup: 0.2.0-beta `main` e88ee39d against this branch rebased on it (head 9e736891). 2x Intel Arc Pro B70 32 GB, kernel 7.1, Compute Runtime 26.22.38646.4, SYCL AOT `bmg-g31` built with the repository dev image. Qwen3.8-Flash-Next ISTA GSQ-RCO IQ3_XXS, `--layer-split 30`, `"parallel": 2`, `--max-context 16384 --vram-reserve-mib 512 --kv int8 --spec 4 --mtp <BF16 draft layer> --mtp-max-t 4`. Test (the same script for both builds): (1) a 512-token request decodes alone, a 64-token request arrives 4 s later (the first is promoted into a slot, then handed back to solo when the short one ends); (2) two 256-token requests together. The API's draft counts are compared with the sum of the engine's per-request DONE / BDONE draft lines in the same log window and with the `/metrics` totals delta. **Passed:** - This branch, case 1: API 300 accepted / 438 offered = engine sum 300 / 438 (legs 80/123 solo, 0/0 and 0/0 in the slot, 220/315 solo) = `/metrics` delta. Case 2: 0 / 0 everywhere (a layer split runs no MTP in the slots). - `main` e88ee39d, case 1: API 220 / 312 against an engine sum of 300 / 435 (the first solo leg's 80 / 123 dropped); `/metrics` matches the API, so both under-report. Case 2: 0 / 0. - `python -m unittest serve.test_slot_drafts serve.test_parallel` in the runtime image: `Ran 47 tests ... OK`. - The SYCL engine of this branch builds (`strata`, AOT bmg-g31). Per-card health passed after both runs. **Failed:** none observed. **Not run:** CUDA build (the CUDA `BDONE` emitter was edited and reviewed, not compiled: no NVIDIA card here); non-zero slot-leg counts on SYCL (needs `--batch-mtp`, refused on a layer split; on 0.1.x an expert-parallel development stack gave BDONE 40 / 46 plus final DONE 304 / 371 = API 344 / 417, not re-run on 0.2.0). ## Limits - Telemetry only; no throughput or quality effect. - "Accepted" means accepted by verification, including a draft not emitted because the request then stops. - Independent of #2526. - Prepared with AI assistance (Claude Code): the code, the measurements and this text were produced by Claude on the submitter's two Arc Pro B70s, at the submitter's request. 🤖 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>
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#4085
No description provided.