Repository navigation
feat(lanes): the lane host fills foreground prompts first, then the shortest waiting - #651
Conversation
…hortest waiting Prompts waiting for their pass were filled oldest first, so a short request queued behind a long prompt waited for all of its chunks, and a foreground request that arrived while a background prompt filled waited for it to end. The next chunk now goes to a foreground prompt before a background one, then to the one with the fewest tokens left to run (the oldest of equals). The pick lives in lane_host_fill.zig with unfill, so lane_host.zig stays under 600 lines; lane_host_fill_test.zig admits a long and a short prompt together and expects the short one first, and sends a foreground request during a background prompt's first chunk and expects it prefilled first.
ed18933 to
3533f64
Compare
|
Thank you, @BlivionIaG. This landed in 1.0.8 as your own commit ( What we checked:
Three small notes for a follow-up, none of them blocking:
The fake target's stepped prefill made both orders easy to pin down without a GPU. |
lane_host.zig was at 600 lines with ashhart#651 still to add. The lone driver (loneFits and runLone: an idle backend's own loop runs a lone stream and hands it back to the lane core when a foreground request or a cancel waits) moves unchanged as lone.fits and lone.run, and the host functions it calls become public. lane_host.zig is 550 lines; lean_check reports the base's 543 problems.
…draws module) into the 1.0.8 candidate
lane_host.zig was at 600 lines with ashhart#651 still to add. The lone driver (loneFits and runLone: an idle backend's own loop runs a lone stream and hands it back to the lane core when a foreground request or a cancel waits) moves unchanged as lone.fits and lone.run, and the host functions it calls become public. lane_host.zig is 550 lines; lean_check reports the base's 543 problems.
ashhart#651 landed above as 43be2838b (the author's commit, rebased onto this candidate). This keeps the PR's own head commit in the history, with no change to the tree.
…draws module) into the 1.0.8 candidate
What this changes
lane_host.zig'sfillOne(#623) filled the oldest waiting prompt first. That caused two waits:The next chunk now goes to a foreground prompt before a background one, then to the prompt with the fewest tokens left to run (
prompt_len - cached), the oldest of equals.lane_host.zigsat at 600 lines, so the pick andunfillmove tolane_host_fill.zig, the waylane_host_learn.zigandlane_host_status.zigdid.lane_host.zigends at 595.No backend on
maingivesprefill_stepyet (only the test fake does), so no engine that runs today changes. The Qwen3.5 HIP engine (#631) is the first that fills in chunks. Background warm passes (#924104e2'swarmPass) do not go through the filling list and are unchanged.Receipt
Environment: base
mainat d512657, head 3533f64. Zig 0.17.0, on macOS (Apple silicon) and Linux 7.1.7.Exactness: the lane host's tests are unchanged and pass, with every request still getting the fake target's exact tokens.
lane_host_fill_test.zigadds two tests:Speed, on our fork with the HIP engine (Qwen3.5-9B MLX 4-bit on a W7800, gfx1100, measured with
serve_bench.pythere), this change alone with prompt chunks left at 1024 rows, at c=8 with 256- and 8192-token prompts alternating 0.4 s apart:The cost is that the long prompts finish a little later.
Tests run:
zig build test test-golden -Dcpu=apple_m1: 139/139 steps, 377/378 tests (1 skipped); golden 309/319 equal, 0 unexpected.zig build test: 39/39 steps, 449/449 tests.zig fmt --checkis clean on the changed files.lean_check.py: 534 problems, the same asmain.Not run, and why: device runs on
main(no backend fills in chunks there).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Only the order in which prompts are filled changes; each stream's tokens are its own.)mainfills in chunks.)