sgl-project/sglang · error · NotImplementedError
forward() is not supported in encoder_only mode. Use get_aud
Error message
forward() is not supported in encoder_only mode. Use get_audio_feature() instead.
What it means
The MiMo-v2 ASR outer wrapper refuses forward() when config.encoder_only is set, because in encoder-only mode there is no LM head / decode path; audio must be encoded via get_audio_feature().
Source
Thrown at python/sglang/srt/models/mimo_v2_asr.py:79
return pattern.pad_input_tokens(input_ids, mm_inputs)
def get_input_embeddings(self):
if getattr(self.config, "encoder_only", False):
return None
return self.model.embed_tokens
@torch.no_grad()
def forward(
self,
input_ids: torch.Tensor,
positions: torch.Tensor,
forward_batch: ForwardBatch,
input_embeds: torch.Tensor = None,
get_embedding: bool = False,
pp_proxy_tensors: Optional[PPProxyTensors] = None,
) -> torch.Tensor:
if getattr(self.config, "encoder_only", False):
raise NotImplementedError(
"forward() is not supported in encoder_only mode. "
"Use get_audio_feature() instead."
)
hidden_states = general_mm_embed_routine(
input_ids=input_ids,
forward_batch=forward_batch,
language_model=self.model,
multimodal_model=self,
positions=positions,
pp_proxy_tensors=pp_proxy_tensors,
)
if not get_embedding:
return self.logits_processor(
input_ids, hidden_states, self.lm_head, forward_batch
)
return self.pooler(hidden_states, forward_batch)View on GitHub (pinned to 0132848349)
Solutions
- Call get_audio_feature() (the audio embedding path) instead of forward()
- If you intended full ASR generation, remove "encoder_only": true from the config
- Route through the multimodal/audio-specific serving path that already uses get_audio_feature
Example fix
# before out = model.forward(input_ids, positions, forward_batch) # after audio_feats = model.get_audio_feature(input_audio, ...)
Defensive patterns
Strategy: type-guard
Validate before calling
if getattr(model.config, 'encoder_only', False):
feats = model.get_audio_feature(audio_input)
else:
out = model.forward(...) Type guard
def is_encoder_only(model) -> bool:
return bool(getattr(model.config, 'encoder_only', False)) Try / catch
try:
model.forward(...)
except NotImplementedError as e:
if 'encoder_only' in str(e):
feats = model.get_audio_feature(audio_input)
else:
raise Prevention
- Branch on config.encoder_only before dispatching forward
- Use the multimodal serving path for audio-only models
When it happens
Trigger: Calling model.forward(...) (or a generic runner path) on MiMoV2ASR with config.encoder_only=True in the checkpoint config.
Common situations: Using the ASR model class standalone as an audio encoder (e.g. embedding service) but invoking the standard causal-LM forward path; misrouted pipelines.
Related errors
- unsupported audio item: loaded={loaded_type}, raw={raw_type}
- Multimodal data is corrupted or cannot be decoded: {e}
- Missing previous frame for delta payload
- kernel dispatch requires at least one tensor argument
- cos/sin shape does not cover image tokens and head_dim
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/820e1d760d273c42.
Report an issue: GitHub.