{"record":{"id":"c5d5391350a1b45f","repo":"sgl-project/sglang","slug":"unsupported-modality-for-epd-preprocessing-modal","errorCode":null,"errorMessage":"Unsupported modality for EPD preprocessing: {modality}","messagePattern":"Unsupported modality for EPD preprocessing: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/mimo_v2.py","lineNumber":638,"sourceCode":"                result[\"video_audio_segment_lens_flat\"] = seg_lens_flat\n                result[\"video_audio_segment_starts_flat\"] = seg_starts_flat\n                result[\"video_audio_per_video_num_units\"] = per_video_num_units\n            return result\n\n        if modality == Modality.AUDIO:\n            all_specs, all_lens = [], []\n            for audio in mm_data:\n                if isinstance(audio, np.ndarray):\n                    audio = (torch.from_numpy(audio).float(), self.audio_sampling_rate)\n                spec, token_len = self.audio_pipeline.preprocess_audio(audio)\n                all_specs.append(spec)\n                all_lens.append(token_len)\n            return {\n                \"input_features\": all_specs,\n                \"audio_feature_lens_raw\": torch.tensor(all_lens, dtype=torch.long),\n            }\n\n        raise ValueError(f\"Unsupported modality for EPD preprocessing: {modality}\")\n\n    def prepare_image_kwargs(self, image: ImageInput):\n        kwargs = {}\n        for k in [\"min_pixels\", \"max_pixels\"]:\n            if getattr(image, k) is not None:\n                kwargs[k] = getattr(image, k)\n            else:\n                kwargs[k] = self.default_image_processor_kwargs[k]\n        return kwargs\n\n    def prepare_video_kwargs(self, video: VideoInput | VideoAudioInput):\n        kwargs = {}\n        for k in [\"min_pixels\", \"max_pixels\", \"total_max_pixels\"]:\n            if getattr(video, k) is not None:\n                kwargs[k] = getattr(video, k)\n            else:\n                kwargs[k] = self.default_video_processor_kwargs[k]\n        if video.num_frames is not None:","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/mimo_v2.py#L620-L656","documentation":"Raised at the end of preprocess_for_encoder in MiMo-V2 when the requested modality is neither image nor audio (the two branches handled above). It is a terminal dispatch guard: any modality value that falls through the if/elif chain hits this ValueError.","triggerScenarios":"Calling preprocess_mm_for_encoder with Modality.VIDEO (or any modality other than IMAGE/AUDIO) — the EPD preprocessing path only implements image and audio branches, so video (or an unknown enum member) reaches the raise.","commonSituations":"Routing video through the EPD encoder path before video support was added; enum extensions adding new modalities without updating this dispatcher; internal callers passing modality as a raw string that doesn't match either branch.","solutions":["Confirm the modality you pass is Modality.IMAGE or Modality.AUDIO; route video inputs through the video pipeline (process_video) instead","If you control the caller, add an explicit branch/guard so unsupported modalities are rejected earlier with a clearer message","Upgrade sglang — a newer MiMo-V2 processor may implement the missing modality branch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from sglang.srt.multimodal.media import Modality\nassert modality in (Modality.IMAGE, Modality.AUDIO), f'EPD supports IMAGE/AUDIO only, got {modality}'","typeGuard":"def is_epd_modality(m) -> bool:\n    return m in (Modality.IMAGE, Modality.AUDIO)","tryCatchPattern":"try:\n    feats = proc.preprocess_mm_for_encoder(modality, items)\nexcept ValueError as e:\n    if 'Unsupported modality' in str(e):\n        route_to_non_epd_path(items)\n    else:\n        raise","preventionTips":["Keep a whitelist of supported modalities per pipeline in client code","Route video through process_video explicitly","Pin sglang version so modality support surface is known"],"tags":["modality","dispatch","input-validation","multimodal"],"backgroundTag":"unsupported-modality","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}