{"record":{"id":"88c7ee573005d4b0","repo":"sgl-project/sglang","slug":"unsupported-mode","errorCode":null,"errorMessage":"unsupported mode","messagePattern":"unsupported mode","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/moe/token_dispatcher/deepep.py","lineNumber":331,"sourceCode":"    @classmethod\n    def set_dispatch_mode_as_normal(cls):\n        cls._state().dispatch_mode = DeepEPDispatchMode.NORMAL\n\n    @classmethod\n    def set_dispatch_mode_as_low_latency(cls):\n        state = cls._state()\n        if state.dispatch_mode == DeepEPDispatchMode.NORMAL:\n            cls.clean_buffer()\n        state.dispatch_mode = DeepEPDispatchMode.LOW_LATENCY\n\n    @classmethod\n    def set_dispatch_mode(cls, mode: DeepEPMode):\n        if mode.is_low_latency():\n            cls.set_dispatch_mode_as_low_latency()\n        elif mode.is_normal():\n            cls.set_dispatch_mode_as_normal()\n        else:\n            raise Exception(\"unsupported mode\")\n\n\nclass DeepEPConfig(BaseDispatcherConfig):\n    _instance = None\n\n    def __init__(self):\n        config_str = get_deepep_config()\n        if config_str:\n            config_parsed = load_json_config(config_str)\n            if torch.distributed.get_rank() == 0:\n                logger.info(f\"Use DeepEP Config: {config_parsed}\")\n            config_dispatch = config_parsed[\"normal_dispatch\"]\n            config_combine = config_parsed[\"normal_combine\"]\n\n            self.normal_dispatch_config = Config(**config_dispatch)\n            self.normal_combine_config = Config(**config_combine)\n\n            assert config_dispatch[\"num_sms\"] == config_combine[\"num_sms\"]","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/token_dispatcher/deepep.py#L313-L349","documentation":"DeepEP dispatcher's classmethod set_dispatch_mode routes only two modes — low-latency and normal — and raises a bare Exception for anything else. Since DeepEPMode should always be one of these (AUTO resolves earlier), hitting this indicates an out-of-sync or corrupted enum value, a custom mode, or a stale DeepEPMode across versions. Called during CUDA-graph capture and replay.","triggerScenarios":"Invoking DeepEPTokenDispatcher.set_dispatch_mode(mode) with a DeepEPMode that is neither .is_low_latency() nor .is_normal() — e.g. an AUTO value that wasn't resolved, or a custom/int enum from a different SGLang version mixed into a pickle/graph capture path.","commonSituations":"CUDA graph capture with a stale dispatcher class state after upgrading SGLang mid-checkpoint; monkey-patched or custom DeepEPMode subclasses; mixed-version imports in the same process.","solutions":["Upgrade/align to a single SGLang version so DeepEPMode enum and dispatcher match","Ensure the mode passed is a resolved DeepEPMode.NORMAL or LOW_LATENCY (resolve AUTO before capture)","If you maintain a custom mode, extend set_dispatch_mode to handle it instead of relying on upstream"],"exampleFix":"# before\nDeepEPTokenDispatcher.set_dispatch_mode(DeepEPMode.AUTO)  # raises 'unsupported mode'\n\n# after\nDeepEPTokenDispatcher.set_dispatch_mode(deepep_mode.resolve(is_extend_in_batch))","handlingStrategy":"validation","validationCode":"from sglang.srt.layers.moe.token_dispatcher.deepep import DeepEPMode\nm = deepep_mode.resolve(is_extend_in_batch) if deepep_mode == DeepEPMode.AUTO else deepep_mode\nassert m in (DeepEPMode.NORMAL, DeepEPMode.LOW_LATENCY)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve AUTO modes before CUDA-graph capture/replay","Pin a single SGLang version across the process to avoid enum skew"],"tags":["deepep","moe","dispatcher","enum","cuda-graph"],"backgroundTag":"unsupported-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}