Skip to content
Merged
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
22 changes: 12 additions & 10 deletions vllm/model_executor/layers/mamba/mamba_mixer2.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,14 @@ def loader(param: torch.Tensor, loaded_weight: torch.Tensor) -> None:
# - the ignore is for a mundane mypy error as it does not
# seem to handle slices well.
# https://github.com/python/mypy/issues/2410
target_slice = param.data[boundary : (boundary + take), ...]
param.data[
boundary : (boundary + take), ... # type: ignore[misc]
] = loaded_weight[
loaded_start_idx : (
loaded_start_idx + take
) # type: ignore[misc]
] # type: ignore[misc]
].view_as(target_slice)

# move indexing boundaries
boundary += shard_size
Expand Down Expand Up @@ -440,17 +441,18 @@ def __init__(
tp_rank,
)

# Apply the custom weight loader to in_proj.weight
# Apply the custom weight loader to in_proj.weight and its scales.
# Works for both non-quantized (Parameter) and quantized
# (ModelWeightParameter which extends BasevLLMParameter)
if isinstance(self.in_proj.weight, BasevLLMParameter):
# For BasevLLMParameter subclasses (quantized layers like FP8)
# These have a weight_loader property that can be directly set
self.in_proj.weight.weight_loader = mamba_loader
else:
# For standard Parameter (non-quantized layers)
delattr(self.in_proj.weight, "weight_loader")
set_weight_attrs(self.in_proj.weight, {"weight_loader": mamba_loader})
for attr_name in ("weight", "weight_scale", "input_scale"):
param = getattr(self.in_proj, attr_name, None)
if param is not None:
if isinstance(param, BasevLLMParameter):
param.weight_loader = mamba_loader
else:
if hasattr(param, "weight_loader"):
delattr(param, "weight_loader")
set_weight_attrs(param, {"weight_loader": mamba_loader})

# unsqueeze to fit conv1d weights shape into the linear weights shape.
# Can't do this in `weight_loader` since it already exists in
Expand Down
Loading