-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Misc] Avoid loading incorrect LoRA config (#3777)
- Loading branch information
Showing
3 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from vllm.lora.models import LoRAModel | ||
from vllm.model_executor.models.baichuan import BaiChuanBaseForCausalLM | ||
|
||
|
||
@pytest.mark.parametrize("lora_name", ["baichuan7B", "chatglm3-6b"]) | ||
def test_load_checkpoints(lora_name, chatglm3_lora_files, baichuan_lora_files): | ||
supported_lora_modules = BaiChuanBaseForCausalLM.supported_lora_modules | ||
packed_modules_mapping = BaiChuanBaseForCausalLM.packed_modules_mapping | ||
embedding_modules = BaiChuanBaseForCausalLM.embedding_modules | ||
embed_padding_modules = BaiChuanBaseForCausalLM.embedding_padding_modules | ||
expected_lora_modules = [] | ||
for module in supported_lora_modules: | ||
if module in packed_modules_mapping: | ||
expected_lora_modules.extend(packed_modules_mapping[module]) | ||
else: | ||
expected_lora_modules.append(module) | ||
if lora_name == "baichuan7B": | ||
# For the baichuan7B model, load it's LoRA, | ||
# and the test should pass. | ||
LoRAModel.from_local_checkpoint( | ||
baichuan_lora_files, | ||
expected_lora_modules, | ||
lora_model_id=1, | ||
device="cpu", | ||
embedding_modules=embedding_modules, | ||
embedding_padding_modules=embed_padding_modules) | ||
else: | ||
# For the baichuan7B model, load chatglm3-6b's LoRA, | ||
# and the test should raise the following error. | ||
expected_error = "Please verify that the loaded LoRA module is correct" # noqa: E501 | ||
with pytest.raises(ValueError, match=expected_error): | ||
LoRAModel.from_local_checkpoint( | ||
chatglm3_lora_files, | ||
expected_lora_modules, | ||
lora_model_id=1, | ||
device="cpu", | ||
embedding_modules=embedding_modules, | ||
embedding_padding_modules=embed_padding_modules) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters