Repository navigation
Conversation
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
Qubitium
force-pushed
the
upstream/26-kimi-k3-native-source-20261108
branch
from
November 9, 2026 09:48
1a40b17 to
2f3028d
Compare
Qubitium
reviewed
Nov 9, 2026
Qubitium
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed against current main.
The K3 source path is deliberately bounded and fails closed where the ordinary looper cannot be correct:
load_calibration_referencecompiles the checkpoint's own decoder after AST-stripping the unused HF wrapper classes and thetransformers.utils.genericimport, so the reference math is the checkpoint's, not the installed Transformers'.KimiK3Sourcevalidatesmodel_type, every index shard name, and shard presence before use, and reads one tensor at a time (safe_open→ owned clone → device copy) so the 2.8T checkpoint never lands in host RAM.decode_mxfp4checks packed/scale geometry, rejects the NaN E8M0 exponent, decodes interleaved E2M1 nibbles against2^(e-127)scales, and rejects non-finite output.load_blockmaterializes a metaKimiDecoderLayerparameter-by-parameter, validates geometry, and deliberately keeps the paddedself_attn.A_logbytes rather than trimming them.prepare_moe/finish_moesplit the reference attention half from routed MoE and carry bothprefix_sumandblock_residual, which is the state the stock looper cannot preserve.KimiLinearQModel.quantizeandpre_quantizeraise when AttnRes layers are reached, so directModuleLooperuse cannot silently drop residual state. Only routedw1/w3/w2leaves are declared.
Cleanup: import ordering and dict.fromkeys in the new support test.
Validation: ruff check clean; pytest on the Kimi support/module-tree tests reports 221 passed, 12 skipped.
Qubitium
marked this pull request as ready for review
November 9, 2026 09:48
8 tasks done
Qubitium
added a commit
that referenced
this pull request
Nov 29, 2026
…ers (#6408) ds4rt is deprecated and is being refactored into method-agnostic features. The per-model calibration adapters it added (#3606-#3616) have no production caller: nothing in gptqmodel/ or scripts/ imports them, MODEL_MAP reaches none of them, and only their own doc pages and unit tests cite them. Delete 14 adapter utils plus exl3_hessian.py (its only user was kimi_k31): kimi_k3, kimi_k3_core_format, kimi_k3_core_stream, kimi_k31, glm5_core, glm5_mtp, glm5_flash_core, glm5_flash_mtp, step5_core, v41_capture, v41_checkpoint, v41_mixed_replay, v41_recovery and v41_routed_batch, with their 9 dedicated test files, their 9 doc pages and the index links. This also removes two policy violations that lived only in this code: step5_core.py ran an external families/step5/golden.py through exec_module with no trust_remote_code / GPTQ_BYPASS_SAFETY_CHECKS gate, and glm5_flash_core.py replaced chunk_kimi_delta_attention on the vendored glm5_next port module. The GPTQMODEL_KIMI_K3_UTILS env var in test_kimi_k3_support.py, which exec'd an arbitrary file, goes too. Kept: - ple_mmap.py: used by the deepseek_v41_flash port and definitions/deepseek_v41. - v41_source, v41_replay, v41_inputs, v41_dspark, v41_native: imported by tests/test_deepseek_v41_local_port.py, test_v41_checkpoint_mapped_ple.py and (v41_native) ports/deepseek_v41. They go with the separate ports/deepseek_v41 removal. - Tests of live code that lived in deleted files move to test_exl3_bitstream_oracle.py (ExllamaV3TorchLinear bitstream decode) and test_exllamav3_padded_output.py (ExllamaV3Linear padded output crop). The Kimi K3 definition, auto.py, kimi_linear.py and docs no longer point at the deleted "bounded KimiK3Source runner"; the NotImplementedError types and the substrings the tests match are unchanged. Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Register Kimi K3 and Kimi Linear routed-expert definitions and carry the bounded native source adapter, MXFP4 decode, AttnRes prefix/residual boundaries, and checkpoint reference loading. Ordinary looper entry points continue to reject unsupported AttnRes continuation explicitly.
This is layer 26/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3605. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream
main.Incremental change: 12 files, +606/−1 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.
Flow and existing-code boundary
flowchart TD S0["KimiK3Source"] M0_0["KimiK3Source.__init__"] M0_1["KimiK3Source.load_block"] S1["prepare_moe"] S2["finish_moe"] S3["KimiLinearQModel"] M3_0["KimiLinearQModel.quantize"] M3_1["KimiLinearQModel.pre_quantize"] S4["KimiK3QModel"] E["KeyError, NotImplementedError, ValueError"] S0 -. "exposes" .-> M0_0 S0 -. "exposes" .-> M0_1 S0 -->|"raises on rejected input/state"| E S3 -. "exposes" .-> M3_0 S3 -. "exposes" .-> M3_1 S3 -->|"raises on rejected input/state"| E style E fill:#fee,stroke:#b22gptqmodel/utils/kimi_k3.py:82:KimiK3Sourcegptqmodel/utils/kimi_k3.py:138:prepare_moegptqmodel/utils/kimi_k3.py:160:finish_moegptqmodel/models/definitions/kimi_k3.py:18:KimiLinearQModelCommitted reference: docs/kimi-k3-native-source.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.
Validation
Carried test files:
tests/test_kimi_k3_support.py,tests/module_tree/test_kimi_k3_fork_plan.py,tests/module_tree/test_kimi_linear_fork_plan.pyThis packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.
New registrations include explicit module-plan inventory entries, targeted plan tests and unqualified fusion entries. Three model-specific plan tests plus the selected registry/consumer metadata cases passed as part of the 10-test CPU metadata group; actual checkpoint/hardware tests were not rerun.