[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
+47
View File
@@ -83,6 +83,21 @@ NUM_RANDOM_SEEDS = 2
VOCAB_PARALLEL_EMBEDDING_TEST_NUM_RANDOM_SEEDS = 2
def test_base_layer_with_lora_delegates_load_weights():
class BaseLayer(torch.nn.Module):
def load_weights(self, weights):
self.loaded_weights = list(weights)
return {"weight"}
base_layer = BaseLayer()
layer = BaseLayerWithLoRA()
layer.base_layer = base_layer
weights = [("weight", torch.ones(1))]
assert layer.load_weights(weights) == {"weight"}
assert base_layer.loaded_weights == weights
@pytest.fixture(autouse=True)
def clean_cache_reset_device(reset_default_device):
# Release any memory we might be holding on to. CI runs OOMs otherwise.
@@ -509,6 +524,38 @@ def test_lm_head_logits_processor_invalid_vocab_size(
lora_logits_processor.create_lora_weights(max_loras, lora_config)
@torch.inference_mode()
@pytest.mark.parametrize("device", DEVICES)
def test_lm_head_reset_sharded_to_full_mapping(
default_vllm_config, dist_init, device
) -> None:
if current_platform.is_cuda_alike() or current_platform.is_xpu():
torch.accelerator.set_device_index(device)
torch.set_default_device(device)
max_loras = 8
vocab_size = 1024
lora_config = LoRAConfig(
max_loras=max_loras, max_lora_rank=8, lora_dtype=torch.float16
)
logits_processor = LogitsProcessor(vocab_size)
sharded_to_full_mapping = list(reversed(range(vocab_size)))
lora_logits_processor = LogitsProcessorWithLoRA(
logits_processor, 1024, torch.float16, device, sharded_to_full_mapping
)
lora_logits_processor.create_lora_weights(max_loras, lora_config)
lora_logits_processor.sharded_to_full_mapping_gpu.fill_(-1)
lora_logits_processor.reset_sharded_to_full_mapping()
torch.testing.assert_close(
lora_logits_processor.sharded_to_full_mapping_gpu,
torch.tensor(sharded_to_full_mapping, dtype=torch.long),
)
@torch.inference_mode()
@pytest.mark.parametrize("num_loras", [1, 2, 4])
@pytest.mark.parametrize("device", DEVICES)