mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4601] [CLOSED] [Engine] serve: replicas: a request waits for a free card instead of being given one on arrival #5106
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#5106
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/4601
Author: @liangzelong
Created: 10/29/2026
Status: ❌ Closed
Base:
main← Head:main📄 Description
Problem and result
With
"replicas", a request is given a card as soon as it arrives, even when that card is busy. It then waits on thatcard's lock while the other card may sit idle. Clients that send the same long system prompt — every agent session
does — all want the card that holds that prefix, so with two of them at once the requests pile onto one card and the
other one stays at 0%. This is what a multi-agent task does (the captain and every member share the system prompt and
the tools) and what two sessions of the same framework do (their prompts differ only in the message).
With
"replica_pull": truea request waits for a free card and takes the first one that frees up, so an idle card isalways used; among the waiting requests the one that would read the fewest prompt tokens again goes first.
Measured on 2x RTX 4090 (Linux, WSL2, 128 threads), Qwen3.8-Flash-Next UD-Q4_K_XL, 262,144-token context,
"replicas": 2,"parallel": 1, two sessions of one agent framework sending the same ~19,500-token system prompt anddiffering only in their last message:
"replica_pull": trueRelated discussion
none
Approach
serve/replicas.py:ReplicaEnginegets an opt-in pull scheduler. The requests wait in one pending pool; when areplica has a free slot, the pool hands it the request that would read the fewest tokens again on that replica (the
prefix bookkeeping is read at that moment, not at arrival). A request that has waited longer than
replica_starve_sgoes first whatever it costs. A request that was given a card then runs as before.
This is the order the mode is for: a layer split keeps one conversation on the same cards to read as little of it
again as possible, while the replicas mode runs a complete model on every card and serves its own conversations, so
every card goes first and the reuse stays inside a card. A request that is given a card on arrival and waits there
behind another one leaves a card idle, which is the split behaviour with more overhead.
serve/server.py:"replica_pull"and"replica_starve_s"in the run config, a start-up line that says which orderis in use, and
live.replica_pendingin/metrics(the pool size).serve/test_replicas.py: six tests for the new order; the old order is left as it was.docs/DETAILS.md,docs/MULTI_GPU.md: the two config keys, and the feature itself, which had no user documentation.Without
"replica_pull"nothing changes: a request is still given a card on arrival and waits there.Validation
Passed:
python -m unittest serve.test_replicas— 25 tests OK (19 before, 6 new), Python 3.10.9, Linux, engine 0.1.53,source tree at
46c152a1(v0.2.7.1) with this change.python -m unittest serve.test_parallel serve.test_slots serve.test_queue_keepalive serve.test_admit_order serve.test_request_accounting serve.test_request_hardening— 82 tests OK, same tree.context,
"replicas": 2,"parallel": 1,"max_queue": 2. Two requests with a 26,987-token shared prefix whose lastmessage differs by one word, sent at the same time:
replica_pull: both requests to one card; the second first token after 5.6 s (the first request's wholeturn); GPU 96% / 0%.
replica_pull: the two requests to the two cards; the second first token after 1.5 s; GPU 97% / 99%./metricsreportslive.replica_pending.Failed: none observed.
Not run:
read was not measured.
Limits
"replica_pull": true; the default path is unchanged.that holds it, so a session whose prompt is cached on no card pays a full read on the card it is given.
max_queue), not by the pull scheduler.queue_timeoutis not checked on this path; it is only checked on the single-slot queue.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.