Skip to content

[Feat] kimi-k31: Support PCP KV sharding with HiCache and DFlash - #48469

Closed
Fridge003 wants to merge 1 commit into
sgl-project:kimi-k3.1-day-0from
Fridge003:codex/kimi-pcp-kv-sharding
Closed

Fridge003 wants to merge 1 commit into
sgl-project:kimi-k3.1-day-0from
Fridge003:codex/kimi-pcp-kv-sharding

Conversation

@Fridge003

@Fridge003 Fridge003 commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Kimi-K3.1 PCP currently replicates persistent DSA KV across ranks. Store each logical KV page and packed index page on its owner rank, then assemble the working prefix for TRTLLM DSA attention. This extends the existing page-sharded KV infrastructure to Kimi's hybrid attention, HiCache L2 and DFlash paths.

This PR targets kimi-k3.1-day-0, the branch of #48414.

Modifications

  • Add --kv-cache-sharding-scratch-size (GiB per GPU, default 10) to bound the two prefix-assembly buffers. Account for active prefixes, overlap and verification headroom in admission and retraction.
  • Keep dynamic DSA indexing, prefix assembly and attention in eager regions while preserving breakable CUDA graphs around the remaining computation. Mask writes for pages owned by other ranks.
  • Integrate compact HiCache L2 ownership without filtering the same owner twice; keep KDA state slots separate from widened KV indices and reserve scratch before restores.
  • Preserve hybrid PD transfer mapping across all KV owners, select the appropriate KDA head writers, and carry sparse source-page positions for Mooncake DCP transfers.
  • Size direct-indexed DFlash draft KV for target logical IDs and validate ring pools against their per-request physical address space.
  • Add regression coverage for graph boundaries, scratch budgets, fragmented target/draft index pages, hybrid host pools and independent KV/KDA/ring address spaces; document the configuration.

Kimi requires interleave PCP across all TP ranks, PP1, attention DP1, DCP1, DFlash, TRTLLM DSA prefill/decode, FP8 E4M3 KV, page size 64 and the Python unified tree core. PD prefill additionally requires the DFlash draft KV ring. HiCache support is limited to compatible L2 modes; L3 storage remains unsupported. Model-weight precision is unchanged.

Accuracy Tests

  • All applicable repository pre-commit hooks pass on the 46 changed files, including import sorting, Ruff, C++ formatting and registered-test validation.
  • AST parsing passes for all 44 changed Python files; git diff --check passes.
  • Runtime unit tests did not reach execution because the required Triton dependency is unavailable. No runtime pass count is claimed for this revision.
  • GPU accuracy, native-weight PD correctness and forced HiCache L2 restore correctness remain unverified for this revision. Required checks include cold-repeat equality, device reuse, eviction and a positive host-restore counter delta with a checkpoint-safe workload.

Speed Tests and Profiling

Pending for this revision. No throughput or latency improvement is claimed. Keep this PR in draft until correctness and performance validation is complete.

Checklist

  • Run repository formatting and static checks.
  • Include regression tests and configuration documentation.
  • Run the affected runtime test suites in a supported environment.
  • Complete GPU accuracy, PD, HiCache restore and performance validation.

CI States

Latest PR Test (Base): ❌ Run #41932502087
Latest PR Test (Extra): ❌ Run #41932501942
Latest PR Test (AMD ROCm 10): ❌ Run #41932502132

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

@github-actions github-actions Bot added documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang jit-kernel unified-radix-cache memory-pool mooncake labels Nov 4, 2026
@Fridge003 Fridge003 changed the title [Feat] kimi: Support PCP KV sharding with HiCache and DFlash [Feat] kimi-k31: Support PCP KV sharding with HiCache and DFlash Nov 4, 2026
@hnyls2002
hnyls2002 deleted the branch sgl-project:kimi-k3.1-day-0 November 17, 2026 07:33
@hnyls2002 hnyls2002 closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang jit-kernel memory-pool mooncake unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants