mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4196] [Engine] keep batch waits alive and cancel before admission #4944
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#4944
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/4196
Author: @wujian47
Created: 10/26/2026
Status: 🔄 Open
Base:
main← Head:codex/batch-wait-cancellation📝 Commits (1)
0a5cb48[Engine] keep batch waits alive and cancel before admission📊 Changes
2 files changed (+226 additions, -2 deletions)
View changed files
📝
serve/server.py(+23 -2)➕
serve/test_batch_waits.py(+203 -0)📄 Description
Problem and result
When every batch slot is occupied, the admission loop can keep reacquiring an available control lock without yielding an HTTP keep-alive. A queued streaming client then stays silent until a slot opens. A disconnected client can also reach GEN/BGEN when control acquisition or slot selection succeeds immediately, and a quiet decoding slot can take ten seconds to receive BSTOP.
Keep full-slot waiters alive every ten seconds, check cancellation at admission boundaries, and poll quiet slot output at 0.5-second intervals. Cancellation still retains the slot until BDONE; the existing ten-second stream heartbeat is preserved.
Related discussion
Searched open and closed PRs for batch heartbeats, full slots and cancellation. #1673/#1619 concern the single-turn queue, and #1182 concerns quiet prompt/control reads; these fixes remain intact. This addresses the separate full-slot wait and slot-output paths. No new setting, default change or native-engine change is proposed.
Approach
Keep a heartbeat clock across full-slot waits instead of relying on a newly entered control-lock wait. Recheck cancellation before sending a command. Separate the short cancellation poll from the HTTP heartbeat in the slot reader, preserving existing STOP/BSTOP, DONE/BDONE and cleanup ownership.
Validation
Windows 11 x64, Python 3.12.0rc3. Base
4b9e05a2a806a3fe24f7b2560d98626c37dade35; tested candidate0a5cb48c98eec9054018eac086491bf1b917dd14(the committed tree is the tree tested).Passed:
The six new tests exercise the real Python generators with in-memory pipes and a simulated clock. They cover silent full-slot waits, pre-cancelled/immediately admitted requests, cancellation during lock/slot acquisition, prompt BSTOP delivery, BDONE ownership and heartbeat cadence. Existing scripted-process and HTTP regressions also run in the command above.
Failed:
Before applying the fix,
python -m unittest serve.test_batch_waits -von the base above reproduced eight failing assertions across five test methods: no full-slot heartbeats, cancelled GEN/BGEN commands, and ten-second quiet-slot cancellation. After the fix all six methods passed. No remaining failure was observed in the selected candidate run.Not run:
GPU/model inference on this current-main candidate, other operating systems and full repository discovery. These Python-only changes do not modify a native backend; CUDA/HIP/SYCL/Metal builds were not run for this PR.
Limits
This improves server-side keep-alives and cancellation delivery; it does not bound how quickly native GPU work responds to BSTOP, add strict FIFO admission or claim an inference-throughput gain. Separate older-version hardware backports are not presented as tests of this PR head.
Prepared and reviewed with OpenAI coding assistants; the commands and reported outcomes were checked against actual output.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.