mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#3899
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/2170
Author: @SuperDistance
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:fix/byield-between-progress-lines📝 Commits (1)
ba9c4e6serve: a long read gives way to a short request at the next chunk, not a chunk later or never (#656)📊 Changes
2 files changed (+70 additions, -17 deletions)
View changed files
📝
serve/server.py(+28 -17)📝
serve/test_parallel.py(+42 -0)📄 Description
Title
Issue: Related: #656 (a long prompt read gives way to a much shorter request; closed when the idea shipped as
BYIELDin 0.1.39, the code this fixes) and #2050, where @blange48 found that with
STRATA_PIPED_READ_PIECE=8192a 42.7Kread gave way only at 16,384 tokens. That was this race in the server, and it is on main too: on one GPU, a short
request misses the boundary it should get in most cases. Overlaps #1288 (which waiting requests count as shorter) and
#2109 (request priority): they change what the two give-way checks test, this changes when they run. Both already
need a rebase on main; after this one, their new condition goes into
give_way()/ask(). Searched 2026-10-12 forBYIELD, "gives way",_shorter_waitingand "heartbeat PP".Summary
In short: the server asks a long read to give way only when the engine prints a progress line (
PP). On a--batchserver with one GPU, every chunk of a read is a boundary whose onlyPPline comes at its end. TheBYIELDanswers that line, and it reaches the engine after the engine has looked. So a short request waits one chunk more, or
for the whole read when that was the last boundary the read could give way at. The server now also asks on the
half-second poll it already runs while the engine is quiet. On one RTX 5090 this cut late give-ways from 28 of 40 runs
to 4. Where the race hit, the short request's TTFT fell 64%: from 4.52 s to 1.62 s, the median of 24 paired runs.
Server only, +70/-17 lines with tests.
Why it matters: the engine looks for a
BYIELDat each boundary, right after the chunk'sPPline:On main the
BYIELDwas in time only at 16,384. There the engine saves a periodic checkpoint after printing thePPline (--prompt-cache-every, default 16,384), which keeps it busy until theBYIELDis in. The same race hits#2050's pipelined pieces of one chunk.
How:
_control()already waits for the engine's lines with a 0.5 s timeout. On a timeout it now callson_quiet(), and the solo read and the admission read pass the same check they run at aPPline. Nothing elsechanges: the rule for who counts as shorter,
YIELDS_MAX, oneBYIELDper read, and what happens when the read endsbefore the engine sees it. The engine drops it (
generate.cppmain loop), and a solo read's reserved slot is freed atits
DONE, as before.Measured on one RTX 5090 (Swift 1.5 IQ3_S,
--batch 4, resident experts, 8K chunks of about 1.9 s; the enginebuilt from main
a0116b27), main's server and this one. Each server got two engine starts, in the order main, this,this, main. A one-line request was sent d s into a cold ~33K read, at 12 delays, twice each. The runs were done with
nothing else decoding (the read is a solo
GEN,give_way()) and with one stream decoding beside it (an admission,ask()). Each run's times came from a log of the server's control events, described below. These are the numbers ofa second window (2026-10-13); the first (2026-10-12) gave the same counts, and this table's TTFTs within 0.05 s.
BYIELDsent after the request started waiting, median (max)The 4 late runs with this change were requests that started waiting 0.01-0.12 s before that boundary's
PPline,too close for any poll. Every request that came 0.35 s or more before a boundary got it.
Per delay: where the read gave way and the short request's TTFT (mean of the 2 runs)
Nothing else decoding:
One stream decoding beside the read:
The two runs at each delay were within 0.16 s of each other.
On 2x RTX 5090 with #2050 (
--batch 6 --batch-groups 2,STRATA_PIPED_READ_PIECE=8192, the engine built frommain with #2050's two commits; main's server and this one, two engine starts each, measured the same way): a one-line
request 0.5-3 s into a cold ~45K read, whose one-chunk pieces take about 1.5 s. Main gave way a piece late in 10 of 12
runs, this change in 4. Those 4 started waiting 0.10-0.12 s before the piece's
PPline, as above. Where the race hit(7 paired runs), the short request's TTFT went from 2.59-5.08 s to 1.08-1.84 s (median 3.19 -> 1.56 s).
Try it without a GPU (the fake engine in
serve/test_parallel.py, one boundary in the read):On main, the solo and admission tests fail in every run, 10 of 10 each, with
[] != [2560]: the read finishedwithout giving way. With this change all three passed 25 of 25 runs, about 3.4 s per test.
Where main is better: in one pair of the 2x RTX 5090 runs (1.5 s, the second engine start), main gave way at
8,192 and this change at 16,384. That request came 0.11-0.14 s before the
PPline, inside one poll, so both serverssent the
BYIELDwith that line, and main's won the race in that start. At aPPline this change runs the samecheck as main, so its
BYIELDis never later than main's. Otherwise, where both gave way at the same boundary, or noboundary was left, both requests' TTFTs were the same. Where main never gave way, the long prompt's own first token
came 0.72 s later with nothing decoding (0.40 s sooner with a stream decoding). That is #656's trade, which main makes
too when the ask is in time: the short request goes first. The poll's cost is one look at the waiting list (a lock and
a scan) per half second of engine silence during a read.
What changed
serve/server.py:_control(..., on_quiet=None)callson_quiet()on its quiet poll. The solo and admissionreads' give-way checks move, unchanged, into two small functions (
give_way(),ask()). They run at aPPline, asbefore, and on that poll.
serve/test_parallel.py: the fake engine takes--pp-every K(aPPline and a boundary every K chunks). Threetests: a solo read and an admission give way at their first boundary, and a request about as long gets no
BYIELDon the poll either.
Extra Notes
Tests: every
serve/test_*.pymodule passes on main (a0116b27, 725 tests) and with this commit (728: thethree new ones).
serve.test_parallelpassed 3 of 3 full runs.How the runs were timed: a measurement-only patch (not in this PR) made both servers log each control
event: its time and token counts, no text. From that log, each run records when the short request started waiting,
when each boundary's
PPline came, when theBYIELDwent out and where the read gave way. The prompts were thisrepository's own files, so every read was cold. I can share the scripts.
Base: rebased onto main
a0116b27. The only change near it on main is #1994'stry/exceptaround theadmission loop, which now wraps the new
forline. The #2050 runs used its two commits rebased ontoa0116b27(the same patches as its head,
63335d4e), with this commit'sserver.py.Not measured: AMD and Intel GPUs. This is server only, with no engine or backend file changes, so there is no
CUDA, HIP or SYCL build to check. The gain grows with the chunk time: a late give-way costs one chunk, or the rest of
the read.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.