Repository navigation
Support deepseek v4 and kimi k3 on ssd - #35314
Merged
BBuf merged 17 commits intoAug 26, 2026
Merged
Conversation
Add the isolated SSD Expert Pack runtime, opt-in model loading for DeepSeek V4 Flash and Kimi K3, one-click GGUF demos, and registered test coverage. Co-authored-by: 1BIN4 <1741738350@qq.com> Co-authored-by: L-Ark <fliangae@connect.ust.hk> Co-authored-by: Chikati <jxudn@connect.ust.hk> Co-authored-by: mengzili <zilim@ust.hk>
Build the Kimi expert-major pack on first launch, validate and reuse it on subsequent launches, and keep the one-click demo limited to the GGUF path and token count. Co-authored-by: 1BIN4 <1741738350@qq.com> Co-authored-by: L-Ark <fliangae@connect.ust.hk> Co-authored-by: Chikati <jxudn@connect.ust.hk> Co-authored-by: mengzili <zilim@ust.hk>
beyondHJM
requested review from
Alisehen,
AniZpZ,
BBuf,
DarkSharpness,
Edwardf0t1,
FlamingoPg,
Fridge003,
HaiShaw,
HydraQYH,
OrangeRedeng,
Qiaolin-Yu,
Ying1123,
b8zhong,
celve,
ch-wan,
fzyzcjy,
hebiao064,
ispobock,
jybsuper,
lifuhuang,
merrymercy,
mmangkad,
yuan-luo and
yushengsu-thu
as code owners
August 18, 2026 10:52
Contributor
Author
|
/tag-and-rerun-ci |
Contributor
Author
|
/rerun-failed-ci |
Contributor
Author
|
/rerun-failed-ci |
1 similar comment
Contributor
Author
|
/rerun-failed-ci |
Contributor
Author
|
/rerun-failed-ci |
3 tasks
5 tasks done
7 tasks done
arathi-hlab
added a commit
to arathi-hlab/sglang
that referenced
this pull request
Aug 27, 2026
The top-level `from sgl_kernel.quantization import ggml_moe_a8_vec` in `expert_pack.py` (added in sgl-project#35314) breaks module import on any device where `sgl_kernel.quantization` is not built — currently XPU, ROCm and NPU. `gguf.py:44-70` already documents that `sgl_kernel.quantization` is CUDA/MUSA-only. Any code path that imports `ExpertPackMoEMethod` then dies at load time. On XPU CI this surfaces via `deepseek_v2.forward_normal -> maybe_fuse_routed_scale_and_shared_add -> expert_pack.py:10 -> ModuleNotFoundError: No module named 'sgl_kernel.quantization'`, even though the actual Kimi-K3 expert-pack path is never entered. Move the import inside `_kimi_vec` — the only function that uses the kernel. CUDA/MUSA behavior is unchanged (Python caches the module in `sys.modules` after the first call); XPU/ROCm/NPU can now import `expert_pack` again without needing the CUDA-only extension. Failing job: https://github.com/sgl-project/sglang/actions/runs/32946854301/job/98212193462
5 tasks
Collaborator
|
Style comment: A top-level folder @beyondHJM @BBuf can you follow up on this? |
5 tasks done
2 of 5 tasks
Contributor
|
Is there any deployment that implements hybrid inference for DS4.1 across memory, SSD, and GPU — putting Engram in memory, MoE on SSD, and activated experts on GPU? I feel this could be done with just 512GB of memory, a 2TB SSD, and 48GB of VRAM. |
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.
[Feature] Add SSD-backed Expert Pack inference for DeepSeek-V4-Flash and Kimi-K3
Summary
This PR adds an opt-in SSD-backed inference path for DeepSeek-V4-Flash and Kimi-K3. It allows these MoE models to run when their complete weights are larger than GPU VRAM and host RAM combined.
Routed expert weights are stored on SSD and loaded only when selected by the router. The implementation uses:
The runtime does not prune, merge, skip, replace, or re-quantize experts, and does not reduce Expert Top-K. The default
auto,safetensors, andggufloading paths remain unchanged; SSD execution is enabled only through the explicitexpert_packpath.Supported Scope
ExpertPackModelLoaderis selected only with--load-format expert_pack. Official checkpoints loaded through the standardautoorsafetensorspaths never enter this loader.The currently validated DeepSeek input is the single-file MXFP4 GGUF used by
frob/deepseek-v4-flash-0731:latest. Its routed expert matrices useMXFP4; the large non-routed matrices are mostlyQ8_0, router input weights areBF16, and the inventory also containsF32andI32normalization or auxiliary tensors. The inspected GGUF contains 129MXFP4, 512Q8_0, 43BF16, 641F32, and 3I32tensors. It contains no FP8 tensors.The other validated input is the text-only 38-shard
KIMI-K3-MXP4-DERISKED-Q2_K-*.gguf, whose routed experts use Q2_K for gate/up and Q3_K for down. The Kimi launcher extracts the officialtext_configinto a flatKimiLinearConfig; the complete multimodal Kimi-K3 checkpoint is not supported by this loader. Other GGUF quantization variants have not been validated and are not currently claimed as supported.Usage
Install this branch from source before running the examples:
python3 -m pip install -e "python"DeepSeek-V4-Flash
The tested MXFP4 GGUF is available as
frob/deepseek-v4-flash-0731:latest, which was imported fromunsloth/DeepSeek-V4-Flash-0731-GGUF. The benchmark used the immutable Ollama model blob with SHA-256947ac34c08c0e5c5752ac76398f934b3b6b4075cfe915ba43dd5ac754900a4cd.python3 examples/runtime/deepseek_v4/benchmark_deepseek_5090.py \ --gguf /path/to/deepseek-v4-flash-0731-mxfp4.gguf \ --prompt "Explain why the sky appears blue." \ --max-new-tokens 200Kimi-K3
Download all 38 Q2_K GGUF shards from
Blackfrost-AI/KIMI-K3-Q2_K-GGUF-ABLITERATED. Also place the tokenizer/config files frommoonshotai/Kimi-K3in a sibling directory namedkimi-k3-tokenizer.hf download Blackfrost-AI/KIMI-K3-Q2_K-GGUF-ABLITERATED \ --include "KIMI-K3-MXP4-DERISKED-Q2_K-*.gguf" \ --local-dir /path/to/kimi-k3python3 examples/runtime/kimi_k3/benchmark_kimi_k3_5090.py \ --gguf /path/to/kimi-k3/KIMI-K3-MXP4-DERISKED-Q2_K-00001-of-00038.gguf \ --prompt "Explain why the sky appears blue." \ --max-new-tokens 200The first shard is only the entrypoint. The launcher automatically discovers and uses all 38 shards in the same directory. Both launchers derive the remaining paths automatically. If the Expert Pack is missing, it is built on the first launch and reused afterward.
The 38 Kimi-K3 source shards and generated Expert Pack occupy approximately 1.814 TiB in total, so a 4 TB SSD is recommended for practical headroom.
Correctness
fallback_count=0andio_errors=0.Performance
The target platform is one RTX 5090 with 32 GB VRAM, 32 GB host RAM, and NVMe SSD storage. The retained measurements were collected on RTX 5090 hosts; host RAM and SSD capacity differed between the two model runs.
DeepSeek-V4-Flash vs Ollama
Five prompts were measured with 200 generated tokens per prompt.
Kimi-K3 vs llama.cpp
The SGLang run used a 91-token prompt and generated 200 tokens.
The llama.cpp decode baseline came from an earlier 50-token run, so the 2.48x decode figure is indicative rather than a strict equal-length comparison.
CI States
Latest PR Test (Base): ❌ Run #32837312025
Latest PR Test (Extra): ❌ Run #32837311604
Latest PR Test (AMD ROCm 7.2): ❌ Run #32837311774