Repository navigation
fix(vllm): handle physical capacity changes at the block-pool recheck - #511
Conversation
rishabhsinha17
left a comment
There was a problem hiding this comment.
LGTM. The release needs this. #197 is this exact raise, its message comes from the early recheck in get_new_blocks, not from the allocator path #453 already reports as a scheduling miss. #453 kept the recheck fail-loud because asking for more than the reported free count meant a caller bug, but under kvcached that count reads shared physical capacity, so a colocated engine can invalidate the preflight with no bug anywhere. Raising KVCachePoolExhausted, the typed signal the allocate_slots wrapper already turns into the scheduler's cannot-allocate-now answer, is the smallest fix.
Verified at aeade71. Pool injection and wrapper share one version range, the NativeBlockPoolMixin that 0.29 mixes in does not override get_new_blocks, and KVCachePoolExhausted subclasses ValueError so existing catchers keep working. Your new recheck cases fail against main, all six, and the file is 12/12 at this head. Full cpu manifest here is 476 passed with a failure set byte-identical to main on my mac. T4 serving evidence stays yours.
Problem
The elastic pool can still terminate EngineCore when physical capacity drops between the scheduler's preflight and
get_new_blocks(). This is a normal possibility on a shared GPU: the earlier free-block count is a snapshot, not a reservation.Related: #197 and #509. #206 adds a reproduction workload for #197; it does not change this allocation path. This PR addresses the escaping exception, not every multi-instance failure mentioned in that issue.
Root cause
At the current base, the pool performs another capacity check:
The existing
allocate_slots()wrapper intentionally catches onlyKVCachePoolExhaustedand returnsNoneto the scheduler. Therefore, exhaustion detected by this early recheck escapes, while exhaustion detected later in the allocator already follows the recoverable path.Before
sequenceDiagram participant S as Scheduler participant P as Elastic block pool participant G as Shared GPU capacity S->>P: Read free blocks for preflight P-->>S: Enough blocks at this instant G->>G: Another allocation consumes capacity S->>P: allocate_slots / get_new_blocks P->>G: Recheck available capacity G-->>P: Not enough now P-->>S: Plain ValueError escapes typed handler Note over S: EngineCore exitsChange
Raise
KVCachePoolExhaustedat that recheck, matching the allocator's existing exhaustion signal. Keep the wrapper narrow: unrelatedValueErrorand CUDA/runtime failures still propagate. There is no broad exception catch, new lock, capacity-policy change, or retry loop.After
sequenceDiagram participant S as Scheduler participant W as allocate_slots wrapper participant P as Elastic block pool S->>W: Allocate after preflight W->>P: get_new_blocks P-->>W: KVCachePoolExhausted on reduced capacity W-->>S: None (cannot allocate now) Note over P: Early rejection leaves pool bookkeeping unchanged S->>W: Retry through normal scheduler behavior W->>P: get_new_blocks P-->>S: Blocks when capacity is availableTests and scope
The regression tests exercise the actual injected pool with prefix caching both enabled and disabled. They check rejection without allocator calls or changes to reference counts/cache bookkeeping, a successful retry, translation through the enabled wrapper, and propagation of unrelated errors. The focused suite has 12 tests.
Validated revision:
aeade716fee796997e9d967304b267ee43223d32, independently based onmain, without the pending adaptation stack.The capacity injection changes the reported free count at the recheck; it is not a natural multi-instance pressure benchmark. The serving model has random tiny attention-only weights, so token equality is a regression check, not a model-quality claim. No multi-GPU/MPS safety or performance improvement is claimed.