diff --git a/python/sglang/multimodal_gen/runtime/layers/lora/linear.py b/python/sglang/multimodal_gen/runtime/layers/lora/linear.py index a062479d1..e83f75a49 100644 --- a/python/sglang/multimodal_gen/runtime/layers/lora/linear.py +++ b/python/sglang/multimodal_gen/runtime/layers/lora/linear.py @@ -48,7 +48,9 @@ class BaseLayerWithLoRA(nn.Module): self.base_layer: nn.Module = base_layer self.merged: bool = False - self.cpu_weight = base_layer.weight.to("cpu") + # Immutable base-weight snapshot; `to("cpu")` may alias CPU storage. + # Use `clone()` so merge updates cannot mutate this backup tensor. + self.cpu_weight = base_layer.weight.detach().to("cpu").clone() # indicates adapter weights don't contain this layer # (which shouldn't normally happen, but we want to separate it from the case of erroneous merging) # Default to True to prevent using uninitialized weights; set to False when weights are loaded