[Gemma4][Bugfix]: Enable Gemma4ForCasualLM to load lora adapters correctly (#38844)
Signed-off-by: ShubyM <shubymishra20@gmail.com>
This commit is contained in:
@@ -69,6 +69,7 @@ from .interfaces import (
|
||||
)
|
||||
from .utils import (
|
||||
AutoWeightsLoader,
|
||||
WeightsMapper,
|
||||
extract_layer_index,
|
||||
is_pp_missing_parameter,
|
||||
make_layers,
|
||||
@@ -1397,6 +1398,22 @@ class Gemma4Model(nn.Module, EagleModelMixin):
|
||||
class Gemma4ForCausalLM(
|
||||
nn.Module, SupportsLoRA, SupportsPP, MixtureOfExperts, SupportsEagle3
|
||||
):
|
||||
hf_to_vllm_mapper = WeightsMapper(
|
||||
orig_to_new_prefix={
|
||||
# Gemma4ForConditionalGeneration already loads the text stack
|
||||
# from `model.language_model.*`. We reuse that same checkpoint
|
||||
# and adapter naming for the text-only Gemma4ForCausalLM path,
|
||||
# so LoRA keys from the conditional wrapper map onto `model.*`.
|
||||
"model.language_model.": "model.",
|
||||
},
|
||||
orig_to_new_substr={
|
||||
# Gemma4ForConditionalGeneration names MoE adapter targets under
|
||||
# `...moe.experts.*`, while the text-only model exposes them
|
||||
# under `...moe.*`.
|
||||
".moe.experts.gate_up_proj": ".moe.gate_up_proj",
|
||||
".moe.experts.down_proj": ".moe.down_proj",
|
||||
},
|
||||
)
|
||||
# Note: qkv_proj packing applies to non-k_eq_v layers (sliding
|
||||
# attention and full attention without k_eq_v). k_eq_v layers use
|
||||
# separate q_proj + k_proj without packing.
|
||||
|
||||
Reference in New Issue
Block a user