Repository navigation
Conversation
Apply in-flight prefill block reservations to local admissions and running allocations, and include them in the full-sequence fit gate. This prevents ordinary work from consuming capacity promised to a parked async KV load. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Jingyi Yang <girasoleyang@gmail.com>
Signed-off-by: Yifan Qiao <yifanqiao@inferact.ai>
e545ec7 to
6480df6
Compare
ivanium
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the fix!
Signed-off-by: Yifan Qiao <yifanqiao@inferact.ai>
|
Actually I may need to test this further so hold up temporarily |
ivanium
left a comment
There was a problem hiding this comment.
Actually there might be some bugs. I'll investigate further
| if required_blocks > ( | ||
| self.block_pool.get_num_free_blocks() - reserved_blocks | ||
| ): |
There was a problem hiding this comment.
This applies to all requests and seems to be buggy and cause stuck in some of my tests.
|
Thanks @GirasoleY! Actually the current behavior is intentional - it optimistically allows use of the "reserved" blocks, with the assumption that more will usually be freed by the time they are actually needed (or else we resort to preemption). We need to enforce the reserved blocks for other async loads to avoid deadlocks. See this comment in the original PR:
I'm not saying we definitely shouldn't make this change but It would be good to understand the motivation. |
|
This pull request has merge conflicts that must be resolved before it can be |
Summary
Async KV loads reserve the blocks they still need to finish, but the scheduler only honored that reservation when admitting another async load. Ordinary local admissions and subsequent running chunks could consume the reserved headroom. The full-sequence admission check also ignored
reserved_blocks.This change:
The reservation is only nonzero while async loads or chunked prefills are in flight, so normal scheduling is unchanged.
Why this is not a duplicate
I searched open PRs for async KV reservation, scheduler deadlock, and
reserved_blocks.max_num_seqsaccounting for async loads; it does not protect block reservations.Validation
Focused lifecycle test file:
Repository hooks on the modified files:
All hooks passed.
I also ran a local two-GPU DSv4-Pro-shaped stress test with DP=2, EP=2, DeepGEMM MegaMoE, dummy weights, a deliberately small KV pool, one delayed async external-KV load, and heavily imbalanced requests. All 8 requests completed without a collective stall. On the original target branch, the same-config A/B reduced peak logical KV usage from 94.2% to 87.2% and completion time from 28.91s to 20.82s. Current upstream
mainwith this patch completed in 20.78s with 87.8% peak KV usage.This test validates the reservation-pressure behavior; it does not claim that every production collective hang has the same root cause.
AI assistance
OpenAI Codex was used to investigate the scheduler path, draft the patch and regression test, and run the validation. I reviewed every changed line and am responsible for the change.