plugin #283 port: a continuing chunked prefill keeps its device state slot #378

Merged
orchestra merged 1 commit from plugin-283-slot-keep into master 2026-11-09 09:56:53 +01:00
Member

Ports vllm-tt-plugin #283 (open upstream) into the served plugin overlay. Served code, no env gate. Deploy only with the next TT arm ship, not on its own (the arm identity sha changes with this file).

Change (patches/prod-local-plugin/src/vllm_tt_plugin/model_runner.py, _alloc_prefill_state_slots): a request that already owns a device state slot keeps it; only requests without one are placed by row (own row if free, else the first free slot), as before. The map is checked for two requests owning one slot (RuntimeError). Upstream's 8 lines, our docstring.

Why it is behaviour-neutral for our served path: the S12 prefix path never reads a continuation's input state from its decode slot. It resumes from the host snapshot PrefixCache.live[request_id] or from the B=1 scratch tagged (request id, start); the slot is only the slot-copy target, which the final chunk rewrites whole (analysis in #377, §2.5). So the fix changes only which slot a continuing chunk writes.

Test tests/test_state_slot_continuing_chunk.py (host-only, no torch/vLLM, ~12 s, python3 -m unittest tests.test_state_slot_continuing_chunk): 7/7 pass.

  1. served allocator keeps B's slot in #283's scenario;
  2. a slot-reading model (what #283 protects) decodes every request's own state;
  3. falsifier: the pre-port allocator (kept verbatim in the test) corrupts the slot-reading model;
  4. behaviour-neutral: a host model of our served semantics (real PrefixCache + prefix_snap.resident_order) decodes identical, correct per-request states under old and new allocators, on #283's scenario and 150 random chunked traces (asserts >= 10 traces where the slot choice differs, so it is not vacuous);
  5. with no continuation, old and new give identical slots and maps on 600 random traces;
  6. rows swapping between chunks keep their slots;
  7. two owners of one slot are refused.

Mutation check: with model_runner.py reverted to origin/master, tests 1, 2, 4, 6, 7 FAIL (3 and 5 pass, as they must).

Needs an independent review before merge.

🤖 Generated with Claude Code

Ports vllm-tt-plugin #283 (open upstream) into the served plugin overlay. Served code, no env gate. **Deploy only with the next TT arm ship**, not on its own (the arm identity sha changes with this file). **Change** (`patches/prod-local-plugin/src/vllm_tt_plugin/model_runner.py`, `_alloc_prefill_state_slots`): a request that already owns a device state slot keeps it; only requests without one are placed by row (own row if free, else the first free slot), as before. The map is checked for two requests owning one slot (RuntimeError). Upstream's 8 lines, our docstring. **Why it is behaviour-neutral for our served path:** the S12 prefix path never reads a continuation's input state from its decode slot. It resumes from the host snapshot `PrefixCache.live[request_id]` or from the B=1 scratch tagged (request id, start); the slot is only the slot-copy target, which the final chunk rewrites whole (analysis in #377, §2.5). So the fix changes only which slot a continuing chunk writes. **Test** `tests/test_state_slot_continuing_chunk.py` (host-only, no torch/vLLM, ~12 s, `python3 -m unittest tests.test_state_slot_continuing_chunk`): 7/7 pass. 1. served allocator keeps B's slot in #283's scenario; 2. a slot-reading model (what #283 protects) decodes every request's own state; 3. falsifier: the pre-port allocator (kept verbatim in the test) corrupts the slot-reading model; 4. behaviour-neutral: a host model of our served semantics (real `PrefixCache` + `prefix_snap.resident_order`) decodes identical, correct per-request states under old and new allocators, on #283's scenario and 150 random chunked traces (asserts >= 10 traces where the slot choice differs, so it is not vacuous); 5. with no continuation, old and new give identical slots and maps on 600 random traces; 6. rows swapping between chunks keep their slots; 7. two owners of one slot are refused. **Mutation check:** with `model_runner.py` reverted to origin/master, tests 1, 2, 4, 6, 7 FAIL (3 and 5 pass, as they must). Needs an independent review before merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
plugin #283 port: a continuing chunked prefill keeps its device state slot
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Successful in 2m27s
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 6m49s
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 17m32s
cards-fresh cards: not measured (serving active or MemAvailable low); add cards:go to retry
tt-stack-ci / Serialized card gate (pull_request) Successful in 13m57s
70d1ad2de6
_alloc_prefill_state_slots now keeps the slot a request already owns (only
requests without one are placed by row) and refuses two owners of one slot,
as vllm-tt-plugin #283. No env gate. Behaviour-neutral for the served S12
prefix path, which resumes continuations from the host snapshot or the B=1
scratch, never from the slot: tests/test_state_slot_continuing_chunk.py
(7 tests; 5 fail on the pre-port allocator).

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

verdict: approve
tier: T1

rationale: Two-file additive port of upstream vllm-tt-plugin #283: _alloc_prefill_state_slots now keeps a request's already-owned state slot (only unowned requests are placed by row) and refuses two owners of one slot; the rest of the allocator is untouched. Served semantics are unaffected by design: the S12 prefix path resumes continuations from the host snapshot or the B=1 scratch, never from the decode slot, so the change only moves which slot a continuing chunk writes.

concerns:

  • [warn] head CI run 11796 is still waiting (build jobs queued, "Serialized card gate" blocked behind them) on 70d1ad2 — the human-approved label is held until the head run lands green; re-dispatch or re-check when it completes.
  • [nit] no-env-gate, always-on allocator change: deploy bundled with the next TT arm ship (not on its own), per the PR note — the arm identity sha changes with this file.

verification (in-kernel, no clone):

  • Full PR diff is exactly the two declared files (compare 04eee3cc...70d1ad2: model_runner.py modified, tests/test_state_slot_continuing_chunk.py added); no CI/arm/doc surface touched.
  • Head model_runner.py: test suite 7/7 pass.
  • Mutation check reproduced: with model_runner.py reverted to the PR base, tests 1, 2, 4, 6, 7 FAIL (3, 5 pass) — exactly as the PR body claims.
  • Test self-lifts the served allocator via AST from the shipped model_runner.py (no torch/vLLM import); the pre-#283 allocator is kept verbatim as the reference; behaviour-neutrality is shown against the real PrefixCache/prefix_snap modules plus 150 chunked / 600 non-chunked random traces with a moved-slot count floor.
**verdict:** approve **tier:** T1 **rationale:** Two-file additive port of upstream vllm-tt-plugin #283: `_alloc_prefill_state_slots` now keeps a request's already-owned state slot (only unowned requests are placed by row) and refuses two owners of one slot; the rest of the allocator is untouched. Served semantics are unaffected by design: the S12 prefix path resumes continuations from the host snapshot or the B=1 scratch, never from the decode slot, so the change only moves which slot a continuing chunk writes. **concerns:** - [warn] head CI run 11796 is still `waiting` (build jobs queued, "Serialized card gate" `blocked` behind them) on `70d1ad2` — the `human-approved` label is held until the head run lands green; re-dispatch or re-check when it completes. - [nit] no-env-gate, always-on allocator change: deploy bundled with the next TT arm ship (not on its own), per the PR note — the arm identity sha changes with this file. **verification (in-kernel, no clone):** - Full PR diff is exactly the two declared files (`compare 04eee3cc...70d1ad2`: `model_runner.py` modified, `tests/test_state_slot_continuing_chunk.py` added); no CI/arm/doc surface touched. - Head `model_runner.py`: test suite **7/7 pass**. - Mutation check reproduced: with `model_runner.py` reverted to the PR base, **tests 1, 2, 4, 6, 7 FAIL** (3, 5 pass) — exactly as the PR body claims. - Test self-lifts the served allocator via AST from the shipped `model_runner.py` (no torch/vLLM import); the pre-#283 allocator is kept verbatim as the reference; behaviour-neutrality is shown against the real `PrefixCache`/`prefix_snap` modules plus 150 chunked / 600 non-chunked random traces with a moved-slot count floor.
Author
Member

Independent review (Opus reviewer agent, read-only): LAND, no blocking defects.

  • Port is line-for-line upstream #283 (model_runner.py:1722-1737); only the docstring differs.
  • Tests: 7/7 pass on HEAD; with origin/master's model_runner.py swapped in, tests 1, 2, 4, 6, 7 fail (4 on its non-vacuity guard); 3 passes on both by design. Worktree restored.
  • Served path: continuations resume from prefix["states"] / scratch (model.py:2887-2908); slot only written (2963/2974/3009; ONESTEP mid readback reads the slot written earlier in the same step). Decode remap moves every map entry by a permutation, so a kept slot cannot collide with a live owner; settle commits before any next prefill allocation. Duplicate-owner RuntimeError not reachable by reading. MTP warm span keyed by request id; checkpoint readback and P/D export use this step's slots; lane mode does not use this allocator.

Low-severity notes:

  1. A kept slot can differ from the request's decode row → one non-identity remap, and mtp_batch_host.py:1234 then runs a full-width decode bucket for that step (perf only, at most one step after a reorder).
  2. Neutrality is proven against a host re-implementation of prefill_paged_slots (real PrefixCache + resident_order); ONESTEP head/tail, the non-device-copy fallback and MTP are covered by code reading, not the test.
  3. Random traces have no decode/remap/preempt steps; optional hardening.

Deploy with the next TT arm ship only.

**Independent review (Opus reviewer agent, read-only): LAND, no blocking defects.** - Port is line-for-line upstream #283 (`model_runner.py:1722-1737`); only the docstring differs. - Tests: 7/7 pass on HEAD; with origin/master's `model_runner.py` swapped in, tests 1, 2, 4, 6, 7 fail (4 on its non-vacuity guard); 3 passes on both by design. Worktree restored. - Served path: continuations resume from `prefix["states"]` / scratch (`model.py:2887-2908`); slot only written (2963/2974/3009; ONESTEP mid readback reads the slot written earlier in the same step). Decode remap moves every map entry by a permutation, so a kept slot cannot collide with a live owner; settle commits before any next prefill allocation. Duplicate-owner RuntimeError not reachable by reading. MTP warm span keyed by request id; checkpoint readback and P/D export use this step's slots; lane mode does not use this allocator. Low-severity notes: 1. A kept slot can differ from the request's decode row → one non-identity remap, and `mtp_batch_host.py:1234` then runs a full-width decode bucket for that step (perf only, at most one step after a reorder). 2. Neutrality is proven against a host re-implementation of `prefill_paged_slots` (real `PrefixCache` + `resident_order`); ONESTEP head/tail, the non-device-copy fallback and MTP are covered by code reading, not the test. 3. Random traces have no decode/remap/preempt steps; optional hardening. Deploy with the next TT arm ship only.
orchestra merged commit 9f5aa330a8 into master 2026-11-09 09:56:53 +01:00
Owner

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

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

Cards skipped

Cards unavailable on cfx-llm0 for PR #378 70d1ad2de6a7208d33f081bc7ccd19028ca3b6c9.

  • systemctl is-active tenstorrent-serving.service = active (need inactive)
  • MemAvailable = 39521140 kB (need >= 4000000)

No slot taken, no boot. This skip is green.

## Cards skipped Cards unavailable on `cfx-llm0` for PR #378 `70d1ad2de6a7208d33f081bc7ccd19028ca3b6c9`. - `systemctl is-active tenstorrent-serving.service` = `active` (need `inactive`) - MemAvailable = `39521140` kB (need >= 4000000) No slot taken, no boot. This skip is green.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!378
No description provided.