Skip to content

fix: gemma 3 not use softcap #5622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions python/sglang/srt/configs/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def __init__(
logger.info(
"Multimodal is disabled for Llama4. To enable it, set --enable-llama4-multimodal."
)
elif self.hf_config.architectures[0] == "Gemma3ForConditionalGeneration":
enable_multimodal = False
logger.info(
"Multimodal is disabled for Gemma3. To enable it, set --enable-gemma3-multimodal."
)
else:
enable_multimodal = True

Expand Down
2 changes: 1 addition & 1 deletion python/sglang/srt/models/gemma3_causal.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __init__(
self.scaling,
num_kv_heads=self.num_kv_heads,
layer_id=layer_id,
logit_cap=getattr(self.config, "attn_logit_softcapping", None),
logit_cap=0.0,
# Module must also define `get_attention_sliding_window_size` to correctly initialize
# attention backend in `ForwardBatch`.
sliding_window_size=self.sliding_window,
Expand Down
11 changes: 10 additions & 1 deletion python/sglang/srt/server_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class ServerArgs:
disable_outlines_disk_cache: bool = False
disable_custom_all_reduce: bool = False
enable_llama4_multimodal: Optional[bool] = None
enable_gemma3_multimodal: Optional[bool] = None
disable_overlap_schedule: bool = False
enable_mixed_chunk: bool = False
enable_dp_attention: bool = False
Expand Down Expand Up @@ -285,7 +286,9 @@ def __post_init__(self):
if self.grammar_backend is None:
self.grammar_backend = "xgrammar"

self.enable_multimodal: Optional[bool] = self.enable_llama4_multimodal
self.enable_multimodal: Optional[bool] = (
self.enable_llama4_multimodal or self.enable_gemma3_multimodal
)

# Data parallelism attention
if self.enable_dp_attention:
Expand Down Expand Up @@ -984,6 +987,12 @@ def add_cli_args(parser: argparse.ArgumentParser):
action="store_true",
help="Enable the multimodal functionality for Llama-4.",
)
parser.add_argument(
"--enable-gemma3-multimodal",
default=ServerArgs.enable_gemma3_multimodal,
action="store_true",
help="Enable the multimodal functionality for Gemma-3.",
)
parser.add_argument(
"--disable-overlap-schedule",
action="store_true",
Expand Down
1 change: 1 addition & 0 deletions python/sglang/srt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,7 @@ def is_fa3_default_architecture(hf_config):
"LlamaForCausalLM",
"MistralForCausalLM",
"Gemma2ForCausalLM",
"Gemma3ForConditionalGeneration",
}
return architectures[0] in default_archs

Expand Down
Loading