{"record":{"id":"0be5dc8270495114","repo":"sgl-project/sglang","slug":"audio-projection-mode-audio-projection-mode-no","errorCode":null,"errorMessage":"audio_projection_mode = {audio_projection_mode} not implemented","messagePattern":"audio_projection_mode = (.+?) not implemented","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/phi4mm_audio.py","lineNumber":1236,"sourceCode":"                    audio_features,\n                    (0, 0, 0, self.linear_downsample_rate - padding),\n                    \"constant\",\n                    0,\n                )\n\n            seq_len = audio_features.size(1)\n            audio_features = audio_features.view(\n                bs,\n                seq_len // self.linear_downsample_rate,\n                feat_dim * self.linear_downsample_rate,\n            )\n\n        if audio_projection_mode == \"speech\":\n            audio_set_tensor = self.audio_projection(audio_features)\n        elif audio_projection_mode == \"vision\":\n            audio_set_tensor = self.audio_projection_for_vision(audio_features)\n        else:\n            raise ValueError(\n                f\"audio_projection_mode = {audio_projection_mode} not \" \"implemented\"\n            )\n\n        return audio_set_tensor\n\n    def forward(\n        self,\n        audio_features: torch.FloatTensor,\n        audio_attention_mask: torch.Tensor = None,\n        audio_projection_mode: str = \"speech\",\n    ) -> torch.FloatTensor:\n        \"\"\"\n        arguments:\n            audio_features: audio features (num_audio_tokens, T, D)\n\n        returns:\n            audio_embeds: audio embeddings (num_audio_tokens, hidden_dim)\n        \"\"\"","sourceCodeStart":1218,"sourceCodeEnd":1254,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/phi4mm_audio.py#L1218-L1254","documentation":"get_audio_features dispatches on audio_projection_mode and only supports 'speech' (self.audio_projection) and 'vision' (self.audio_projection_for_vision). Any other mode string raises ValueError at runtime during forward of the audio tower.","triggerScenarios":"Calling forward on the Phi-4-MM audio model when the audio tower was configured with an audio_projection_mode other than 'speech' or 'vision'; the mode typically comes from the multimodal projector config or is hardcoded at call sites.","commonSituations":"A vision-language call path routed into the audio tower with the wrong mode string; fine-tuned models introducing a new projection mode; typos like 'Speech' or 'vision ' in configs.","solutions":["Ensure the caller passes audio_projection_mode of exactly 'speech' or 'vision'","Check where get_audio_features is invoked (forward) and fix the mode propagation from config","Normalize/lowercase the mode string before dispatch if case drift is possible"],"exampleFix":"# before\naudio_set_tensor = model.get_audio_features(audio_features, mode=\"text\")\n# after\naudio_set_tensor = model.get_audio_features(audio_features, mode=\"speech\")","handlingStrategy":"type-guard","validationCode":"assert audio_projection_mode in (\"speech\", \"vision\"), f\"bad mode: {audio_projection_mode}\"","typeGuard":"def is_valid_audio_projection_mode(mode: str) -> bool:\n    return mode in (\"speech\", \"vision\")","tryCatchPattern":"try:\n    feats = model.get_audio_features(audio_features, mode)\nexcept ValueError as e:\n    if \"audio_projection_mode\" in str(e):\n        raise ValueError(\"mode must be 'speech' or 'vision'\") from e\n    raise","preventionTips":["Centralize the mode string as a constant/enum instead of passing raw strings","Validate mode at the call site in forward before dispatch"],"tags":["phi4","audio","runtime-dispatch","value-error"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}