Shared-GPU startup memory budgeting with kvcached #454
shipiyouniao
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Status
Settled for now. Reopen this design discussion only if production evidence shows that the current compatibility solution is insufficient.
The current direction is the stable logical KV capacity implemented in #448. A complete redesign of inference-engine memory profiling is not part of that fix.
Context
Inference engines such as vLLM derive KV capacity from whole-device GPU memory snapshots. The calculation assumes that other processes sharing the GPU do not change their memory usage during profiling.
That assumption does not hold for colocated engines using kvcached. Model loading, CUDA contexts, compilation, CUDA Graph capture, workspaces, and physical KV page mappings all consume or release physical GPU memory. A peer process can therefore change whole-device free memory while another engine profiles.
Observed effects include:
In one unfixed vLLM run, free memory changed from
8.57 GiBto12.91 GiBduring profiling and terminated EngineCore. In a T4 SGLang reproduction, two identical instances received1,048,596and832,174logical tokens respectively, a 20.6% difference caused only by startup order.Options considered
1. Serialize startup profiling
A startup lock can stop two initializers from profiling simultaneously, but it does not restore the whole-device snapshot assumption:
The same issue returns when a later engine C starts. Making serialization complete would require a global quiescence barrier over running engines, which would stall traffic and make cold-start latency grow with the number of colocated instances.
This option is not selected.
2. Use a stable logical KV capacity in the kvcached integration
This is the selected compatibility boundary and the implementation in #448:
gpu_memory_utilization;mem_fraction_static;kv_cache_memory_bytespath, which still performs the required compilation profile;After the SGLang fix, both T4 instances received the same
14,073,377,588-byte logical capacity and1,145,294logical tokens, reached health, and completed requests.This option covers both peer allocation and peer release without pretending that whole-device deltas are process-local accounting.
3. Redesign shared-GPU memory budgeting in the inference engine
A complete design could separate logical KV capacity from physical budgets for weights, activations, workspaces, communication buffers, CUDA contexts, CUDA Graphs, and other non-KV allocations.
This would be a larger inference-engine API and accounting change. It is easier to get wrong across versions and execution modes, so it is deliberately deferred. It should only proceed with a clear upstream contract and evidence that option 2 is insufficient.
Known boundary
The selected solution does not make a permanently infeasible configuration runnable. Physical non-KV headroom and at least one KV page must eventually be available.
When physical KV capacity never becomes available, null-block reservation continues waiting instead of failing fast. The retry is backed off and does not busy-spin, but the engine does not become usable. A future change may make this wait lifecycle-aware or connect it to an explicit caller-provided startup deadline without reintroducing timing-dependent failures.
Observability should expose allocator state for diagnosis and verification, but metrics and exported snapshots must not participate in allocation decisions.
Reopen criteria
Reopen this design discussion only when there is reproducible evidence of at least one of the following:
Performance differences or failures caused by a physically infeasible deployment are not, by themselves, evidence that the profiling redesign is required.
References
All reactions