Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions vllm/model_executor/models/deepseek_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,8 @@ def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
and loaded_weight.dtype == torch.float8_e8m0fnu
):
loaded_weight = loaded_weight.view(torch.uint8)
name_mapped = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Initializing name_mapped to None prevents the UnboundLocalError, but we should also track whether any expert mapping was successfully loaded. If weight_loader returns False for all mappings (e.g., because the expert is not assigned to the current rank), the parameter should not be added to loaded_params. Initializing a success flag here allows for a more robust check after the loop.

                    name_mapped = None
                    success = False

success = False
for mapping in expert_mapping:
param_name, weight_name, expert_id, shard_id = mapping
if weight_name not in name:
Expand All @@ -1554,6 +1556,13 @@ def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
if success:
name = name_mapped
break
if not success:
# No expert mapping matched, or the loader did not
# load this weight for the current rank (e.g. a
# non-canonical checkpoint, or this rank holds no
# replica). Skip it instead of marking it loaded or
# raising UnboundLocalError.
continue
loaded_params.add(name_mapped)
continue
elif "attn_sink" in name:
Expand Down
Loading