Skip to content

[II] TP-shard Kimi MLA latent projections - #345

Closed
voipmonitor wants to merge 1 commit into
dev/infernal-invocationfrom
agent/ii-kimi-sharded-qkv-a
Closed

voipmonitor wants to merge 1 commit into
dev/infernal-invocationfrom
agent/ii-kimi-sharded-qkv-a

Conversation

@voipmonitor

Copy link
Copy Markdown

Status

Implemented and independently validated.

Behavior

VLLM_KIMI_SHARD_QKV_A=1 stores the merged Kimi-K3 q_a and kv_a projection as tensor-parallel column shards. Each forward pass gathers one rank-local merged output and restores the logical q_a followed by kv_a layout before either latent is consumed.

For moonshotai/Kimi-K3@2496450e92e425c886db095102a52a6682ca3970, each of 24 MLA layers has a 2,112 by 7,168 BF16 merged projection. TP16 sharding reduces this replicated weight storage by approximately 0.634 GiB per GPU.

Technical reason

The low-rank latent tensors are logically replicated, but their projection weights do not need to be. A standard tensor-parallel gather reconstructs the exact output. Merged-column collectives produce rank-major shards, so the implementation explicitly restores the two logical projection ranges.

Compatibility

  • The feature is disabled by default.
  • Disabled or TP1 operation retains the replicated disable_tp layer.
  • Enabled operation requires every merged output size to be divisible by the tensor-parallel size.
  • This pull request uses the standard tensor-parallel gather. A separate transport optimization may replace that gather without changing the weight layout or logical result.
  • Quantization behavior is inherited from MergedColumnParallelLinear.

Validation

Environment: NVIDIA PyTorch 26.07 image, PyTorch 2.13, CUDA 13.3.

  • Thirty Kimi sequence-parallel and projection tests pass.
  • Focused tests verify rank-major to logical projection ordering and reject non-divisible or truncated collective geometry.
  • Ruff format and check pass.
  • git diff --check passes.

Add an opt-in tensor-parallel layout for Kimi-K3 fused q_a and kv_a weights. Gather rank-local outputs once per layer and restore logical q_a/kv_a ordering before normalization, preserving the replicated projection result while reducing per-rank weight storage.
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@voipmonitor, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: acc0145d-fcff-4730-86f1-274bd346d073

📥 Commits

Reviewing files that changed from the base of the PR and between ad848fc and bd25a51.

📒 Files selected for processing (3)
  • tests/models/kimi_k3/test_sequence_parallel.py
  • vllm/envs.py
  • vllm/models/kimi_k3/nvidia/mla.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@voipmonitor

Copy link
Copy Markdown
Author

The behavior implemented by this pull request is preserved unchanged in vLLM #385 as commit fc426b02ae84. Stable Git patch IDs match. Review and merge #385; this pull request is closed to avoid duplicate review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant