Skip to content

feat(k3): Kimi-K3 vLLM plugin vision + DSpark draft support - #1910

Open
sajandhy wants to merge 5 commits into
ROCm:mainfrom
sajandhy:hexwang/k3_dspark_026_vision_rebased
Open

feat(k3): Kimi-K3 vLLM plugin vision + DSpark draft support#1910
sajandhy wants to merge 5 commits into
ROCm:mainfrom
sajandhy:hexwang/k3_dspark_026_vision_rebased

Conversation

@sajandhy

@sajandhy sajandhy commented Aug 16, 2026

Copy link
Copy Markdown

Motivation

Note: This PR is being opened on behalf of others. The implementation is primarily from whx-sjtu / hexwang (xiaowang990929@gmail.com), ganyi (ygan@amd.com), Guanbao Yu (Guanbao.Yu@amd.com), and zejchen (zejchen@amd.com) on branch hexwang/k3_dspark_026_vision; I am submitting a cleaned rebased extraction to the upstream repo from my fork.

Land the remaining Kimi-K3 vLLM OOT work from hexwang/k3_dspark_026_vision onto current main as a clean, single-commit PR:

  • Multimodal / vision path for Kimi-K3 in the vLLM plugin
  • DSpark draft model registration and auxiliary hidden-state taps for speculative decoding
  • MLA / metadata / model-wrapper plumbing needed for mixed KDA batches and draft KV alignment
  • Recipe and design/plan docs for the plugin launch and DSpark speculative config

Earlier pieces of that branch already merged via squash PRs (#1752, #1782, #1806, #1876, #1820, etc.). This PR keeps main's later versions of those shared files and overlays only the still-unique delta.

Technical Details

  • Register K3DSparkModelatom.plugin.vllm.models.kimi_k3_dspark:KimiK3DSparkVllm
  • Extend plugin kimi_k3.py with segmented KDA forward, aux hidden-state collection, and multimodal outer/inner classes; add kimi_k3 to _PLUGIN_SUPPORTED_MULTIMODAL_MODELS
  • Attention / metadata / model-wrapper updates for multi-token draft queries and dtype-aligned draft KV pages
  • Update recipes/atom_vllm/Kimi-K3.md (prefix caching + DSpark speculative launch) and add recipes/atom_vllm/KVV.md plus vision design/plan docs
  • Expand tests/plugin/test_vllm_kimi_k3.py

Source branch (dirty history, 75 behind / 37 ahead): hexwang/k3_dspark_026_vision. This PR is a rebased extraction of the remaining tip delta.

Test Plan

  • black . and ruff check .
  • python -m pytest tests/ (non-GPU unit tests, including tests/plugin/test_vllm_kimi_k3.py)
  • Confirm no @support_torch_compile decorated model files were modified (native kimi_k3.py untouched)
  • vLLM plugin smoke: text-only Kimi-K3 serve per recipes/atom_vllm/Kimi-K3.md
  • Multimodal / vision path smoke (when image assets available)
  • DSpark speculative decode smoke with Inferact/Kimi-K3-DSpark and num_speculative_tokens=7

Test Result

Pending — draft PR for review of the extracted delta. Draft PRs do not trigger heavy CI.

Submission Checklist

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Run after the PR is approved and Pre Checkin passes
  • ✅ Run immediately when an approval review is submitted
  • ✅ Can be requested before approval with labels
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, and SGLang
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests

Heavy jobs are skipped when the PR is not approved and no matching ci:* label is present.
Add labels via the sidebar or gh pr edit 1910 --add-label <label>

@sajandhy
sajandhy force-pushed the hexwang/k3_dspark_026_vision_rebased branch from 574f4ed to 0cc72e5 Compare August 17, 2026 03:57
@sajandhy
sajandhy marked this pull request as ready for review August 18, 2026 03:40
@sajandhy
sajandhy requested a review from valarLip August 18, 2026 06:01
@sajandhy
sajandhy force-pushed the hexwang/k3_dspark_026_vision_rebased branch from 6742a7c to b3ffe3e Compare August 19, 2026 15:40
straight into the KV projection, while ``input_layernorm`` applies only
to the residual stream carrying the draft block.

``slot_mapping`` is optional: the native path reads it from

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why can't plugin follow the same way?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Native ATOM can use the default path because DSparkProposer calls write_context_kv immediately after the target forward, while forward_context().attn_metadata still describes the target step — so slot_mapping[:N] is the verified-token slots we need.

In the vLLM plugin, context KV is written from the speculator via precompute_and_store_context_kv(..., slot_mappings=...), not from ATOM's proposer/forward context. vLLM builds those slots from block tables, and they can differ per layer when the draft spans multiple KV cache groups — so the plugin passes slot_mappings explicitly rather than reading a single global attn_metadata.slot_mapping.

Both paths end up in the same write_context_kvwrite_context_kv_latent store; only the source of the slot indices differs. During the later draft backbone pass, attn_metadata.slot_mapping would describe the draft block, not the context rows — so we can't rely on forward context for this write in either design.

@zufayu
zufayu requested a review from yhl-amd August 20, 2026 00:52
@sajandhy
sajandhy requested a review from valarLip August 20, 2026 20:19
@sajandhy

Copy link
Copy Markdown
Author

@valarLip, @whx-sjtu, @zejunchen-zejun,
Please complete the review.
Thanks
Satya

@sajandhy

sajandhy commented Sep 2, 2026

Copy link
Copy Markdown
Author

@zejunchen-zejun,
Please take a look at this PR.
Thank you

whx-sjtu and others added 5 commits September 6, 2026 09:29
Keep main's later K3/DSpark/core fixes; overlay only the still-unique
plugin vision, DSpark draft, MLA/metadata, and recipe changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
The multimodal plugin classes in kimi_k3.py referenced symbols without
importing them, which made Ruff fail in pre-checks CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sajandhy
sajandhy force-pushed the hexwang/k3_dspark_026_vision_rebased branch from 58445f2 to 1b937ea Compare September 6, 2026 16:32
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.

3 participants