Skip to content

[Feat] model: Add basic Kimi-K3.1 support (NV, AMD) - #48415

Merged
ispobock merged 3 commits into
mainfrom
kimi-k3.1-support
Nov 4, 2026
Merged

ispobock merged 3 commits into
mainfrom
kimi-k3.1-support

Conversation

@sglang-bot

@sglang-bot sglang-bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Adds Kimi-K3.1 (KimiK31ForConditionalGeneration): Kimi-K3 with DeepSeek-style sparse attention (DSA) in its full-attention layers, an fp8_ds_mla KV cache whose tile scales are rounded up to powers of two as the reference writer does, and flashmla_kv on CUDA or the Triton sparse MLA backend on ROCm.

No behavior change for other models; the exact packed top-k kernel now also builds on CUDA, where only this model selects it.

Performance and further features (DCP, PD, speculative decoding) follow in #48414.

Model: https://huggingface.co/moonshotai/Kimi-K3.1-Pro


CI States

Latest PR Test (Base): 🚫 Run #41863403425
Latest PR Test (Extra): 🚫 Run #41863403243
Latest PR Test (AMD ROCm 10): 🚫 Run #41863403198

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@hnyls2002 hnyls2002 added run-ci CI: run the baseline test suite on this PR highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed run-ci-nv-extra CI: NVIDIA/shared Extra suite (requires run-ci) labels Nov 4, 2026
@ispobock
ispobock merged commit 61a3c7f into main Nov 4, 2026
176 of 194 checks passed
@ispobock
ispobock deleted the kimi-k3.1-support branch November 4, 2026 18:27
mattteochen added a commit to mattteochen/sglang that referenced this pull request Nov 4, 2026
Take sgl-project#48415's packed top-k wiring (kernel built on every backend, wrapper
exported unconditionally, packed_extend_topk flag) in place of this branch's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
mattteochen added a commit to mattteochen/sglang that referenced this pull request Nov 4, 2026
sgl-project#48415 builds the exact packed PAGED extend top-k on CUDA but selects it only
for Kimi-K3.1, so GLM-5.x and DeepSeek-V3.2 prefill on CUDA still run the
legacy fused transform. Nothing in the packed path is model specific (ROCm
already runs it for every DSA model) and the dispatch keeps its own shape
checks and legacy fallback, so enable it for every DSA model except on XPU,
which has no packed op.

Add test_topk_v2_packed_exact (exact top-k contract over every length band,
ties and unaligned starts, chunked rows) and test_topk_v2_packed_dsa_dispatch
(the DSA PAGED extend dispatch reaches the packed kernel and agrees with the
legacy kernel).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
akhilg-nv added a commit to akhilg-nv/sglang that referenced this pull request Nov 6, 2026
Resolve the conflicts with main's Kimi-K3.1 support (sgl-project#48415), which already
builds the topk_v2 packed kernel on every platform and dispatches the PAGED
extend to it only when packed_extend_topk is set (ROCm, Kimi-K3.1):

- topk_v2.cuh and dsv4/topk.py take main's version; this branch's guard
  removal there is now main's.
- The PAGED extend dispatch takes the packed kernel for every DSA model; a
  prefill-CP shard takes it only with packed_extend_topk, so ROCm and
  Kimi-K3.1 keep main's routing and other models keep CP on legacy.
- test_prefill_cp_shard_topk_route (renamed) sets dsa_packed_extend_topk
  per case instead of patching _is_hip, and covers all four
  (flag, sharded) pairs.
- ForwardMode is imported from forward_mode (main's indirect-import check).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed jit-kernel memory-pool quant LLM Quantization run-ci CI: run the baseline test suite on this PR run-ci-nv-extra CI: NVIDIA/shared Extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants