{"record":{"id":"f71591566cdea777","repo":"sgl-project/sglang","slug":"num-fused-shared-experts-1-self-num-fused-shar","errorCode":null,"errorMessage":"num_fused_shared_experts > 1 ({self.num_fused_shared_experts}) is not supported on CUDA platform. The current TopK implementation only handles one fused shared expert. AMD platform with aiter supports multiple shared experts.","messagePattern":"num_fused_shared_experts > 1 \\((.+?)\\) is not supported on CUDA platform\\. The current TopK implementation only handles one fused shared expert\\. AMD platform with aiter supports multiple shared experts\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/models/bailing_moe_v3.py","lineNumber":1456,"sourceCode":"                        \"--disable-shared-experts-fusion to use padding solution instead.\"\n                    )\n        return None\n\n    def determine_num_fused_shared_experts(self):\n        self.num_fused_shared_experts = (\n            0\n            if is_shared_experts_fusion_disabled()\n            else getattr(self.config, \"num_shared_experts\", 0)\n        )\n        if self.num_fused_shared_experts == 0:\n            return\n\n        # Safety check: current CUDA implementation only supports num_fused_shared_experts == 1.\n        # The grouped_topk_gpu and _post_process_topk_ids functions only handle the last column,\n        # which is incorrect when num_fused_shared_experts > 1.\n        # AMD platform with aiter handles this correctly via fused_append_shared_experts kernel.\n        if self.num_fused_shared_experts > 1 and not _is_hip:\n            raise ValueError(\n                f\"num_fused_shared_experts > 1 ({self.num_fused_shared_experts}) is not \"\n                f\"supported on CUDA platform. The current TopK implementation only handles \"\n                f\"one fused shared expert. AMD platform with aiter supports multiple shared experts.\"\n            )\n\n        moe_ep_size = get_parallel().moe_ep_size\n        if moe_ep_size > 1:\n            log_info_on_rank0(\n                logger,\n                f\"Shared experts fusion optimization is enabled with {self.num_fused_shared_experts} fused shared expert(s) under EP mode (ep_size={moe_ep_size}). \"\n                f\"Shared experts will be distributed across GPUs along with routed experts.\",\n            )\n        else:\n            log_info_on_rank0(\n                logger,\n                f\"Shared experts fusion optimization is enabled with {self.num_fused_shared_experts} fused shared expert(s).\",\n            )\n","sourceCodeStart":1438,"sourceCodeEnd":1474,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/bailing_moe_v3.py#L1438-L1474","documentation":"For Bailing v3, fusing shared experts into the TopK output is only implemented for one shared expert on CUDA; grouped_topk_gpu/_post_process_topk_ids only handle the last ids column. Multiple fused shared experts only work on AMD with the aiter kernel.","triggerScenarios":"Loading a Bailing v3 config with num_fused_shared_experts > 1 on an NVIDIA GPU (not HIP).","commonSituations":"Taking a config tuned for AMD/aiter and running it on CUDA; models with 2+ shared experts enabled for fusion.","solutions":["Set num_fused_shared_experts to 1 (or 0) in config.json / disable shared-expert fusion on CUDA","Run on AMD with aiter if multiple fused shared experts are required","Upgrade SGLang in case multi-fused support was added for CUDA later"],"exampleFix":"// before\n\"num_fused_shared_experts\": 2\n// after\n\"num_fused_shared_experts\": 1","handlingStrategy":"validation","validationCode":"import torch\nassert getattr(config, \"num_fused_shared_experts\", 1) <= 1 or torch.version.hip","typeGuard":null,"tryCatchPattern":null,"preventionTips":["On CUDA keep num_fused_shared_experts <= 1","Reserve multi-shared-expert fusion for AMD+aiter"],"tags":["moe","shared-experts","cuda","platform-limit","bailing"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}