[Bugfix] Fix level-2 sleep/wake/reload with enable_lora=True (#39935)

Signed-off-by: Silen Naihin <silen.naihin@gmail.com>
Co-authored-by: Dakai An <dakaian108@gmail.com>
Co-authored-by: Jiangyun Zhu <riverclouds.zhu@qq.com>
This commit is contained in:
Silen Naihin
2026-08-06 09:13:10 +08:00
committed by GitHub
co-authored by Dakai An Jiangyun Zhu
parent 8cfa01cdd2
commit b50fdebce0
11 changed files with 252 additions and 4 deletions
+13
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Iterable
from typing import TYPE_CHECKING, overload
import torch
@@ -14,6 +15,18 @@ if TYPE_CHECKING:
class BaseLayerWithLoRA(nn.Module):
def load_weights(
self, weights: Iterable[tuple[str, torch.Tensor]]
) -> Iterable[str]:
"""Load checkpoint weights into the wrapped base layer."""
base_load_weights = getattr(self.base_layer, "load_weights", None)
if callable(base_load_weights):
return base_load_weights(weights)
from vllm.model_executor.models.utils import AutoWeightsLoader
return AutoWeightsLoader(self.base_layer).load_weights(weights)
@overload
def slice_lora_a(
self, lora_a: list[torch.Tensor | None]
+12
View File
@@ -118,6 +118,18 @@ class LogitsProcessorWithLoRA(BaseLayerWithLoRA):
else:
self.sharded_to_full_mapping_gpu = None
def reset_sharded_to_full_mapping(self) -> None:
"""Restore the TP logits mapping after its GPU memory is reused."""
mapping_gpu = self.sharded_to_full_mapping_gpu
if mapping_gpu is not None:
mapping_gpu.copy_(
torch.tensor(
self.sharded_to_full_mapping,
device=mapping_gpu.device,
dtype=mapping_gpu.dtype,
)
)
def reset_lora(self, index: int):
self.lora_a_stacked[index] = 0
self.lora_b_stacked[index] = 0