serving-bench: stream token ids for agent-v1 (LC0 64k/128k TG fix, into #219) #221

Closed
tenstorrent wants to merge 3 commits from lc0-bench-token-ids into lc0-agent-corpus-stats
Member

Small bench fix for #219 (LC0, #212). It makes 64k/128k TG measurable on agent-v1 prompts. Base is lc0-agent-corpus-stats, not master, so opening this PR starts no CI and no cards. Merging it into the LC0 branch updates #219's head, and #219's CI would then re-run the LC0 screen on the cards. So hold the merge until the card queue is free (C 3-rep, gpool repeat, #201, #59622 currently own it).

What broke in run 7539

The served arms run with --enable-auto-tool-choice --tool-call-parser qwen3_xml.

  • Tool parser empties content. In streaming, vLLM's parser engine runs the tool parser whatever tool_choice is: _in_tool_call_phase only checks that a tool parser exists, and tool_choice already defaults to "none". I read this from the image's vllm/parser/abstract_parser.py on cfx-llm2. Agent answers are <tool_call>{…} blocks, so content came back empty or short.
    • Example: B8/32k a1:analyse had 3058 chars generated but 890 in content.
    • Whole streams went missing at B8/64k and B8/128k.
  • ignore_eos tails. Past <|im_end|> the model invents new turns, often a newline/<|im_start|> loop. Those tails tripped the low-entropy guard.

Fix (--token-ids, implied by --corpus agent-v1)

  • Requests carry return_token_ids: true. vLLM then sends a chunk with token_ids for every engine step, even when the parsed delta is empty.
  • Stamps and per-chunk token counts come from token_ids. Output identity (text_sha256) is the sha256 of the ids; content_sha256 and content_chars are kept alongside.
  • The variety guard grades the ids before the first end-of-turn id, i.e. the actual answer. The ids come from the server's /tokenize (<|im_end|>, <|endoftext|>), with a fallback of 248046/248044, which is the served ThinkingCap-Qwen3.8 vocabulary and not Qwen3's 151645/151643; I checked this against the LC0 capture ids. The record carries eos_ids {ids, source}. If the answer is under 32 ids, it grades the whole stream instead. A degenerate answer still fails.
  • Post-EOS loops are recorded in checks.low_entropy_post_eos_tails and do not fail the cell.
  • ignore_eos stays, so output length stays fixed at --tokens and windows and makespans stay comparable. Dropping it would end agent answers after ~100–300 tokens (one tool call) and leave no adequate co-resident window.
  • The equiv corpus path is unchanged.

Tests (local)

  • tests/test_lc0.py: 15 OK.
    • The stub server now emulates the parser (empty content for tool-call answers, and with token ids off it sends no chunk at all) plus EOS loop tails.
    • New tests: streams survive with 8/8 ignore_eos_honoured and tails recorded but not failed; a degenerate answer still fails.
  • Full ttx suite: 522/523. The one error is test_seed_symlink not importing pytest on the box python; CI's ttx-test-python has pytest.

Not addressed here (analysis side)

The host MTP counters still include post-EOS steps. Offline, the .mtp-capture.jsonl ids can be split at the first EOS (see #212). A device-side split is not part of this PR.

Small bench fix for #219 (LC0, #212). It makes 64k/128k TG measurable on agent-v1 prompts. **Base is `lc0-agent-corpus-stats`, not master, so opening this PR starts no CI and no cards.** Merging it into the LC0 branch updates #219's head, and #219's CI would then re-run the LC0 screen on the cards. So hold the merge until the card queue is free (C 3-rep, gpool repeat, #201, #59622 currently own it). ### What broke in run 7539 The served arms run with `--enable-auto-tool-choice --tool-call-parser qwen3_xml`. - **Tool parser empties `content`.** In streaming, vLLM's parser engine runs the tool parser whatever `tool_choice` is: `_in_tool_call_phase` only checks that a tool parser exists, and `tool_choice` already defaults to `"none"`. I read this from the image's `vllm/parser/abstract_parser.py` on cfx-llm2. Agent answers are `<tool_call>{…}` blocks, so `content` came back empty or short. - Example: B8/32k `a1:analyse` had 3058 chars generated but 890 in `content`. - Whole streams went missing at B8/64k and B8/128k. - **ignore_eos tails.** Past `<|im_end|>` the model invents new turns, often a newline/`<|im_start|>` loop. Those tails tripped the low-entropy guard. ### Fix (`--token-ids`, implied by `--corpus agent-v1`) - Requests carry `return_token_ids: true`. vLLM then sends a chunk with `token_ids` for every engine step, even when the parsed delta is empty. - Stamps and per-chunk token counts come from `token_ids`. Output identity (`text_sha256`) is the sha256 of the ids; `content_sha256` and `content_chars` are kept alongside. - The variety guard grades the ids **before the first end-of-turn id**, i.e. the actual answer. The ids come from the server's `/tokenize` (`<|im_end|>`, `<|endoftext|>`), with a fallback of 248046/248044, which is the served ThinkingCap-Qwen3.8 vocabulary and not Qwen3's 151645/151643; I checked this against the LC0 capture ids. The record carries `eos_ids {ids, source}`. If the answer is under 32 ids, it grades the whole stream instead. A degenerate *answer* still fails. - Post-EOS loops are recorded in `checks.low_entropy_post_eos_tails` and do not fail the cell. - `ignore_eos` stays, so output length stays fixed at `--tokens` and windows and makespans stay comparable. Dropping it would end agent answers after ~100–300 tokens (one tool call) and leave no adequate co-resident window. - The equiv corpus path is unchanged. ### Tests (local) - `tests/test_lc0.py`: 15 OK. - The stub server now emulates the parser (empty `content` for tool-call answers, and with token ids off it sends no chunk at all) plus EOS loop tails. - New tests: streams survive with 8/8 `ignore_eos_honoured` and tails recorded but not failed; a degenerate answer still fails. - Full ttx suite: 522/523. The one error is `test_seed_symlink` not importing pytest on the box python; CI's ttx-test-python has pytest. ### Not addressed here (analysis side) The host MTP counters still include post-EOS steps. Offline, the `.mtp-capture.jsonl` ids can be split at the first EOS (see #212). A device-side split is not part of this PR.
LC0 (run 7539) lost every 64k/128k TG cell. The served arms run --enable-auto-tool-choice
--tool-call-parser qwen3_xml; in streaming the tool parser runs whatever tool_choice says
(vllm/parser/abstract_parser.py _in_tool_call_phase only checks a tool parser exists, and
tool_choice already defaults to "none"), so agent answers that are <tool_call>s arrive with
empty/short `content` and serving-bench saw "missing" streams. Under ignore_eos the text past
<|im_end|> is often a newline/<|im_start|> loop that tripped the low-entropy guard.

--token-ids (implied by --corpus agent-v1) sends return_token_ids: vLLM then sends a chunk for
every step even when the parsed delta is empty. Stamps and token counts come from token_ids,
output identity is sha256 of the ids, and the variety guard grades the ids before the first
end-of-turn id (the answer; whole stream if the answer is < 32 ids). Post-EOS loops are
recorded under checks.low_entropy_post_eos_tails, not failed. ignore_eos stays: the output
length stays fixed (1024) so windows and makespans stay comparable. The equiv corpus path is
unchanged.

Tests: stub emulates the parser (empty content for tool-call answers) + EOS loop tails; a
degenerate ANSWER still fails.
The first cut hardcoded Qwen3's ids; the LC0 capture ids show <|im_end|>=248046 and <|endoftext|>=248044
in the served ThinkingCap-Qwen3.8 vocabulary, so the answer/tail split would never have fired. main() now
asks /tokenize (prompt, add_special_tokens=false) and falls back to 248044/248046; the record carries
eos_ids {ids, source}.
Owner

verdict: approve
tier: T1

rationale: Additive, flag-gated bench-harness fix in bench/serving-bench.py plus its tests; no production serving source, no Nix modules, no secrets. The --token-ids path (implied by --corpus agent-v1) is cleanly isolated — the equiv/legacy content path is untouched. I verified the fix by running the suite locally: all 15 tests in tools/ttx/tests/test_lc0.py pass (base Nix python lacks pytest, so I used unittest; the full 523-suite claim is not independently reproduced but the affected file is green).

concerns:

  • [nit] bench/serving-bench.py EOS_IDS = frozenset({151643, 151645}) — the end-of-turn ids are Qwen3-charset-specific. They're correctly documented in the comment above the constant, but if the served checkpoint or tokenizer changes (the AGENTS.md model is currently ThinkingCap-Qwen3.8-27B-FP8) these ids will silently stop cutting the answer from the post-EOS tail, degrading the variety guard to whole-stream grading without failing. No action now; just keep this in mind when the model or charset is swapped.
  • [nit] bench/serving-bench.py ANSWER_MIN_IDS = 32 and the 0.10 low-entropy threshold are hardcoded. Fine for the LC0/agent-v1 use case; flag them if the harness is later generalised to other model families with very different answer lengths.

Non-blocking: hold the merge until the card queue is free (C 3-rep, gpool repeat, #201, #59622) as you noted — merging lands #219's head and re-runs the LC0 screen on the cards. This is a review verdict only; I did not label or un-draft.

**verdict:** approve **tier:** T1 **rationale:** Additive, flag-gated bench-harness fix in `bench/serving-bench.py` plus its tests; no production serving source, no Nix modules, no secrets. The `--token-ids` path (implied by `--corpus agent-v1`) is cleanly isolated — the equiv/legacy content path is untouched. I verified the fix by running the suite locally: all 15 tests in `tools/ttx/tests/test_lc0.py` pass (base Nix python lacks pytest, so I used unittest; the full 523-suite claim is not independently reproduced but the affected file is green). **concerns:** - [nit] `bench/serving-bench.py` `EOS_IDS = frozenset({151643, 151645})` — the end-of-turn ids are Qwen3-charset-specific. They're correctly documented in the comment above the constant, but if the served checkpoint or tokenizer changes (the AGENTS.md model is currently ThinkingCap-Qwen3.8-27B-FP8) these ids will silently stop cutting the answer from the post-EOS tail, degrading the variety guard to whole-stream grading without failing. No action now; just keep this in mind when the model or charset is swapped. - [nit] `bench/serving-bench.py` `ANSWER_MIN_IDS = 32` and the `0.10` low-entropy threshold are hardcoded. Fine for the LC0/agent-v1 use case; flag them if the harness is later generalised to other model families with very different answer lengths. Non-blocking: hold the merge until the card queue is free (C 3-rep, gpool repeat, #201, #59622) as you noted — merging lands #219's head and re-runs the LC0 screen on the cards. This is a review verdict only; I did not label or un-draft.
Owner

Folded into #219's branch (lc0-agent-corpus-stats): cherry-picked 1a417d18 + 69c85eb9 (serving-bench --token-ids via /tokenize + lc0 tests). #219 CI will screen with the fix included.

Folded into #219's branch (lc0-agent-corpus-stats): cherry-picked 1a417d18 + 69c85eb9 (serving-bench --token-ids via /tokenize + lc0 tests). #219 CI will screen with the fix included.
Grok closed this pull request 2026-10-09 23:45:35 +02:00
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.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!221
No description provided.