From 3f0482174aa45e649c7d39e27878c3ce80b6d5cb Mon Sep 17 00:00:00 2001 From: roikoren755 <26850796+roikoren755@users.noreply.github.com> Date: Sun, 14 Dec 2025 21:08:48 +0200 Subject: [PATCH] Fix Mamba2-based models' default attention backend (#15117) Signed-off-by: Roi Koren --- python/sglang/srt/server_args.py | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/python/sglang/srt/server_args.py b/python/sglang/srt/server_args.py index afe93efd5..a669287b1 100644 --- a/python/sglang/srt/server_args.py +++ b/python/sglang/srt/server_args.py @@ -1286,6 +1286,29 @@ class ServerArgs: else: self.quantization = model_config.quantization self.moe_runner_backend = "flashinfer_cutlass" + if not self.disable_radix_cache: + logger.warning( + "Disabling overlap schedule since MambaRadixCache is not compatible with " + "overlap schedule currently, try to use --disable-radix-cache if overlap schedule is necessary" + ) + self.disable_overlap_schedule = True + if is_sm100_supported(): + if self.attention_backend is None: + self.attention_backend = "flashinfer" + logger.info( + "Use flashinfer as attention backend on sm100 for NemotronHForCausalLM" + ) + if self.attention_backend == "trtllm_mha": + logger.warning( + "Disabling radix cache since trtllm_mha does not support page_size = 1, which is required by MambaRadixCache. " + "Try to use --attention-backend triton if radix cache is necessary." + ) + self.disable_radix_cache = True + self.disable_overlap_schedule = False + assert self.attention_backend != "triton", ( + "NemotronHForCausalLM does not support triton attention backend," + "as the first layer might not be an attention layer" + ) elif model_arch in [ "Qwen3MoeForCausalLM", "Qwen3VLMoeForConditionalGeneration", @@ -1350,7 +1373,6 @@ class ServerArgs: self.disable_radix_cache = True self.disable_overlap_schedule = False elif model_arch in [ - "NemotronHForCausalLM", "FalconH1ForCausalLM", "JetNemotronForCausalLM", "JetVLMForConditionalGeneration", @@ -1361,6 +1383,19 @@ class ServerArgs: "overlap schedule currently, try to use --disable-radix-cache if overlap schedule is necessary" ) self.disable_overlap_schedule = True + if is_sm100_supported(): + if self.attention_backend is None: + self.attention_backend = "triton" + logger.info( + f"Use triton as attention backend on sm100 for {model_arch}" + ) + if self.attention_backend == "trtllm_mha": + logger.warning( + "Disabling radix cache since trtllm_mha does not support page_size = 1, which is required by MambaRadixCache. " + "Try to use --attention-backend triton if radix cache is necessary." + ) + self.disable_radix_cache = True + self.disable_overlap_schedule = False def _handle_sampling_backend(self): if self.sampling_backend is None: