sgl-project/sglang · error · ValueError
Unknown forward method: {forward_method}
Error message
Unknown forward method: {forward_method} What it means
Raised by SarvamMoE attention forward when the attention layer is dispatched with a forward method name that matches none of the supported branches (e.g. full/MLA-style paths selected by forward_method). The model implementation only implements a fixed set of forward paths, so any other string is a programming or configuration error rather than a runtime data problem.
Source
Thrown at python/sglang/srt/models/sarvam_moe.py:817
attn_output = self.attn_mqa(
q_nope_out,
k_nope,
k_nope,
forward_batch,
q_rope=q_pe,
k_rope=k_pe,
)
elif forward_method == AttnForwardMethod.MLA_CONCAT_ROPE:
q = torch.cat([q_nope_out, q_pe], dim=-1)
k = torch.cat([k_nope, k_pe], dim=-1)
attn_output = self.attn_mqa(
q,
k,
k_nope,
forward_batch,
)
else:
raise ValueError(f"Unknown forward method: {forward_method}")
attn_output = attn_output.view(-1, self.num_local_heads, self.kv_lora_rank)
attn_bmm_output = self._maybe_fp8_bmm(
attn_output.transpose(0, 1), self.w_vc, zero_allocator
)
attn_bmm_output = attn_bmm_output.transpose(0, 1).flatten(1, 2)
output, _ = self.o_proj(attn_bmm_output)
return output
def forward_prepare(
self,
positions: torch.Tensor,
hidden_states: torch.Tensor,
forward_batch: ForwardBatch,
zero_allocator: Optional[BumpAllocator] = None,
llama_4_scaling: Optional[torch.Tensor] = None,
) -> Tuple[Optional[torch.Tensor], ForwardBatch, Optional[Tuple]]:View on GitHub (pinned to 0132848349)
Solutions
- Check the server/attention backend flags (--attention-backend) and switch to one supported by sarvam-moe
- Update sglang to a version where sarvam_moe.py supports the forward method being requested
- If running a fork, inspect the if/elif chain above line 817 and add a branch for the missing forward_method
Example fix
# before python -m sglang.launch_server --model sarvam-moe --attention-backend some_new_backend # after python -m sglang.launch_server --model sarvam-moe --attention-backend fa3
Defensive patterns
Strategy: validation
Validate before calling
from sglang.srt.models.sarvam_moe import SUPPORTED # if exposed; otherwise read source
# before launch: assert chosen attention backend is in the model's supported set
assert attention_backend in {"fa3", "flashinfer", "triton", "torch_native"}, attention_backend Prevention
- Pin sglang version and launch scripts together
- Check server logs at startup for which forward path the model selected
When it happens
Trigger: Calling the SarvamMoE attention module's forward with a forward_method value not recognized by the if/elif chain in python/sglang/srt/models/sarvam_moe.py:817 (e.g. a new backend name passed from model config or a custom patch that renames methods).
Common situations: Using an unsupported attention backend with sarvam-moe, mixing model code versions where a newer scheduler passes a method name the installed model file doesn't know, or typos in custom forks that add a forward method selection string.
Related errors
- Sparse Video Gen 2 attention does not support causal attenti
- {selection_error}{component_suffix}
- Attention backend name must be a string
- Invalid attention backend '{backend}'. Available options are
- component_attention_backends must be a dict or a comma-separ
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/7978a9f71dca6772.
Report an issue: GitHub.