diff --git a/quark/torch/quantization/config/algo_configs.py b/quark/torch/quantization/config/algo_configs.py index 4f258213f..a376ed3e5 100755 --- a/quark/torch/quantization/config/algo_configs.py +++ b/quark/torch/quantization/config/algo_configs.py @@ -561,6 +561,21 @@ ], model_decoder_layers="model.language_model.layers", ), + "gemma4": GPTQConfig( + inside_layer_modules=[ + "self_attn.k_proj", + "self_attn.v_proj", + "self_attn.q_proj", + "self_attn.o_proj", + "mlp.up_proj", + "mlp.gate_proj", + "mlp.down_proj", + "experts.*.up_proj", + "experts.*.gate_proj", + "experts.*.down_proj", + ], + model_decoder_layers="model.language_model.layers", + ), "gpt_oss": GPTQConfig( inside_layer_modules=[ "self_attn.q_proj", diff --git a/quark/torch/quantization/config/template.py b/quark/torch/quantization/config/template.py index 99a040a37..373e29927 100644 --- a/quark/torch/quantization/config/template.py +++ b/quark/torch/quantization/config/template.py @@ -710,6 +710,7 @@ def get(cls, model_type: str) -> LLMTemplate: - gemma2 - gemma3 - gemma3_text + - gemma4 - glm4_moe - glm4_moe_lite - glm_moe_dsa @@ -1096,6 +1097,31 @@ def _set_layer_type_config(self, config: QConfig, layer_type_config: dict[type[n "q_layer_name": "*q_proj", "exclude_layers_name": ["*lm_head"], }, + "gemma4": { + "kv_layers_name": ["*language_model.*k_proj", "*language_model.*v_proj"], + "q_layer_name": "*language_model.*q_proj", + "exclude_layers_name": [ + "*vision_tower*", + "*embed_vision*", + "*audio_tower*", + "*embed_audio*", + "*multi_modal_projector*", + "*lm_head", + "*router.proj", + ], + "f2f_weight_converters": [ + WeightConverter( + "gate_up_proj", + ["gate_proj.weight", "up_proj.weight"], + operations=[SplitFusedExperts(split_axis=0)], + ), + WeightConverter( + "down_proj", + ["down_proj.weight"], + operations=[SplitFusedExperts(split_axis=0)], + ), + ], + }, "glm4_moe": { "kv_layers_name": ["*k_proj", "*v_proj"], "q_layer_name": "*q_proj",