[Bugfix] Fix Kimi K3 loading with interleaved weight streams (#53379)

Signed-off-by: Sherif Waly <sherif.waly@mistral.ai>
Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai>
This commit is contained in:
Sherif Waly
2026-09-08 16:08:51 +02:00
committed by GitHub
co-authored by Nicolò Lucchesi
parent 613ab20f7f
commit f998862d46
2 changed files with 80 additions and 2 deletions
+8 -2
View File
@@ -1705,12 +1705,15 @@ class KimiLinearForCausalLM(
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
loader = AutoWeightsLoader(self)
loaded = loader.load_weights(weights)
return loader.load_weights(weights)
def process_weights_after_loading(self) -> None:
# A parent AutoWeightsLoader may invoke load_weights repeatedly for
# non-contiguous streamed prefixes. Finalize only after the full stream.
self.model.finalize_mega_moe_weights()
# The fused MultiHeadLatentAttention's process_weights_after_loading
# (W_UK_T / W_UV absorption) is driven by the loader's generic post-load
# hook for any AttentionLayerBase, so no manual trigger is needed here.
return loaded
def get_spec_layer_idx_from_weight_name(
@@ -2155,3 +2158,6 @@ class KimiK3ForConditionalGeneration(
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]):
loader = AutoWeightsLoader(self)
return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
def process_weights_after_loading(self) -> None:
self.language_model.process_weights_after_loading()