[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

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

📋 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)

  • 2943b42 serve: opt-in STRATA_SLOT_EXPIRE_S takes a free batch slot from the conversation cheapest to lose
  • ca7d91a serve: 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_slot takes 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-in STRATA_SLOT_EXPIRE_S=600 the 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.

#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 --batch without 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 last min() key, slot_expire_s(env), serve/test_slot_alloc.py, and the sentence on slot choice in docs/BATCHING.md.

Which batch slot a new conversation takes: its own history; else an empty slot; else (new) the longest idle of the slots idle STRATA_SLOT_EXPIRE_S or more; else (new) the one holding the shortest history

Validation

Passed:

  • 0.2.0-beta (main e88ee39d) + this branch (ca7d91a5), Windows 11, Python 3.12: python -m unittest serve.test_slot_alloc 25 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.
  • One RTX 5090 (Windows 11), engine built from 0.2.0-beta (e88ee39d), Swift 1.5 IQ3_S, --batch 3, no pipelined groups, no conversation cache, a fresh engine per arm, STRATA_SLOT_EXPIRE_S=600 in 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:
main this, STRATA_SLOT_EXPIRE_S=600 this, unset
slot the side request took A's (40,250 tokens held) B's (1,781 held) A's (40,250 held)
A's next turn: first token 12.78 s 0.34 s 12.70 s
B's next turn: first token 1.20 s 1.18 s 1.17 s
  • Before the rebase, on 0.1.45 (477ac13c), 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 1 on 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.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2589 **Author:** [@SuperDistance](https://github.com/SuperDistance) **Created:** 10/15/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/slot-keep-value` --- ### 📝 Commits (2) - [`2943b42`](https://github.com/Niko1221/Strata/commit/2943b42a6a7fa52a3bf3b46139355f97e7816246) serve: opt-in STRATA_SLOT_EXPIRE_S takes a free batch slot from the conversation cheapest to lose - [`ca7d91a`](https://github.com/Niko1221/Strata/commit/ca7d91a50065bf82565e69dd86b8befa510ad54a) serve: STRATA_SLOT_EXPIRE_S also from the run config's "env" block ### 📊 Changes **3 files changed** (+230 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+5 -1) 📝 `serve/server.py` (+31 -3) 📝 `serve/test_slot_alloc.py` (+194 -6) </details> ### 📄 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_slot` takes 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-in `STRATA_SLOT_EXPIRE_S=600` the 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 `--batch` without 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 last `min()` key, `slot_expire_s(env)`, `serve/test_slot_alloc.py`, and the sentence on slot choice in `docs/BATCHING.md`. <picture> <source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/bd84b68b-ce4e-4b9d-91cf-17b3e2418507"> <img alt="Which batch slot a new conversation takes: its own history; else an empty slot; else (new) the longest idle of the slots idle STRATA_SLOT_EXPIRE_S or more; else (new) the one holding the shortest history" src="https://github.com/user-attachments/assets/594e7eb8-8637-40b0-aa25-27ba6d0fc063" width="740"> </picture> ## Validation **Passed:** - 0.2.0-beta (main e88ee39d) + this branch (ca7d91a5), Windows 11, Python 3.12: `python -m unittest serve.test_slot_alloc` 25 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. - One RTX 5090 (Windows 11), engine built from 0.2.0-beta (e88ee39d), Swift 1.5 IQ3_S, `--batch 3`, no pipelined groups, no conversation cache, a fresh engine per arm, `STRATA_SLOT_EXPIRE_S=600` in 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: | | main | this, `STRATA_SLOT_EXPIRE_S=600` | this, unset | | --- | ---: | ---: | ---: | | slot the side request took | A's (40,250 tokens held) | B's (1,781 held) | A's (40,250 held) | | A's next turn: first token | 12.78 s | 0.34 s | 12.70 s | | B's next turn: first token | 1.20 s | 1.18 s | 1.17 s | - Before the rebase, on 0.1.45 (477ac13c), 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 1` on 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. --- <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#4149
No description provided.