[Misc][LoRA] Fix LoRA weight mapper (#11495)
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
@@ -74,7 +74,7 @@ def test_load_checkpoints(
|
||||
embedding_padding_modules=embed_padding_modules)
|
||||
|
||||
|
||||
def test_lora_weights_mapping(baichuan_lora_files, ):
|
||||
def test_lora_weights_mapping(baichuan_lora_files):
|
||||
supported_lora_modules = BaiChuanBaseForCausalLM.supported_lora_modules
|
||||
packed_modules_mapping = BaiChuanBaseForCausalLM.packed_modules_mapping
|
||||
embedding_modules = BaiChuanBaseForCausalLM.embedding_modules
|
||||
@@ -86,10 +86,14 @@ def test_lora_weights_mapping(baichuan_lora_files, ):
|
||||
else:
|
||||
expected_lora_modules.append(module)
|
||||
|
||||
hf_to_vllm_mapper = WeightsMapper(orig_to_new_prefix={
|
||||
"model.": "language_model.model.",
|
||||
}, )
|
||||
|
||||
hf_to_vllm_mapper = WeightsMapper(
|
||||
orig_to_new_prefix={
|
||||
"model.": "language_model.model.",
|
||||
},
|
||||
orig_to_new_substr={
|
||||
".layers.": ".baichuan_layers.",
|
||||
},
|
||||
)
|
||||
lora_model = LoRAModel.from_local_checkpoint(
|
||||
baichuan_lora_files,
|
||||
expected_lora_modules,
|
||||
@@ -101,3 +105,4 @@ def test_lora_weights_mapping(baichuan_lora_files, ):
|
||||
)
|
||||
for name in lora_model.loras:
|
||||
assert name.startswith(hf_to_vllm_mapper.orig_to_new_prefix["model."])
|
||||
assert ".baichuan_layers." in name
|
||||
|
||||
@@ -22,7 +22,7 @@ IMAGE_ASSETS = [
|
||||
|
||||
# After fine-tuning with LoRA, all generated content should start begin `A`.
|
||||
EXPECTED_OUTPUT = [
|
||||
"A stop sign stands prominently in the foreground, with a traditional Chinese gate and a black SUV in the background, illustrating a blend of modern and cultural elements.", # noqa: E501
|
||||
"A red stop sign stands prominently in the foreground, with a traditional Chinese gate and a black SUV in the background, illustrating a blend of modern and cultural elements.", # noqa: E501
|
||||
"A majestic skyscraper stands tall, partially obscured by a vibrant canopy of cherry blossoms, against a clear blue sky.", # noqa: E501
|
||||
]
|
||||
|
||||
@@ -76,3 +76,7 @@ def test_qwen2vl_lora(qwen2vl_lora_files):
|
||||
output1 = do_sample(llm, qwen2vl_lora_files, lora_id=1)
|
||||
for i in range(len(EXPECTED_OUTPUT)):
|
||||
assert EXPECTED_OUTPUT[i].startswith(output1[i])
|
||||
|
||||
output2 = do_sample(llm, qwen2vl_lora_files, lora_id=2)
|
||||
for i in range(len(EXPECTED_OUTPUT)):
|
||||
assert EXPECTED_OUTPUT[i].startswith(output2[i])
|
||||
|
||||
Reference in New Issue
Block a user