Repository navigation
[OMNIML-6079] [20/21] Add the Kimi-K3 expert-parallel adapter #2749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shengliangxu
wants to merge
17
commits into
shengliangx/hfep-11b-kimi-k25-vl
from
shengliangx/hfep-11c-kimi-k3
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7440b62
Add the Kimi-K3 expert-parallel adapter
shengliangxu 0d705d3
Size Kimi-K3's fused experts from the MoE block's latent decision
shengliangxu 8749a69
Read KDA's beta-sigmoid flag off the call's keywords
shengliangxu 1ac6768
Skip the tests below the transformers release the code requires
shengliangxu 47dea2c
Leave Kimi-K3's latent-expert projections and residual gates unquanti…
shengliangxu 04d2298
Keep Kimi's mm_projector in BF16 by default, as the vision block intends
shengliangxu 76176b3
Patch each Kimi-K3 checkpoint's own remote module
shengliangxu b59a381
State the expert plan Kimi-K3's prepare attaches
shengliangxu 09e370f
Run the Kimi-K3 bf16-experts test without compressed-tensors
shengliangxu 7cc71c3
Trim the Kimi-K3 adapter tests: fold duplicates into covering tests
shengliangxu 5613527
Refuse to import an untrusted checkpoint's code in the Kimi-K3 adapter
shengliangxu ffa1882
Let a missing conversion API stop the Kimi-K3 expert-parallel load
shengliangxu 7142db1
Decompress Kimi-K3 only with a quantization_config, and let its error…
shengliangxu f760d5f
Refuse a Kimi-K3 prepare without the checkpoint's path, and declare t…
shengliangxu ffdc408
Stop a Kimi-K3 load whose remote code drifts from what prepare patches
shengliangxu 3d74422
Register torch_a2a in Kimi-K3's prepare, before the plan decision bui…
shengliangxu 9df995b
Give Kimi-K3's cache the query offset transformers 5.15 asks for
shengliangxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,7 @@ | |
| minimax_m3_vl, | ||
| llama4_text, | ||
| kimi_vl, | ||
| kimi_k3, | ||
| kimi_k25, | ||
| nemotron_h_omni, | ||
| qwen2_moe, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """kimi_k3 specs (HF model type ``kimi_k3``).""" | ||
|
|
||
| from . import specs |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """kimi_k3 specs (HF model type ``kimi_k3``). | ||
|
|
||
| Kimi-K3: a remote-code VLM on the kimi_linear backbone, with packed mxfp4 experts that are | ||
| decompressed at load. | ||
| """ | ||
|
|
||
| from ..specs import EPSpec, ModelSpec, register | ||
| from .ep import BASE_MODEL_EP_PLAN, prepare | ||
|
|
||
| __all__: list[str] = [] | ||
|
|
||
| register( | ||
| ModelSpec( | ||
| model_type="kimi_k3", | ||
| modeling_source="remote_code", | ||
| ep_spec=EPSpec( | ||
| prepare=prepare, | ||
| prepared_ep_plan=BASE_MODEL_EP_PLAN, | ||
| # prepare's patches to the checkpoint's remote code were validated on this release. | ||
| requires_transformers="5.13", | ||
| ), | ||
| ) | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[SUGGESTION]
EPSpecalready has a declarative slot for the transformers floor —requires_transformers("Earliest transformers release that supports THIS model expert-parallel, when it is later than the framework floor", used bycheck_distributed_support, moe.py:170-174).minimax_m3_vlandqwen3_moeuse it; here the floor is instead enforced imperatively byrequire_transformers("5.8", ...)insideep.prepare.Two consequences:
check_distributed_support("kimi_k3")— called on its own at model_load_utils.py:478 to refuse a run "before any weight is loaded" — does not refuse, and the user misses the "Or quantize it without expert parallelism, e.g. with FSDP2" hint that wrapper appends.Separately, worth reconciling the number: the declared floor is 5.8 (for the decompressor), but
ep.pyis written against 5.13 throughout —USER_REGISTERED_MAPPINGSis 5.13+ (the test fixture gates on exactly that, test_kimi_k3_ep.py:69), and thecreate_causal_mask/get_mask_sizes/tie_weightsshims all say "tf>=5.13". The shims are conditional so they're no-ops on older releases, but if 5.8-5.12 is genuinely supported it would help to say so (and ideally to have run a load there); if it isn't, 5.13 is the honest floor.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ebad207: the spec declares
requires_transformers="5.13", the release the adapter's patches were developed and validated against, andprepareno longer checks a floor itself; a test sets 5.12 and checkscheck_distributed_supportrefuses it.