Repository navigation
Add Kimi-Linear-48B-A3B (kimi-linear) - #275
Merged
kotselidis merged 9 commits intoNov 24, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This was referenced Nov 19, 2026
orionpapadakis
approved these changes
Nov 24, 2026
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.
Depends on #242 (GLM-5.3-Flash,
glm5next): this branch is stacked onfeat/glm53-flashand reuses its KDA, routed-expert and int8 GEMM pieces. Merge #242 first; this PR then retargets tomain.Adds Kimi-Linear-48B-A3B (
moonshotai/Kimi-Linear-48B-A3B-Instruct) as thekimi-linearfamily, loaded from llama.cpp'skimi-linearGGUFs, on the CPU and on CUDA: single-token decode, sequential prefill/decode and batched prefill, on one GPU or split across several.The model
48B parameters (49.12B counted), about 3B active per token. 27 layers: 20 KDA (Kimi delta attention) and 7 MLA layers without RoPE (layers 3, 7, 11, 15, 19, 23, 26); a dense SwiGLU in layer 0, then 256 routed experts (top 8, sigmoid routing with a selection bias, scale 2.446) plus one shared expert. Plain pre-norm residual, no hyper-connections. Kimi's tiktoken vocabulary (163 840 tokens) and chat template. See
docs/architecture/kimi-linear.md.How it is built
Kimi-Linear is deepseek2's latent attention and mixture of experts plus glm5next's KDA, so it reuses both:
KdaForward,KdaHostState,KdaWeights,KdaKernels,KdaBatchKernels); only the decay is new (−exp(A_log) · softplus(·), where glm5next uses a bounded sigmoid).attn_q.RoutedExpertKernelsandRoutedExpertBatchKernels, with the clamp at infinity; Q8_0 or Q4_0 routed experts.KimiTokenizer(Kimi's split onQwen3Tokenizer's byte-level BPE) andKimiChatFormat.Correctness
Performance
NVIDIA A100 80GB, Q8_0 (48.65 GiB), one GPU. Both sides on the same 427-token prompt, decode of 128 tokens at depth 427, five repetitions; jitllm medians with their range, llama.cpp (
11fe021,-fa 1 -ngl 99) mean ± deviation. Tokens per second.CUDA graphs change neither number. The single-token plan runs prompt and decode together at 154 tokens per second.
2× NVIDIA A10, Q8_0 projections with Q4_0 routed experts (26.72 GiB), split by layer with the default byte-balanced split (
--split-transport host). The same 427-token prompt and depth-427 decode; three repetitions each, jitllm medians with their range, llama.cpp (-sm layer) mean ± deviation:The single-token plan runs prompt and decode together at 127 tokens per second.
Limits
llama-gguf-split --mergefirst.llama-quantize --allow-requantize --tensor-type ffn_gate_exps=q4_0 --tensor-type ffn_up_exps=q4_0 --tensor-type ffn_down_exps=q4_0 in.gguf out.gguf Q8_0.