{"record":{"id":"cbbb6c44448cc192","repo":"sgl-project/sglang","slug":"torchaudio-is-required-for-audio-inputs-install-t","errorCode":null,"errorMessage":"torchaudio is required for audio inputs; install torchaudio","messagePattern":"torchaudio is required for audio inputs; install torchaudio","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/mimo_audio.py","lineNumber":148,"sourceCode":"            f_max=audio_fmax,\n            n_mels=audio_n_mels,\n            power=1.0,\n            center=True,\n        )\n        self._mel_spectrogram = None\n        self._resamplers: OrderedDict[int, torchaudio.transforms.Resample] = (\n            OrderedDict()\n        )\n        self._resamplers_max = max_resamplers\n\n    @property\n    def audio_token_per_second(self) -> float:\n        return self.audio_input_id_per_second / self.audio_group_size\n\n    @staticmethod\n    def _ensure_audio_dependencies() -> None:\n        if torchaudio is None or MelSpectrogram is None:\n            raise RuntimeError(\n                \"torchaudio is required for audio inputs; install torchaudio\"\n            )\n\n    @property\n    def mel_spectrogram(self):\n        self._ensure_audio_dependencies()\n        if self._mel_spectrogram is None:\n            self._mel_spectrogram = MelSpectrogram(**self.mel_spectrogram_kwargs)\n        return self._mel_spectrogram\n\n    def compute_audio_token_len(self, mel_len: int) -> int:\n        n = mel_len + 3 - self.audio_kernel_size\n        n = (n + 2 - self.audio_kernel_size) // self.audio_stride_size + 1\n        n = n // self.audio_avg_pooler + int(n % self.audio_avg_pooler != 0)\n        return math.ceil(n / self.audio_group_size)\n\n    def preprocess_audio(self, audio):\n        \"\"\"Load audio source → log-mel spectrogram + token length.","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/mimo_audio.py#L130-L166","documentation":"MiMo audio preprocessing needs torchaudio (and its MelSpectrogram transform) to compute mel spectrograms from audio. Neither is importable in the current environment, so any audio input path fails at dependency check.","triggerScenarios":"Calling mel_spectrogram or preprocess_audio on the MiMo audio pipeline when torchaudio was not installed or failed to import (e.g. version mismatch with torch).","commonSituations":"Installing sglang without the audio extras; a torch/torchaudio version mismatch causing a silent import failure recorded as None; slim Docker images omitting torchaudio.","solutions":["pip install torchaudio matching your torch version (e.g. torchaudio==<torch version>)","If import fails despite installation, align torchaudio with the installed torch/torchvision/CUDA versions","Use an image/deployment that includes audio dependencies when serving audio-capable models"],"exampleFix":"# before: RuntimeError torchaudio is required\n# after\npip install torchaudio==2.5.1  # match your torch==2.5.1","handlingStrategy":"fallback","validationCode":"try:\n    import torchaudio  # noqa\n    AVAILABLE = True\nexcept ImportError:\n    AVAILABLE = False\nif not AVAILABLE: raise SystemExit(\"install torchaudio\")","typeGuard":null,"tryCatchPattern":"try: run audio request except RuntimeError as e: if 'torchaudio' in str(e): prompt to install / route to text-only","preventionTips":["Install torchaudio matched to your torch version when serving audio models","Smoke-test the audio path at server startup"],"tags":["multimodal","audio","missing-dependency","mimo"],"backgroundTag":"missing-optional-dependency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}