{"record":{"id":"8da4be03f565c04b","repo":"sgl-project/sglang","slug":"aiter-is-required-when-sglang-use-aiter-is-set-to-8da4be","errorCode":null,"errorMessage":"aiter is required when SGLANG_USE_AITER is set to True","messagePattern":"aiter is required when SGLANG_USE_AITER is set to True","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/layers/moe/moe_runner/triton_utils/fused_moe.py","lineNumber":72,"sourceCode":"_use_aiter = get_bool_env_var(\"SGLANG_USE_AITER\") and _is_hip\n_is_xpu = is_xpu()\n_is_musa = is_musa()\n\n\nif _is_cuda:\n    from sgl_kernel import moe_sum_reduce\n\n    from sglang.kernels.ops.activation.activation import gelu_and_mul, silu_and_mul\nelif _is_cpu and _is_cpu_amx_available:\n    pass\nelif _is_hip:\n    from sgl_kernel import gelu_and_mul, silu_and_mul\n\n    if _use_aiter:\n        try:\n            from aiter import moe_sum\n        except ImportError:\n            raise ImportError(\"aiter is required when SGLANG_USE_AITER is set to True\")\n    # Note: vllm_ops is not needed for HIP when _use_aiter=False\n    # because the code uses moe_sum_reduce_triton as fallback (line 619)\nelif _is_xpu:\n    from sgl_kernel import moe_sum_reduce, silu_and_mul\nelif _is_musa:\n    from sgl_kernel import moe_sum_reduce\n\n    _silu_and_mul_musa = torch.nn.SwishGLU()\n\n# Try to import vllm_ops for non-CUDA/HIP/XPU platforms\n_has_vllm_ops = False\nif not _is_cuda and not _is_hip and not _is_xpu:\n    try:\n        from vllm import _custom_ops as vllm_ops\n\n        _has_vllm_ops = True\n    except ImportError:\n        # Fallback: vllm not available, will use native PyTorch implementations","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/moe_runner/triton_utils/fused_moe.py#L54-L90","documentation":"Raised at import time of the Triton fused MoE utilities when SGLANG_USE_AITER is truthy but the AMD-oriented aiter package cannot be imported. SGLang uses aiter's moe_sum kernel as the reduction path on ROCm/HIP when explicitly requested via env var. Missing aiter makes the module import fail entirely.","triggerScenarios":"Setting SGLANG_USE_AITER=1 (or True) on a ROCm/HIP build while the aiter package is not installed or not importable in the environment, then importing sglang.srt.layers.moe (any model load triggers it).","commonSituations":"Copying ROCm-tuned launch configs or benchmark scripts that set SGLANG_USE_AITER without installing aiter; aiter installed for a different ROCm/torch version so the import fails; running on CUDA machines with the env var left over from a previous shell.","solutions":["Install or repair aiter (pip install aiter / build from https://github.com/ROCm/aiter matching your ROCm and torch version) and verify `python -c \"from aiter import moe_sum\"`","Unset SGLANG_USE_AITER (or set to 0/false) if you don't need aiter — the code falls back to moe_sum_reduce_triton on HIP","Verify you are actually on an AMD/ROCm platform; on NVIDIA GPUs aiter is not applicable"],"exampleFix":"# before\nSGLANG_USE_AITER=1 python -m sglang.launch_server ...\n# ImportError: aiter is required when SGLANG_USE_AITER is set to True\n\n# after\npip install aiter  # ROCm-matched build\npython -c \"from aiter import moe_sum\"  # sanity check\n# or: unset SGLANG_USE_AITER","handlingStrategy":"validation","validationCode":"import os, importlib.util\nif os.environ.get(\"SGLANG_USE_AITER\", \"\").lower() in (\"1\",\"true\",\"yes\"):\n    assert importlib.util.find_spec(\"aiter\") is not None, \\\n        \"SGLANG_USE_AITER set but aiter not installed; unset it or pip install aiter\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Scope ROCm-specific env vars to the launch script that needs them","Smoke-test `from aiter import moe_sum` in CI for any ROCm image that sets SGLANG_USE_AITER"],"tags":["moe","rocm","aiter","import-error","env-var","amd"],"backgroundTag":"missing-optional-dependency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}