Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions python/sglang/srt/server_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,8 @@ def _handle_model_specific_adjustments(self):
if parse_connector_type(self.model_path) == ConnectorType.INSTANCE:
return

hf_config = self.get_model_config().hf_config
model_config = self.get_model_config()
hf_config = model_config.hf_config
model_arch = hf_config.architectures[0]

_hybrid_spec = get_linear_attn_spec_by_arch(model_arch)
Expand Down Expand Up @@ -2366,8 +2367,17 @@ def _handle_model_specific_adjustments(self):
"Gemma4ForCausalLM",
"Gemma4UnifiedForConditionalGeneration",
):
is_gemma4_modelopt_fp4 = model_config.quantization == "modelopt_fp4"
is_gemma4_moe = getattr(
model_config.hf_text_config, "enable_moe_block", False
)
is_gemma4_modelopt_fp4_moe = is_gemma4_modelopt_fp4 and is_gemma4_moe
# TODO: switch Gemma4 modelopt_fp4 MoE back to trtllm_mha by default
# after the SM10X trtllm_mha accuracy issue is fixed.
default_attention_backend = (
"trtllm_mha" if is_sm100_supported() else "triton"
"trtllm_mha"
if is_sm100_supported() and not is_gemma4_modelopt_fp4_moe
else "triton"
)
if self.is_attention_backend_not_set():
self.attention_backend = default_attention_backend
Expand All @@ -2392,7 +2402,7 @@ def _handle_model_specific_adjustments(self):
)

if is_sm100_supported() and self.moe_runner_backend == "auto":
if self.get_model_config().quantization == "modelopt_fp4":
if is_gemma4_modelopt_fp4:
self.quantization = "modelopt_fp4"
self.moe_runner_backend = "flashinfer_trtllm"
logger.info(
Expand Down
Loading