{"record":{"id":"820e1d760d273c42","repo":"sgl-project/sglang","slug":"forward-is-not-supported-in-encoder-only-mode-u","errorCode":null,"errorMessage":"forward() is not supported in encoder_only mode. Use get_audio_feature() instead.","messagePattern":"forward\\(\\) is not supported in encoder_only mode\\. Use get_audio_feature\\(\\) instead\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/mimo_v2_asr.py","lineNumber":79,"sourceCode":"        return pattern.pad_input_tokens(input_ids, mm_inputs)\n\n    def get_input_embeddings(self):\n        if getattr(self.config, \"encoder_only\", False):\n            return None\n        return self.model.embed_tokens\n\n    @torch.no_grad()\n    def forward(\n        self,\n        input_ids: torch.Tensor,\n        positions: torch.Tensor,\n        forward_batch: ForwardBatch,\n        input_embeds: torch.Tensor = None,\n        get_embedding: bool = False,\n        pp_proxy_tensors: Optional[PPProxyTensors] = None,\n    ) -> torch.Tensor:\n        if getattr(self.config, \"encoder_only\", False):\n            raise NotImplementedError(\n                \"forward() is not supported in encoder_only mode. \"\n                \"Use get_audio_feature() instead.\"\n            )\n\n        hidden_states = general_mm_embed_routine(\n            input_ids=input_ids,\n            forward_batch=forward_batch,\n            language_model=self.model,\n            multimodal_model=self,\n            positions=positions,\n            pp_proxy_tensors=pp_proxy_tensors,\n        )\n\n        if not get_embedding:\n            return self.logits_processor(\n                input_ids, hidden_states, self.lm_head, forward_batch\n            )\n        return self.pooler(hidden_states, forward_batch)","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/mimo_v2_asr.py#L61-L97","documentation":"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().","triggerScenarios":"Calling model.forward(...) (or a generic runner path) on MiMoV2ASR with config.encoder_only=True in the checkpoint config.","commonSituations":"Using the ASR model class standalone as an audio encoder (e.g. embedding service) but invoking the standard causal-LM forward path; misrouted pipelines.","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"],"exampleFix":"# before\nout = model.forward(input_ids, positions, forward_batch)\n# after\naudio_feats = model.get_audio_feature(input_audio, ...)","handlingStrategy":"type-guard","validationCode":"if getattr(model.config, 'encoder_only', False):\n    feats = model.get_audio_feature(audio_input)\nelse:\n    out = model.forward(...)","typeGuard":"def is_encoder_only(model) -> bool:\n    return bool(getattr(model.config, 'encoder_only', False))","tryCatchPattern":"try:\n    model.forward(...)\nexcept NotImplementedError as e:\n    if 'encoder_only' in str(e):\n        feats = model.get_audio_feature(audio_input)\n    else:\n        raise","preventionTips":["Branch on config.encoder_only before dispatching forward","Use the multimodal serving path for audio-only models"],"tags":["asr","encoder-only","api-misuse","multimodal"],"backgroundTag":"unsupported-operation-mode","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}