@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / d1a75e303d
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 4, 12:30 UTC

Fix timeout when using LoRA adapters with Nemotron Super (#40916)

Signed-off-by: Daniel Serebrenik <daserebrenik@nvidia.com>

danisereb committed Apr 29, 2026 at 20:39 UTC d1a75e303d81eaaa3d0bb5622e0a6d380ccc22fa
2 files changed +1 -140
tests/lora/test_lora_manager.py
-107
@@ -943,110 +943,3 @@ def test_target_modules_match_packed_runtime_modules(
943 ("layer1.dense2", RowParallelLinearWithLoRA),
944 ],
945 )
946 -
947 -
948 -@pytest.mark.parametrize("device", DEVICES)
949 -def test_load_adapter_warns_on_unsupported_modules(
950 - default_vllm_config, dist_init, dummy_model_gate_up, device, tmp_path
951 -):
952 - """Test that _load_adapter warns when a LoRA adapter contains modules
953 - not in the model's supported LoRA target modules."""
954 - from unittest.mock import patch
955 -
956 - import vllm.lora.worker_manager as wm_module
957 -
958 - lora_config = LoRAConfig(
959 - max_lora_rank=8, max_cpu_loras=4, max_loras=4, lora_dtype=DEFAULT_DTYPE
960 - )
961 -
962 - dummy_lora_files = f"{tmp_path}/lora_adapter"
963 - os.makedirs(dummy_lora_files, exist_ok=True)
964 - create_peft_lora(
965 - dummy_model_gate_up,
966 - save_dir=dummy_lora_files,
967 - target_modules=["layer1.dense1", "dense2"],
968 - lora_dtype=DEFAULT_DTYPE,
969 - )
970 -
971 - model_config = ModelConfig(max_model_len=16)
972 - vllm_config = VllmConfig(model_config=model_config, lora_config=lora_config)
973 - vllm_config.scheduler_config.max_num_seqs = 4
974 - vllm_config.scheduler_config.max_num_batched_tokens = 2
975 -
976 - worker_manager = WorkerLoRAManager(vllm_config, device, EMBEDDING_MODULES)
977 - worker_manager.vocab_size = dummy_model_gate_up.unpadded_vocab_size
978 - worker_manager.create_lora_manager(dummy_model_gate_up)
979 -
980 - # Patch from_local_checkpoint to inject an unsupported module
981 - original_from_checkpoint = LoRAModel.from_local_checkpoint
982 -
983 - def patched_from_checkpoint(*args, **kwargs):
984 - lora = original_from_checkpoint(*args, **kwargs)
985 - lora.loras["unsupported_module"] = LoRALayerWeights(
986 - module_name="unsupported_module",
987 - rank=8,
988 - lora_alpha=16,
989 - lora_a=torch.randn(8, 10),
990 - lora_b=torch.randn(10, 8),
991 - )
992 - return lora
993 -
994 - lora_request = LoRARequest("test", 1, dummy_lora_files)
995 - with (
996 - patch.object(LoRAModel, "from_local_checkpoint", patched_from_checkpoint),
997 - patch.object(wm_module.logger, "warning_once") as mock_warning,
998 - ):
999 - worker_manager._load_adapter(lora_request)
1000 - warning_args = mock_warning.call_args_list
1001 - found = any("unsupported_module" in str(call) for call in warning_args)
1002 - assert found, (
1003 - f"Expected warning about 'unsupported_module', got: {warning_args}"
1004 - )
1005 -
1006 -
1007 -@pytest.mark.parametrize("device", DEVICES)
1008 -def test_load_adapter_warns_on_target_modules_restriction(
1009 - default_vllm_config, dist_init, dummy_model_gate_up, device, tmp_path
1010 -):
1011 - """Test that _load_adapter warns when a LoRA adapter contains modules
1012 - excluded by the deployment-time target_modules restriction."""
1013 - from unittest.mock import patch
1014 -
1015 - import vllm.lora.worker_manager as wm_module
1016 -
1017 - # Restrict to only dense2 — adapter has dense1 which will be excluded
1018 - lora_config = LoRAConfig(
1019 - max_lora_rank=8,
1020 - max_cpu_loras=4,
1021 - max_loras=4,
1022 - lora_dtype=DEFAULT_DTYPE,
1023 - target_modules=["dense2"],
1024 - )
1025 -
1026 - dummy_lora_files = f"{tmp_path}/lora_adapter"
1027 - os.makedirs(dummy_lora_files, exist_ok=True)
1028 - create_peft_lora(
1029 - dummy_model_gate_up,
1030 - save_dir=dummy_lora_files,
1031 - target_modules=["layer1.dense1", "dense2"],
1032 - lora_dtype=DEFAULT_DTYPE,
1033 - )
1034 -
1035 - model_config = ModelConfig(max_model_len=16)
1036 - vllm_config = VllmConfig(model_config=model_config, lora_config=lora_config)
1037 - vllm_config.scheduler_config.max_num_seqs = 4
1038 - vllm_config.scheduler_config.max_num_batched_tokens = 2
1039 -
1040 - worker_manager = WorkerLoRAManager(vllm_config, device, EMBEDDING_MODULES)
1041 - worker_manager.vocab_size = dummy_model_gate_up.unpadded_vocab_size
1042 - worker_manager.create_lora_manager(dummy_model_gate_up)
1043 -
1044 - lora_request = LoRARequest("test", 1, dummy_lora_files)
1045 - with patch.object(wm_module.logger, "warning_once") as mock_warning:
1046 - worker_manager._load_adapter(lora_request)
1047 - warning_args = mock_warning.call_args_list
1048 - # dense1 is supported by the model but excluded by target_modules
1049 - found = any("target_modules" in str(call) for call in warning_args)
1050 - assert found, (
1051 - f"Expected warning about target_modules restriction, got: {warning_args}"
1052 - )
vllm/lora/worker_manager.py
+1 -33
@@ -17,11 +17,7 @@ from vllm.lora.model_manager import (
17 )
18 from vllm.lora.peft_helper import PEFTHelper
19 from vllm.lora.request import LoRARequest
20 -from vllm.lora.utils import (
21 - get_adapter_absolute_path,
22 - is_in_target_modules,
23 - is_supported_lora_module,
24 -)
20 +from vllm.lora.utils import get_adapter_absolute_path
21
22 logger = init_logger(__name__)
23
@@ -146,34 +142,6 @@ class WorkerLoRAManager:
142 skip_prefixes=lora_skip_prefixes,
143 )
144
149 - # Warn about adapter modules that will be ignored.
150 - target_modules = self.lora_config.target_modules
151 - expected_lora_modules_lst = list(expected_lora_modules)
152 - for module_name in lora.loras:
153 - if not is_supported_lora_module(module_name, expected_lora_modules_lst):
154 - logger.warning_once(
155 - "LoRA module '%s' in adapter '%s' is not in the "
156 - "model's supported LoRA target modules [%s]. "
157 - "These parameters will be ignored, which may "
158 - "cause abnormal model behavior.",
159 - module_name,
160 - lora_request.lora_path,
161 - ", ".join(sorted(expected_lora_modules_lst)),
162 - )
163 - elif not is_in_target_modules(
164 - module_name,
165 - target_modules,
166 - packed_modules_mapping,
167 - ):
168 - logger.warning_once(
169 - "LoRA module '%s' in adapter '%s' is not in the "
170 - "deployment-time target_modules restriction [%s]."
171 - " These parameters will be ignored.",
172 - module_name,
173 - lora_request.lora_path,
174 - ", ".join(sorted(target_modules)),
175 - )
176 -
145 except FileNotFoundError as e:
146 # FileNotFoundError should be raised if both
147 # - No adapter found to download from huggingface (or in