fix(sglang): use storage dtype for FP8 KV pools - #388
Open
shipiyouniao wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a dtype/layout mismatch in the SGLang integration by consistently using SGLang’s physical KV-cache store_dtype (instead of the logical dtype) when kvcached allocates and accounts for MHA/MLA KV backing buffers—important for FP8 storage where physical element width differs from the logical dtype.
Changes:
- Update SGLang MHA/MLA pool patches to size allocator cells and physical byte accounting using
store_dtype.itemsize. - Allocate MHA/MLA backing KV buffers using
store_dtype. - Add regression tests covering the case where logical and storage dtypes intentionally differ.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
kvcached/integration/sglang/patches.py |
Switches MHA/MLA physical allocation + sizing/accounting to store_dtype semantics. |
tests/test_sglang_storage_dtype.py |
Adds targeted regression tests for logical-vs-storage dtype divergence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
shipiyouniao
force-pushed
the
fix/sglang-fp8-storage-dtype
branch
2 times, most recently
from
July 16, 2026 11:05
5d5c8e1 to
358288b
Compare
shipiyouniao
force-pushed
the
fix/sglang-fp8-storage-dtype
branch
from
July 16, 2026 11:31
358288b to
6936972
Compare
shipiyouniao
force-pushed
the
fix/sglang-fp8-storage-dtype
branch
from
July 22, 2026 07:07
6936972 to
0f8d3d5
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
Closes #387.
Use SGLang's physical KV-cache
store_dtypeconsistently when kvcached constructs MHA and MLA backing pools.Root cause
SGLang separates the model-facing logical
dtypefrom the physicalstore_dtype. FP8 KV storage can therefore use one-byte physical elements while the logical dtype remains wider. The kvcached patches used the logical dtype for tensor allocation, page cell geometry, and physical byte accounting, allowing the allocator contract and the actual storage layout to disagree.Changes
self.store_dtypestore_dtype.itemsizestore_dtype.itemsizeThe logical
self.dtyperemains unchanged for model-facing behavior.Validation
python -m pytest tests/test_sglang_storage_dtype.py -q-> 2 passedpre-commit run --all-filesunder Python 3.11 -> all hooks passedruncwith GPU devices explicitly hiddenThis is independent from vLLM hybrid mapping and scheduler policy.