pp/host2: API-server front-end levers (TOKSPLIT + DETOK_WINDOW): PP +0.2…+2.0%, tier 1 #263

Closed
Grok wants to merge 11 commits from pp/host2 into pp/host
Owner

Stacked on #260 (pp/host). LEDGER R-2026-10-19-fe.

Attribution (S2-hg-ft diag, B1 medians at 4k/16k/32k): TTFT outside the runner was 27/64/120 ms. Of that, the single-thread render (template plus tokenize) was 11/37/71 ms and detokenizer priming on the whole prompt was about 14 ms at 32k. IPC, scheduler and polling were each 2 ms or less, so no lever was built for them.

Levers (default off, reboot class, in-boot self-tests with wrong-input branches; off-card gate bench/runs/pp-host2-front-gate-20261019T122922Z.jsonl all_ok):

  • QWEN36_FRONT_TOKSPLIT=1: prompts of 8192 chars or more are cut at newline→letter boundaries and encoded with one parallel encode_batch; the ids are exact.
  • QWEN36_FRONT_DETOK_WINDOW=1: the detokenizer is primed with a clean 8–16 id suffix; the text is exact.

Card verdict (ttx ab n=2, S2-hg → S2-hg-fe; PP tok/s, TG tok/s/user):

cell PP TG/user
B1/4k 7020 → 7080 (+0.9%) 73.1 → 73.7
B1/32k 6544 → 6672 (+2.0%) 65.5 → 65.4
B4/4k 6508 → 6548 (+0.6%) 76.3 → 76.5
B4/32k 6573 → 6593 (+0.3%) 62.1 → 62.6
B8/4k 6119 → 6183 (+1.0%) 64.7 → 64.7
B8/32k 6562 → 6574 (+0.2%) 52.0 → 52.4

TTFT was −97 ms at B1/32k (expected −55) and −4 ms at B1/4k (expected −5 to −7). Tier 1: B=1 text is identical; the B>1 differences match the control's own rep drift.

Records: bench/runs/ttx-ab-…-dfr-s2-hg-switch-20261019T162130Z.jsonl, bench/runs/pp-host2-fe-verdict-20261019.jsonl, bench/runs/pp-host2-fe-analysis-20261019.jsonl.

🤖 Generated with Claude Code

Stacked on #260 (pp/host). LEDGER `R-2026-10-19-fe`. **Attribution** (S2-hg-ft diag, B1 medians at 4k/16k/32k): TTFT outside the runner was 27/64/120 ms. Of that, the single-thread render (template plus tokenize) was 11/37/71 ms and detokenizer priming on the whole prompt was about 14 ms at 32k. IPC, scheduler and polling were each 2 ms or less, so no lever was built for them. **Levers** (default off, reboot class, in-boot self-tests with wrong-input branches; off-card gate `bench/runs/pp-host2-front-gate-20261019T122922Z.jsonl` all_ok): - `QWEN36_FRONT_TOKSPLIT=1`: prompts of 8192 chars or more are cut at newline→letter boundaries and encoded with one parallel `encode_batch`; the ids are exact. - `QWEN36_FRONT_DETOK_WINDOW=1`: the detokenizer is primed with a clean 8–16 id suffix; the text is exact. **Card verdict** (ttx ab n=2, S2-hg → S2-hg-fe; PP tok/s, TG tok/s/user): | cell | PP | TG/user | |---|---|---| | B1/4k | 7020 → 7080 (+0.9%) | 73.1 → 73.7 | | B1/32k | 6544 → 6672 (+2.0%) | 65.5 → 65.4 | | B4/4k | 6508 → 6548 (+0.6%) | 76.3 → 76.5 | | B4/32k | 6573 → 6593 (+0.3%) | 62.1 → 62.6 | | B8/4k | 6119 → 6183 (+1.0%) | 64.7 → 64.7 | | B8/32k | 6562 → 6574 (+0.2%) | 52.0 → 52.4 | TTFT was −97 ms at B1/32k (expected −55) and −4 ms at B1/4k (expected −5 to −7). Tier 1: B=1 text is identical; the B>1 differences match the control's own rep drift. Records: `bench/runs/ttx-ab-…-dfr-s2-hg-switch-20261019T162130Z.jsonl`, `bench/runs/pp-host2-fe-verdict-20261019.jsonl`, `bench/runs/pp-host2-fe-analysis-20261019.jsonl`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R-2026-10-19-hg left client->runner at 18 ms (4k) / 83 ms (32k) and runner->client at 6-33 ms,
all outside the model and all inside TTFT, hence inside PP. Nothing in the logs splits it.

vllm_tt_plugin.front_latency wraps (class level, host clocks only) the chat handler, render
(template + tokenize), AsyncLLM.add_request/_add_request, OutputProcessor.process_outputs and the
SSE stream in the API server, and preprocess_add_request / add_request / schedule in the engine
core. Installed from the plugin's general-plugin entry point (entrypoints.py now vendored), which
returns at once with the flag unset. All 8 hook targets checked present in vllm-tt:k2-mr-pk3r
(vLLM 0.26.0) by an import-only container (no devices).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
First S2-hg-ft boot (11:50Z, records added): 37 engine-core lines and no api lines. vLLM runs the
route handler in its own task (with_cancellation) and the StreamingResponse iterates the generator
(where generate() -> add_request() runs) in another, so the ContextVar set in the handler was
invisible at add_request. Stamps now travel by request-object id to the stream wrapper, which sets
the ContextVar in the task that calls add_request; a g0 stamp splits handler return from the
stream start. tests/test_front_latency.py reproduces the two-task structure on fake vLLM classes
(4/4; the first version fails it). No speed number from that boot (diagnostic, attribution only).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The S2-hg-ft boot (12:11Z) splits B1 TTFT outside the runner (26 / 64 / 120 ms at 4k / 16k / 32k):
render (chat template + tokenize) 11 / 37 / 71 and api_out (first output -> first SSE chunk)
5 / 16 / 34 scale with the prompt; IPC, engine-core add/schedule, the client and the rest are ~10 ms.
Believed before: ZMQ/msgpack of the prompt ids or scheduler overhead. Both are under 2 ms.

- TOKSPLIT: long prompts are cut only after a newline run and before a letter/digit (a Qwen
  pre-token boundary) and encoded with one encode_batch (parallel, GIL released). cfx-llm2
  (Ryzen 3 1200, 4 cores), vLLM's process: 32k-token prompt 62-64 ms -> 20-25 ms.
- DETOK_WINDOW: vLLM primes DecodeStream with every prompt id, so the first step decodes the
  whole prompt (13.8 ms at 32k in the image). Primed with the shortest clean (no U+FFFD)
  8..16-id suffix instead; a prompt ending inside a character keeps the full priming (vLLM
  itself emits prompt text there, found by the self-test).
Both self-test at boot on the served tokenizer (fail closed, wrong-input branch, _MUSTFAIL
refuses). In-image gate (vLLM 0.26.0, transformers 5.12.1, tokenizers 0.22.2):
bench/runs/pp-host2-front-gate-20261019T122922Z.jsonl all_ok (6 rungs). Host tests 11/11 + 4/4.
No card number yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
B1 medians (ms) 4k / 16k / 32k: TTFT 586 / 2435 / 5038, runner 560 / 2371 / 4919, outside
27 / 64 / 120: render 11 / 37 / 71, api_out 5 / 16 / 34; client->handler 1.8-2.5, IPC in
0.3-1.7, engine core add..schedule <1.2, IPC out ~1, to client 0.5-1.7. At B8 the 32k
requests queue behind each other's prefill (to_schedule seconds), as expected; render under
8 concurrent requests is serial in vLLM's one renderer thread (median 317 ms at 32k), hidden
behind the earlier users' prefill. Host clocks of an instrumented boot; no speed number.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Believed before: the 18/83 ms client->runner gap held IPC/serialization and
engine-core polling. The S2-hg-ft attribution showed those are <=2 ms each;
the prompt-scaled hops are the single-thread render (71 ms at 32k) and the
detokenizer priming on the whole prompt (14 ms). Split tokenization and a
windowed detok prime save 97 ms TTFT at B1/32k and 4 ms at B1/4k on cards.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
serving: bind-mount the front-end plugin files in the Nix unit
All checks were successful
cards-fresh cards: fresh (run 845) fp=40ce3edeec0f2cd2
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 4m3s
tt-stack-ci / Report upstream drift (pull_request) Successful in 1m29s
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 2m50s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
a8f8fffbba
test_prod_matches_nix failed on this branch the same way it did for
prefill_host.py (CI 9511): ttx overlays the whole prod-local-plugin tree, the
unit listed only some files. entrypoints.py imports front_latency (and through
it front_levers) unconditionally, so all three must be present on every boot;
they patch nothing unless a QWEN36_FRONT_* flag is set.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Owner

Superseded: #260 (pp/host) is on master already, so this goes against master instead.

Superseded: #260 (pp/host) is on master already, so this goes against master instead.
Grok closed this pull request 2026-10-19 18:51:43 +02:00
Author
Owner

agent-gateway closeout (closed): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (closed): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Owner

Verdict: APPROVE (comment-only — human-approved label held until the head card gate lands). Session model: agent-dense (already active).

Standalone front-end levers on pp/host (#260): QWEN36_FRONT_TOKSPLIT + QWEN36_FRONT_DETOK_WINDOW, arm …-dfr-s2-hg-fe, LEDGER R-2026-10-19-fe.

Tier: 1 — B=1 served text identical at both contexts; B>1 differs only on prompts whose two control reps already differ (each arm rep matches a control text).

What I checked

  • Off path is a true no-op: install() returns before patching when the flags are unset; front_latency.install() likewise returns before _install_api/_core_timing. The new entrypoints.register() runs in every vLLM process but is inert until a flag is set — correct default-empty behavior.
  • Per-tokenizer identity guard: the toksplit wrapper only uses the split path when self.get_tokenizer()._tokenizer is st["backend"] (the exact self-tested backend) and falls back on offsets/other encode kwargs/truncation/add_special_tokens. Detok window keeps full-prompt priming whenever the suffix wouldn't decode clean (no U+FFFD).
  • Correctness gates: in-image gate pp-host2-front-gate-…jsonl all_ok (vllm 0.26.0 / tokenizers 0.22.2), both MUSTFAIL rungs REFUSED (toksplit mid-word, detok no-context). Host tests pin the wrapper fallbacks + flag-gating.
  • Card A/B (n=2, separate boots): PP +0.2…+2.0% in 6/6 cells, TG/user flat (−0.2…+0.8%), TTFT −97 ms at B1/32k. Verdict record reconciles with the PR table.
  • Arms: inheritance is the legitimate union (parent flags retained, only the new [env] lever added). Bracket-safe banner conflict check: NONE on both the -fe and -ft arms.
  • No secrets in the diff.

Concerns (non-blocking)

  • [warn] The A/B is n=2 and the win is small; the record itself notes ~30% band false-positive at n=2, and B1/32k TTFT −97 ms vs the −55 ms attribution (excess explicitly "not attributed"). The mechanism (removing serial tokenize + whole-prompt detok priming from the TTFT path) is real, but the margin sits near the noise floor at most cells.
  • [warn] The head CI (run 9525) is still running — the "Serialized card gate" job is blocked on the mesh slot. That is why the label is held; re-review when it turns green.
  • [warn] entrypoints.py imports vllm_tt_plugin.model_registry, which is not in this repo's overlay (it ships in the serving image). The six arm/control boots prove the import resolves, but the plugin is a partial source overlay copied into the image — if model_registry moves/renames on the image side, register() breaks at boot.

Approve on substance; label is deliberately not applied (non-draft PR → label is the entire auto-merge trigger). Re-review when the card gate lands.

**Verdict: APPROVE (comment-only — `human-approved` label held until the head card gate lands).** Session model: `agent-dense` (already active). Standalone front-end levers on pp/host (#260): `QWEN36_FRONT_TOKSPLIT` + `QWEN36_FRONT_DETOK_WINDOW`, arm `…-dfr-s2-hg-fe`, LEDGER `R-2026-10-19-fe`. **Tier: 1** — B=1 served text identical at both contexts; B>1 differs only on prompts whose two control reps already differ (each arm rep matches a control text). **What I checked** - Off path is a true no-op: `install()` returns before patching when the flags are unset; `front_latency.install()` likewise returns before `_install_api/_core_timing`. The new `entrypoints.register()` runs in every vLLM process but is inert until a flag is set — correct default-empty behavior. - Per-tokenizer identity guard: the toksplit wrapper only uses the split path when `self.get_tokenizer()._tokenizer is st["backend"]` (the exact self-tested backend) and falls back on offsets/other encode kwargs/truncation/add_special_tokens. Detok window keeps full-prompt priming whenever the suffix wouldn't decode clean (no U+FFFD). - Correctness gates: in-image gate `pp-host2-front-gate-…jsonl` `all_ok` (vllm 0.26.0 / tokenizers 0.22.2), both MUSTFAIL rungs REFUSED (toksplit mid-word, detok no-context). Host tests pin the wrapper fallbacks + flag-gating. - Card A/B (n=2, separate boots): PP +0.2…+2.0% in 6/6 cells, TG/user flat (−0.2…+0.8%), TTFT −97 ms at B1/32k. Verdict record reconciles with the PR table. - Arms: inheritance is the legitimate union (parent flags retained, only the new `[env]` lever added). Bracket-safe banner conflict check: NONE on both the `-fe` and `-ft` arms. - No secrets in the diff. **Concerns (non-blocking)** - [warn] The A/B is n=2 and the win is small; the record itself notes ~30% band false-positive at n=2, and B1/32k TTFT −97 ms vs the −55 ms attribution (excess explicitly "not attributed"). The mechanism (removing serial tokenize + whole-prompt detok priming from the TTFT path) is real, but the margin sits near the noise floor at most cells. - [warn] The head CI (run 9525) is still `running` — the "Serialized card gate" job is `blocked` on the mesh slot. That is why the label is held; re-review when it turns green. - [warn] `entrypoints.py` imports `vllm_tt_plugin.model_registry`, which is not in this repo's overlay (it ships in the serving image). The six arm/control boots prove the import resolves, but the plugin is a partial source overlay copied into the image — if `model_registry` moves/renames on the image side, `register()` breaks at boot. Approve on substance; label is deliberately not applied (non-draft PR → label is the entire auto-merge trigger). Re-review when the card gate lands.
All checks were successful
cards-fresh cards: fresh (run 845) fp=40ce3edeec0f2cd2
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 4m3s
tt-stack-ci / Report upstream drift (pull_request) Successful in 1m29s
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 2m50s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
bitpartner/tt-stack!263
No description provided.