Skip to content

Commit f55f4b0

Browse files
shimmyshimmerworthant
authored andcommitted
kimi-k3 : fixes for loading and running the full-size model
Graph node budget, LLM_TYPE for the 93-layer config, four hparams promoted to required, and an E8M0 NaN check during the MXFP4 repack. Details in the PR description.
1 parent 2529313 commit f55f4b0

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/llama-context.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,10 @@ void llama_context::output_reorder() {
23342334
//
23352335

23362336
uint32_t llama_context::graph_max_nodes(uint32_t n_tokens) const {
2337+
if (model.arch == LLM_ARCH_KIMI_K3) {
2338+
// the n_tokens*40 budget below is exhausted at ubatch 3840
2339+
return std::max<uint32_t>(n_tokens * 160, 64u * model.n_tensors());
2340+
}
23372341
if (model.arch == LLM_ARCH_QWEN3NEXT ||
23382342
model.arch == LLM_ARCH_KIMI_LINEAR ||
23392343
model.arch == LLM_ARCH_QWEN35 ||

src/llama-model.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ const char * llm_type_name(llm_type type) {
832832
case LLM_TYPE_397B_A17B: return "397B.A17B";
833833
case LLM_TYPE_685B_A37B: return "685B.A37B";
834834
case LLM_TYPE_744B_A40B: return "744B.A40B";
835+
case LLM_TYPE_2_8T_A50B: return "2.8T.A50B";
835836
case LLM_TYPE_E2B: return "E2B";
836837
case LLM_TYPE_E4B: return "E4B";
837838
default: return "?B";

src/llama-model.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ enum llm_type {
142142
LLM_TYPE_397B_A17B, // Qwen3.5
143143
LLM_TYPE_685B_A37B, // DeepSeek V3.2
144144
LLM_TYPE_744B_A40B, // GLM-5
145+
LLM_TYPE_2_8T_A50B, // Kimi-K3
145146
LLM_TYPE_E2B,
146147
LLM_TYPE_E4B,
147148
};

src/models/kimi-k3.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ void llama_model_kimi_k3::load_arch_hparams(llama_model_loader & ml) {
4747
// K3 always renormalizes the top-k sigmoid weights (moe_renormalize = true)
4848
hparams.expert_weights_norm = true;
4949

50-
type = LLM_TYPE_UNKNOWN;
50+
GGML_ASSERT(hparams.attn_res_block_size > 0 && "Kimi-K3 requires attn_res_block_size");
51+
GGML_ASSERT(hparams.moe_latent_size > 0 && "Kimi-K3 requires moe_latent_size");
52+
53+
switch (hparams.n_layer()) {
54+
case 93: type = LLM_TYPE_2_8T_A50B; break; // Kimi-K3
55+
default: type = LLM_TYPE_UNKNOWN;
56+
}
5157
}
5258

5359
void llama_model_kimi_k3::load_arch_tensors(llama_model_loader &) {

0 commit comments

Comments
 (0)