mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2589] [Engine] serve: opt-in STRATA_SLOT_EXPIRE_S keeps a long conversation's batch slot from a short side request (next turn 12.8 -> 0.3 s) #4149
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4149
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2589
Author: @SuperDistance
Created: 10/15/2026
Status: 🔄 Open
Base:
main← Head:pr/slot-keep-value📝 Commits (2)
2943b42serve: opt-in STRATA_SLOT_EXPIRE_S takes a free batch slot from the conversation cheapest to loseca7d91aserve: STRATA_SLOT_EXPIRE_S also from the run config's "env" block📊 Changes
3 files changed (+230 additions, -10 deletions)
View changed files
📝
docs/BATCHING.md(+5 -1)📝
serve/server.py(+31 -3)📝
serve/test_slot_alloc.py(+194 -6)📄 Description
Problem and result
I run coding agents on Strata with
--batch. Next to their long conversations, clients send short side requests (a title, a summary, a one-line check). When every free slot holds a conversation,pick_slottakes the least recently used one, so a side request can take the slot of a 40K-token conversation that is still going, and that conversation's next turn reads its whole history again: 12.8 s to the first token on 0.2.0-beta (one RTX 5090, below). With the new opt-inSTRATA_SLOT_EXPIRE_S=600the side request takes an expired slot or the one holding the shortest history, and the long conversation's next turn takes 0.34 s. Unset or 0, nothing changes.Related discussion
#1906 and #1930 (agent sessions reading whole prompts again), #1920, #1938. Next to #2527 / #2528 (andyhrc): their placement policy covers pipelined groups; this is the small counterpart for
--batchwithout pipelined groups (one GPU, or--batch-groups 1). qiuzan2001 noted here that the config's"env"block was ignored: the value is now read from the engine's environment (the server's plus the config's"env"). Rebased onto 0.2.0-beta after the tracker reset (one textual conflict: two functions added at the same place).Approach
STRATA_SLOT_EXPIRE_S(seconds; off unless set). Set, a new conversation that finds no empty slot takes an expired one first (idle that long or longer: its client has likely moved on), the least recently used among them; else the one holding the shortest history. Unset or 0: the least recently used one, as before (a test checks it picks main's slot on 3,000 random slot tables). A request still goes to the slot holding its own prefix first, and pipelined groups return before this rule. Changes:pick_slot's lastmin()key,slot_expire_s(env),serve/test_slot_alloc.py, and the sentence on slot choice indocs/BATCHING.md.Validation
Passed:
e88ee39d) + this branch (ca7d91a5), Windows 11, Python 3.12:python -m unittest serve.test_slot_alloc25 OK; the whole serve suite (python -m unittest discover -s serve -t . -p "test_*.py") 899 OK, 21 skipped, against 881 OK, 21 skipped on main.e88ee39d), Swift 1.5 IQ3_S,--batch 3, no pipelined groups, no conversation cache, a fresh engine per arm,STRATA_SLOT_EXPIRE_S=600in the config's"env"block (main ignores it). A third stream decodes all along, so every request goes through a slot. Conversation A (a 40,250-token prompt) and B (about 1,770 tokens) finish and stay in their slots; then a one-line side request; then A's and B's next turns:STRATA_SLOT_EXPIRE_S=600477ac13c), same bench: 14.79 / 14.84 s on main against 0.32 / 0.32 s with 600, and 14.72 s unset. A 21-hour replay of my own agent traffic through the slots (ids, times and token counts only): 17.8 / 20.6 / 21.1% fewer prompt tokens read at 4 / 6 / 8 slots with 600.Failed: none observed.
Not run: a split with
--batch-groups 1on GPUs; the RAM conversation cache on (replay only: smaller gain); AMD, Linux, Mac (Python-only change, nothing to build).Limits
Opt-in, because it changes whose conversation loses its slot and is measured on one user's traffic. A long conversation whose client has gone keeps its slot until it expires; a client whose prompts never match its slot leaves histories that stay until they expire.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.