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/27-kimi-core-calibration-20261108
branch
from
November 9, 2026 09:50
fe83c3b to
caa4e3d
Compare
Qubitium
reviewed
Nov 9, 2026
Qubitium
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed against current main.
The core calibration/storage layer is well bounded:
kimi_k3_core_formatowns the padded EXL3 source layout and the quantize/reconstruct path, including the padded row geometry and crop back to the native shape. The CUDA oracle tests assert packed round-trip mismatch counts of zero,1e-7-scale normalized Hessian error for the small case, and bit-identical inner-half reconstruction for fp16/bf16.kimi_k3_core_streamkeeps a single safetensors reader, returns owned tensors rather than mappings, and materializes routed experts explicitly so the block never holds file-backed pages.- The wrapper-inference tests compare native vs reconstructed-inner-GEMM paths at both batch 1 and batch 33 across fp16/bf16 and stay within the expected
~1e-4max-abs error. test_native_kimi_mla_shape_calibrated_quantization_and_cropis correctly skipped when the required MLA shape/hardware is unavailable.
Cleanup only: import ordering, dict(...) → literals, dict.fromkeys, and two semicolon-split lines in the test harness. Behaviour is unchanged and the full suite still passes.
Validation: ruff check clean; pytest tests/test_kimi_k3_core_format.py tests/test_kimi_k3_core_stream.py tests/test_kimi_k3_core_cuda.py reports 72 passed, 1 skipped.
Qubitium
marked this pull request as ready for review
November 9, 2026 09:50
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
Carry explicit attention/MoE/head calibration boundaries, bounded source-shard ownership, padded core projection storage validation and reconstruction, and calibrated EXL3 source replacement. Keep the existing independent format and CUDA oracle tests as carried evidence.
This is layer 27/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3606. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream
main.Incremental change: 7 files, +1318/−0 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["quantize_core_projection"] S1["reconstruct_core_projection"] S2["KimiK3EXL3Source"] M2_0["KimiK3EXL3Source.load_block"] M2_1["KimiK3EXL3Source.materialize_routed_experts"] S3["capture_linear_input"] E["KeyError, ValueError"] S0 -->|"raises on rejected input/state"| E S2 -. "exposes" .-> M2_0 S2 -. "exposes" .-> M2_1 S2 -->|"calls where selected"| S1 S2 -->|"raises on rejected input/state"| E style E fill:#fee,stroke:#b22gptqmodel/utils/kimi_k3_core_format.py:64:quantize_core_projectiongptqmodel/utils/kimi_k3_core_format.py:56:reconstruct_core_projectiongptqmodel/utils/kimi_k3_core_format.py:126:KimiK3EXL3Sourcegptqmodel/utils/kimi_k3_core_stream.py:87:capture_linear_inputCommitted reference: docs/kimi-core-calibration.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_core_format.py,tests/test_kimi_k3_core_stream.py,tests/test_kimi_k3_core_cuda.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.