Skip to content

Commit 337eb23

Browse files
jiahancmgoin
andauthored
[Fix] Fix llama4 modelopt weight loading error (#22107)
Signed-off-by: jiahanc <[email protected]> Co-authored-by: mgoin <[email protected]>
1 parent 2ff46b8 commit 337eb23

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

vllm/model_executor/models/mllama4.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,11 +906,13 @@ def _consolidate_qkv_weights(
906906
def _rename_weight_for_modelopt_checkpoint(self, name: str) -> str:
907907
"""Rename weights from ModelOpt llama4 fp8 checkpoints to vLLM
908908
format."""
909-
if name.startswith("model."):
909+
if name.startswith("model.") or name.startswith(
910+
"language_model.model."):
911+
renamed = name.replace("model.", "language_model.model.",
912+
1) if name.startswith("model.") else name
910913
# Handle expert scale parameters with flat naming
911914
if "feed_forward.experts." in name and ("_input_scale" in name or
912915
"_weight_scale" in name):
913-
renamed = name.replace("model.", "language_model.model.", 1)
914916
# Map checkpoint naming to vLLM's expected naming
915917
if "down_proj_input_scale" in renamed:
916918
return renamed.replace("down_proj_input_scale",
@@ -929,15 +931,14 @@ def _rename_weight_for_modelopt_checkpoint(self, name: str) -> str:
929931
# Handle attention scale parameters
930932
elif "self_attn." in name and (".k_scale" in name
931933
or ".v_scale" in name):
932-
renamed = name.replace("model.", "language_model.model.", 1)
933934
if ".k_proj.k_scale" in renamed:
934935
return renamed.replace(".k_proj.k_scale", ".attn.k_scale")
935936
elif ".v_proj.v_scale" in renamed:
936937
return renamed.replace(".v_proj.v_scale", ".attn.v_scale")
937938
return renamed
938939

939940
# Standard model.* to language_model.model.* renaming
940-
return name.replace("model.", "language_model.model.", 1)
941+
return renamed
941942

942943
elif name.startswith("lm_head.weight"):
943944
return name.replace("lm_head.weight",

0 commit comments

Comments
 (0)