Skip to content

Commit eb83923

Browse files
add projector LayerNorm weight mapping (converter side)
1 parent 0dda80f commit eb83923

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

convert_hf_to_gguf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3912,13 +3912,22 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter
39123912
if ".head." in name:
39133913
return []
39143914

3915-
# 3) Projector MLP remap: mlp1 -> mm indices (match 'mlp1.' anywhere, not just at start)
3915+
# 3) Projector MLP remap: map Eagle2-VL mlp1.* -> mm_input_norm/mm.0/mm.2
39163916
mlp_pos = name.find("mlp1.")
39173917
if mlp_pos != -1:
39183918
mlp_suffix = name[mlp_pos + len("mlp1."):]
3919-
# Skip LayerNorm (mlp1.0.*)
3919+
# Map Eagle2-VL projector LayerNorm:
3920+
# mlp1.0.{weight,bias} correspond to the input LayerNorm of the projector
3921+
# (structure: LayerNorm → Linear → GELU → Linear).
3922+
# The C++ runtime applies ggml_norm + scale/shift, so we store γ/β as mm_input_norm_w/b.
39203923
if mlp_suffix.startswith("0."):
3924+
if mlp_suffix.endswith("weight"):
3925+
return [("mm_input_norm_w", data_torch)]
3926+
if mlp_suffix.endswith("bias"):
3927+
return [("mm_input_norm_b", data_torch)]
3928+
# any other subfield under mlp1.0.* (rare) -> skip
39213929
return []
3930+
39223931
# Map first Linear (mlp1.1.*) -> mm.0.*
39233932
if mlp_suffix.startswith("1."):
39243933
new_name = "mm.0." + mlp_suffix[2:]

0 commit comments

Comments
 (0)