From 05de73efd1ab6e7fa8218e51471bc0f674c22d36 Mon Sep 17 00:00:00 2001 From: Lucia Fang <116399278+luccafong@users.noreply.github.com> Date: Fri, 1 May 2026 15:49:30 -0700 Subject: [PATCH] [core/model] Use explicit model arch for Llama4 attention backend auto-selection (#24232) --- python/sglang/srt/server_args.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/sglang/srt/server_args.py b/python/sglang/srt/server_args.py index 8e30444ea..6b8ac5277 100644 --- a/python/sglang/srt/server_args.py +++ b/python/sglang/srt/server_args.py @@ -81,6 +81,10 @@ MIMO_V2_MODEL_ARCHS = ( "MiMoV2ForCausalLM", "MiMoV2FlashForCausalLM", ) +LLAMA4_MODEL_ARCHS = ( + "Llama4ForConditionalGeneration", + "Llama4ForCausalLM", +) SAMPLING_BACKEND_CHOICES = {"flashinfer", "pytorch", "ascend"} @@ -2034,7 +2038,7 @@ class ServerArgs: logger.warning( "Disable hybrid SWA memory for Step3p5ForCausalLM model with hierarchical cache" ) - elif "Llama4" in model_arch and self.device != "cpu": + elif model_arch in LLAMA4_MODEL_ARCHS and self.device != "cpu": # Auto-select attention backend for Llama4 if not specified if self.attention_backend is None: if is_sm100_supported():