[GH-ISSUE #465] Feature request: serve concurrent requests (cross-request batching) #216

Closed
opened 2026-11-04 01:40:59 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Viachtik on GitHub (Oct 2, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/465

With several clients on one GPU (orchestrator agent + sub-agents, a chat bot) everything queues: /v1/status reports concurrency.serving: 1, and DETAILS.md lists "one request at a time" as a v1 limit.

Request: batch decode steps across a few concurrent requests (even 2-4 slots), like llama.cpp --parallel.

Setup: RTX 3090 24 GB + 62 GB RAM, IQ3_S, 262K ctx, OpenCode multi-agent pipeline. Thanks!

Originally created by @Viachtik on GitHub (Oct 2, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/465 With several clients on one GPU (orchestrator agent + sub-agents, a chat bot) everything queues: `/v1/status` reports `concurrency.serving: 1`, and DETAILS.md lists "one request at a time" as a v1 limit. Request: batch decode steps across a few concurrent requests (even 2-4 slots), like llama.cpp `--parallel`. Setup: RTX 3090 24 GB + 62 GB RAM, IQ3_S, 262K ctx, OpenCode multi-agent pipeline. Thanks!
Author
Owner

@Niko1221 commented on GitHub (Oct 2, 2026):

Thanks for the request. Strata runs one sequence at a time by design: decode is limited by reading experts from RAM and over PCIe, and the engine keeps one sequence's state (KV, the draft layer, the conversation checkpoints) per process. Batching requests across users would mean rewriting the decode loop for several slots, with a shared expert cache and per-slot drafting. That is a large change, with limited gain while expert reads are the bottleneck. So it's not planned for now; requests queue and run in order. Closing; the request stays here for later.

<!-- gh-comment-id:5947590496 --> @Niko1221 commented on GitHub (Oct 2, 2026): Thanks for the request. Strata runs one sequence at a time by design: decode is limited by reading experts from RAM and over PCIe, and the engine keeps one sequence's state (KV, the draft layer, the conversation checkpoints) per process. Batching requests across users would mean rewriting the decode loop for several slots, with a shared expert cache and per-slot drafting. That is a large change, with limited gain while expert reads are the bottleneck. So it's not planned for now; requests queue and run in order. Closing; the request stays here for later.
Author
Owner

@Niko1221 commented on GitHub (Oct 4, 2026):

Planned after all: 0.1.39 has it as an opt-in. "parallel": N in strata-<model>.json (or setup --parallel N) decodes up to N requests together in the engine's batch slots; more wait for a free slot. A request alone still runs the usual path with MTP drafts (and goes back to it when the others have finished); with two or more, each slot decodes one token per window and the weights are read once for all of them. A new prompt is read chunk by chunk with the other slots decoding in between, a long prompt gives way to a much shorter waiting one, and each slot keeps its conversation for the next turn. Each slot's session (0.56 GiB at 32K) comes out of the expert cache, so setup recommends parallel only where the experts mostly fit in VRAM (about 24 GB and up on one card for Q2_0, or a multi-GPU split); elsewhere it stays at one at a time, and --parallel N is still honoured as asked.

Measured on an RTX 5070 (12 GB) with Q2_0, 4 requests at once: the last one starts after 1.8 s instead of 11.2 s, but together they decode at 63 tok/s against 71 one after the other, and a request alone is 11-24% slower (the slots' VRAM comes out of the expert cache). On a card where most experts run on the CPU the slots buy waiting time, not speed. A card that holds more of the experts in VRAM may do better; we have not measured one yet. Details and limits: docs/BATCHING.md. The engine part is PR #559 by blange48.

<!-- gh-comment-id:5979978318 --> @Niko1221 commented on GitHub (Oct 4, 2026): Planned after all: 0.1.39 has it as an opt-in. `"parallel": N` in `strata-<model>.json` (or setup `--parallel N`) decodes up to N requests together in the engine's batch slots; more wait for a free slot. A request alone still runs the usual path with MTP drafts (and goes back to it when the others have finished); with two or more, each slot decodes one token per window and the weights are read once for all of them. A new prompt is read chunk by chunk with the other slots decoding in between, a long prompt gives way to a much shorter waiting one, and each slot keeps its conversation for the next turn. Each slot's session (0.56 GiB at 32K) comes out of the expert cache, so setup recommends `parallel` only where the experts mostly fit in VRAM (about 24 GB and up on one card for Q2_0, or a multi-GPU split); elsewhere it stays at one at a time, and `--parallel N` is still honoured as asked. Measured on an RTX 5070 (12 GB) with Q2_0, 4 requests at once: the last one starts after 1.8 s instead of 11.2 s, but together they decode at 63 tok/s against 71 one after the other, and a request alone is 11-24% slower (the slots' VRAM comes out of the expert cache). On a card where most experts run on the CPU the slots buy waiting time, not speed. A card that holds more of the experts in VRAM may do better; we have not measured one yet. Details and limits: docs/BATCHING.md. The engine part is PR #559 by blange48.
Author
Owner

@gravitomagnetic commented on GitHub (Oct 5, 2026):

Measured parallel: 2 on a 32 GB single-card box (RTX 5090, IQ3_S MoE, 1M ctx) — full A/B posted on #466; two findings specific to this feature:

1. The VRAM budget is tight, and the failure mode is late + fatal. With the stock --expert-cache 7500 --vram-reserve-mib 700, --batch 2 loads and prints:

strata serve: 217 MiB of VRAM free with everything loaded - LOW: requests may stall;
add --vram-reserve-mib 995 to the config's args (or lower --max-context)

…but it's worse than stalling: the first request that actually needs the second slot kills the engine (HTTP 400, then /v1/models returns empty — wrapper alive, engine gone). Suggestion: when the free-VRAM deficit is large enough that an extra slot can never run, refuse at load (or auto-trim the expert cache) rather than dying at first concurrency — a startup failure is debuggable, a mid-request engine death looks like a crash. Workaround that runs cleanly: --expert-cache 6500 --vram-reserve-mib 995 (513 MiB free at startup, no warning; decode hit rate 88–97% vs 92–96% at 7500). --batch 4 OOMs at load on this card at 1M ctx.

2. Batched requests lose per-request timings. When A shares the batch window with B, the client response reports prompt_n: 0, prompt_per_second: null for A — the batched prefill path logs segments in the serve log (32768 reused + 92452 read, plus (cancelled)-tagged partial reads that are bookkeeping, not errors) but the response timings don't aggregate them. Anyone benchmarking --batch will hit this trap; worth fixing or a line in docs/BATCHING.md.

<!-- gh-comment-id:6004872926 --> @gravitomagnetic commented on GitHub (Oct 5, 2026): Measured `parallel: 2` on a 32 GB single-card box (RTX 5090, IQ3_S MoE, 1M ctx) — full A/B posted on #466; two findings specific to this feature: **1. The VRAM budget is tight, and the failure mode is late + fatal.** With the stock `--expert-cache 7500 --vram-reserve-mib 700`, `--batch 2` loads and prints: ``` strata serve: 217 MiB of VRAM free with everything loaded - LOW: requests may stall; add --vram-reserve-mib 995 to the config's args (or lower --max-context) ``` …but it's worse than stalling: the first request that actually needs the second slot kills the engine (HTTP 400, then `/v1/models` returns empty — wrapper alive, engine gone). Suggestion: when the free-VRAM deficit is large enough that an extra slot can never run, refuse at load (or auto-trim the expert cache) rather than dying at first concurrency — a startup failure is debuggable, a mid-request engine death looks like a crash. Workaround that runs cleanly: `--expert-cache 6500 --vram-reserve-mib 995` (513 MiB free at startup, no warning; decode hit rate 88–97% vs 92–96% at 7500). `--batch 4` OOMs at load on this card at 1M ctx. **2. Batched requests lose per-request timings.** When A shares the batch window with B, the client response reports `prompt_n: 0, prompt_per_second: null` for A — the batched prefill path logs segments in the serve log (`32768 reused + 92452 read`, plus `(cancelled)`-tagged partial reads that are bookkeeping, not errors) but the response timings don't aggregate them. Anyone benchmarking `--batch` will hit this trap; worth fixing or a line in docs/BATCHING.md.
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#216
No description provided.