Skip to content

feat: add Kimi-K3 model definition and quantization example - #2994

Open
kylesayrs wants to merge 7 commits into
mainfrom
kimi-k3-example
Open

feat: add Kimi-K3 model definition and quantization example#2994
kylesayrs wants to merge 7 commits into
mainfrom
kimi-k3-example

Conversation

@kylesayrs

@kylesayrs kylesayrs commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Currently dequantizes the entire model up-front, but we can avoid upfront quantization using layerwise decompression

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 74b72e89-97e6-41c4-8492-d3bed81aa69e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

@mergify

mergify Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages:
https://github.com/vllm-project/llm-compressor/blob/main/CONTRIBUTING.md

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the Kimi-K3 model, adding its configuration, XTML encoding helpers, multimodal and vision processors, model architectures, and a tokenizer, along with a quantization example. The review feedback identifies a critical bug in modeling_kimi_k3_linear.py where the optimized inference path is hardcoded to False. Additionally, it highlights several improvement opportunities, such as replacing unsafe assert statements used for runtime input, file, and dependency validation with standard if checks that raise appropriate exceptions, and defensively using .get() and type checks to prevent potential KeyError or TypeError crashes.

Comment thread src/llmcompressor/modeling/kimi_k3/modeling_kimi_k3_linear.py Outdated
Comment thread src/llmcompressor/modeling/kimi_k3/modeling_kimi_k3_linear.py Outdated
Comment thread src/llmcompressor/modeling/kimi_k3/modeling_kimi_k3_linear.py Outdated
Comment thread src/llmcompressor/modeling/kimi_k3/modeling_kimi_k3.py
Comment thread src/llmcompressor/modeling/kimi_k3/tokenization_kimi.py
Comment thread src/llmcompressor/modeling/kimi_k3/kimi_k3_processor.py
Comment thread src/llmcompressor/modeling/kimi_k3/configuration_kimi_k3.py
Comment thread src/llmcompressor/modeling/kimi_k3/encoding_k3.py

@brian-dellabetta brian-dellabetta left a comment

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.

overall lgtm, couple questions. when you have empty checkboxes in your PR summary, does that mean PR is still WIP or that you've added each of those?

Comment thread src/llmcompressor/modeling/kimi_k3/modeling_kimi_linear.py

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.

do you have a record at all of what you had to change to get this to work? In case we need to modify later?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a diff record!

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.

sorry, where is the diff? is it a commit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Hmm, it's not loading correctly for me. can you point to the file name / line number? This is also for personal edification, but a README outlining changes from what was copy-pasted from the model checkpoint itself would be handy

@kylesayrs
kylesayrs requested a review from yiliu30 as a code owner August 10, 2026 19:45
@mergify mergify Bot removed the quality-failed label Aug 10, 2026
@mergify

mergify Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages:
https://github.com/vllm-project/llm-compressor/blob/main/CONTRIBUTING.md

@mergify

mergify Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages:
https://github.com/vllm-project/llm-compressor/blob/main/CONTRIBUTING.md

@mergify

mergify Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages:
https://github.com/vllm-project/llm-compressor/blob/main/CONTRIBUTING.md

Comment thread examples/quantizing_moe/kimi_k3_example.py
@mergify

mergify Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 1 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require one maintainer review 👀 reviews

🔴 Require one maintainer review

Waiting for any of

  • approved-reviews-by=HDCharles
  • approved-reviews-by=brian-dellabetta
  • approved-reviews-by=dsikka
  • approved-reviews-by=kylesayrs
  • approved-reviews-by=yiliu30
This rule is failing.

All PRs must have at least one approving review from a maintainer before merging.

  • any of:
    • approved-reviews-by=HDCharles
    • approved-reviews-by=brian-dellabetta
    • approved-reviews-by=dsikka
    • approved-reviews-by=kylesayrs
    • approved-reviews-by=yiliu30
  • #changes-requested-reviews-by = 0

kylesayrs and others added 5 commits August 18, 2026 01:06
Add vendored Kimi-K3 model implementation (KimiK3ForConditionalGeneration)
with configuration, vision processing, tokenization, and encoding support.

Add quantization example that loads a quantization config from pretrained,
adds ignore patterns for residual projections and routed experts, and
passes the config as a loading argument.

Also adds _apply_attn_res to default tracing ignore list for Kimi-K3
compatibility with the sequential pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
…files

Each kimi_k3 file now has a comment at the top documenting implementation
differences from the original files at moonshotai/Kimi-K3 on Hugging Face.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…, remove formatting-only comments

- Rename modeling_kimi_k3_linear.py back to modeling_kimi_linear.py to
  match the upstream HuggingFace filename
- Remove the re-export shim that was in modeling_kimi_linear.py
- Remove "Differences: formatting only" comments from files with no
  substantive changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Kimi-K3 key models documentation page with NVFP4 example, update
nav and index. Exclude kimi_k3 modeling files from ruff since they are
vendored upstream files. Fix import ordering in kimi_k3_example.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kylesayrs kylesayrs mentioned this pull request Aug 19, 2026
@kylesayrs kylesayrs added the ready When a PR is ready for full CI testing before merge label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready When a PR is ready for full CI testing before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants