feat(sglang): account DeepSeek-V4 runtime reservations#376
Open
shipiyouniao wants to merge 2 commits into
Open
feat(sglang): account DeepSeek-V4 runtime reservations#376shipiyouniao wants to merge 2 commits into
shipiyouniao wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the first SGLang DeepSeek-V4 integration step by accounting for runtime-owned DeepSeek-V4 KV/cache side pools as static reservations (without taking ownership), so kvcached’s device-memory budgeting doesn’t overbook colocated allocations. Also updates the SGLang elastic paged allocator patch to accept a runtime-provided num_new_pages, and adds targeted tests for both behaviors.
Changes:
- Introduce DeepSeek-V4 runtime-owned pool reservation collection/registration in the SGLang patch layer, and subtract those reservations from kvcached’s allocatable GPU budget.
- Extend the elastic paged allocator patch API to accept a precomputed
num_new_pages(avoiding callingget_num_new_pageswhen provided). - Add unit tests covering the allocator signature compatibility and DeepSeek-V4 reservation accounting behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_sglang_elastic_allocator_patch.py | Adds a regression test ensuring alloc_extend(..., num_new_pages=...) bypasses get_num_new_pages. |
| tests/test_sglang_dsv4_runtime_reservation_patch.py | Adds tests for DeepSeek-V4 per-pool reservation breakdown registration and budget subtraction in alloc_kv_cache. |
| kvcached/integration/sglang/patches.py | Implements DeepSeek-V4 runtime reservation patch and updates paged allocator patch to accept optional num_new_pages. |
| kvcached/integration/sglang/interfaces.py | Adds APIs for tracking runtime-owned reservations and subtracts them from the GPU budget during KV allocation. |
| kvcached/integration/sglang/autopatch.py | Registers the new DeepSeek-V4 runtime reservation patch in the SGLang autopatch sequence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
84e5957 to
0d3fdf7
Compare
c4728bf to
e2a8737
Compare
188f9c6 to
861eeb8
Compare
861eeb8 to
c99f3e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a partial first step for DeepSeek-V4 support. The broader DeepSeek-V4 tracking issue should remain open for the remaining pooling work.
This PR adds a partial SGLang DeepSeek-V4 integration step: kvcached now accounts for DeepSeek-V4 runtime-owned KV/cache pools as static reservations, without taking ownership of those pools.
It also includes a small SGLang allocator compatibility fix so the elastic paged allocator accepts a precomputed
num_new_pagesargument when the runtime provides it.What this PR does
DeepSeekV4TokenToKVPool.num_new_pagesin the SGLang paged allocator path.allocator.pagedmodule.What this PR does not do
Related context
This PR is intentionally narrow and is no longer stacked on the other pending fixes. During multi-process / TP validation we also used or checked several related fixes, especially startup ordering and worker error propagation work from #336, #340, #341, #365, and #373. Those are separate PRs and are not included here.
Manual validation setup
Validated with DeepSeek-V4-Flash on two SGLang builds:
1c2857b0646f12a58a04072f0f3d6bd649f064f2, first released inv0.5.13)v0.5.13.post1(85fd90072d1a9f2432842b03588f63b745e524e4), which exercises the newer splitallocator.pagedpathThe runtime was configured to keep DeepSeek-V4 KV pools runtime-owned and disable the experimental kvcached bridge:
Server launch shape:
Router launch shape used for multi-worker validation:
Local validation