From 7c51369e71ef11c3000a3a1c07e3356c913ae5c3 Mon Sep 17 00:00:00 2001 From: Yuri Khrustalev Date: Wed, 25 Mar 2026 00:00:00 +0000 Subject: [PATCH] lfm2: strip lm_head.weight for tied embeddings The lfm2 model always uses tied embeddings (embed_tokens.as_linear), but some checkpoints (e.g. LiquidAI/LFM2.5-350M) ship a separate lm_head.weight in their safetensors. This causes load_weights to raise "Received 1 parameters not in model: lm_head.weight". Strip lm_head.weight in sanitize, matching the pattern already used by llama, mixtral, and qwen3_moe. --- mlx_lm/models/lfm2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mlx_lm/models/lfm2.py b/mlx_lm/models/lfm2.py index c7f742af9..07bebdea1 100644 --- a/mlx_lm/models/lfm2.py +++ b/mlx_lm/models/lfm2.py @@ -298,6 +298,8 @@ def __call__( def sanitize(self, weights): sanitized_weights = {} for name, param in weights.items(): + if name == "lm_head.weight": + continue if "conv.weight" in name: if param.shape[-1] > param.shape[1]: param = param.transpose(0, 2, 1)