[Gemma4][Bugfix]: Enable Gemma4ForCasualLM to load lora adapters correctly (#38844)
Signed-off-by: ShubyM <shubymishra20@gmail.com>
This commit is contained in:
@@ -5,7 +5,9 @@ import pytest
|
||||
|
||||
from vllm.lora.lora_model import LoRAModel
|
||||
from vllm.lora.peft_helper import PEFTHelper
|
||||
from vllm.lora.utils import parse_fine_tuned_lora_name
|
||||
from vllm.model_executor.models.baichuan import BaiChuanBaseForCausalLM
|
||||
from vllm.model_executor.models.gemma4 import Gemma4ForCausalLM
|
||||
from vllm.model_executor.models.utils import WeightsMapper
|
||||
|
||||
lora_lst = ["baichuan7B", "baichuan7B-zero", "baichuan7B-zero-regex", "chatglm3-6b"]
|
||||
@@ -128,3 +130,24 @@ 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
|
||||
|
||||
|
||||
def test_gemma4_lora_weights_mapping():
|
||||
mapper = Gemma4ForCausalLM.hf_to_vllm_mapper
|
||||
name = "base_model.model.model.language_model.layers.9.mlp.down_proj.lora_A.weight"
|
||||
assert parse_fine_tuned_lora_name(name, mapper) == (
|
||||
"model.layers.9.mlp.down_proj",
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
def test_gemma4_moe_lora_weights_mapping():
|
||||
mapper = Gemma4ForCausalLM.hf_to_vllm_mapper
|
||||
name = (
|
||||
"base_model.model.model.language_model.layers.9.moe.experts."
|
||||
"gate_up_proj.lora_B.weight"
|
||||
)
|
||||
assert parse_fine_tuned_lora_name(name, mapper) == (
|
||||
"model.layers.9.moe.gate_up_proj",
|
||||
False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user