Skip to content

support kimi-k2.5-nvfp4#18412

Closed
yhyang201 wants to merge 8 commits intosgl-project:mainfrom
yhyang201:fix-nvfp4
Closed

support kimi-k2.5-nvfp4#18412
yhyang201 wants to merge 8 commits intosgl-project:mainfrom
yhyang201:fix-nvfp4

Conversation

@yhyang201
Copy link
Collaborator

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yhyang201, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for the Kimi-k2.5 model with NVFP4 quantization by refining how module exclusions are configured during model initialization. The changes ensure that the quantization process correctly identifies and handles specific model components, enabling the use of the NVFP4 format for improved efficiency or compatibility.

Highlights

  • Quantization Module Exclusion Adjustment: Modified the quant_config.exclude_modules list in kimi_k25.py to correctly map module names ('language_model' to 'model' and 'language_model.lm_head' to 'lm_head') before initializing the DeepseekV3ForCausalLM. This ensures proper handling of module exclusions during quantization for the Kimi-k2.5 model, specifically for NVFP4 support.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • python/sglang/srt/models/kimi_k25.py
    • Modified the __init__ method of the KimiK25ForCausalLM class to preprocess quant_config.exclude_modules.
    • Replaced 'language_model' with 'model' and 'language_model.lm_head' with 'lm_head' in the exclude_modules list to align with the DeepseekV3ForCausalLM module naming conventions for quantization.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet. The author has provided a detailed PR description with checklists and review processes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@yhyang201
Copy link
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions bot added the run-ci label Feb 7, 2026
Copy link
Contributor

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

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 adds support for kimi-k2.5-nvfp4. The change involves remapping module names in the quantization configuration to correctly exclude certain modules from quantization. However, the current implementation for remapping is buggy. I've provided a suggestion to fix this, which simplifies the logic and ensures correct behavior for all module paths.

@yhyang201
Copy link
Collaborator Author

(sglang) root@di-bm-cjiuqp-126:/sgl-workspace/Kimi-Vendor-Verifier# uv run python eval.py ocrbench --model kimi/your-model-id     --thinking --think-mode opensource --max-tokens 16384 --stream
============================================================
Running: ocrbench | thinking=True | mode=opensource
Model: kimi/your-model-id
max_tokens=16384, max_connections=100, epochs=1
temperature=None, top_p=None
stream=True, extra_body={'chat_template_kwargs': {'thinking': True}}
============================================================

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ocrbench (1,000 samples): kimi/your-model-id                                                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
max_connections: 100, max_tokens: 16384, extra_body: {...}, retry_on_error: 3, dataset: echo840/OCRBench

total time:                                       0:05:16
kimi/your-model-id                                1,295,224 tokens [I: 787,829, O: 507,395]

ocrbench_scorer
accuracy         0.930
stderr           0.008

@seindum
Copy link

seindum commented Feb 7, 2026

fyi i think i saw there are already two reqs on this, first #18370 and second #18391

but i think #18370 is the more complete fix because it remaps weight names with weightsmapper and aligns the exclude list, meanwhile #18391 expands exclude matching but i think doesn’t address the weight‑name mismatch

qq: this patch only rewrites exclude_modules, how does it handle the weight‑name mismatch (language_model.layers.* vs current layout) that triggers the load shape errors?

@yhyang201
Copy link
Collaborator Author

yhyang201 commented Feb 7, 2026

fyi i think i saw there are already two reqs on this, first #18370 and second #18391

but i think #18370 is the more complete fix because it remaps weight names with weightsmapper and aligns the exclude list, meanwhile #18391 expands exclude matching but i think doesn’t address the weight‑name mismatch

qq: this patch only rewrites exclude_modules, how does it handle the weight‑name mismatch (language_model.layers.* vs current layout) that triggers the load shape errors?

  1. I only wanted to modify Kimi 2.5, so I submitted this PR. I don’t know which approach is better lol—let’s leave it to whoever merges it to decide.
  2. I didn’t encounter any errors during loading.
python3 -m sglang.launch_server --model-path nvidia/Kimi-K2.5-NVFP4 --tp 8 --quantization modelopt_fp4 --trust-remote-code

@yhyang201 yhyang201 closed this Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants