fix(moe): gate fp8 megamoe on deepgemm capability
Some checks failed
CI Failure Monitor / failure-analysis (push) Has been cancelled
Release PyPI Nightly Wheels / build-nightly-wheel (push) Has been cancelled
Release PyPI Nightly Wheels / release-nightly (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Nightly Release SGLang Model Gateway to PyPI / Upload to TestPyPI (push) Has been cancelled
CI Coverage Overview / Summary (push) Has been cancelled
CI Coverage Overview / Tests by Folder (push) Has been cancelled
CI Coverage Overview / Tests by Suite (push) Has been cancelled
CI Coverage Overview / Unit Test Code Coverage (push) Has been cancelled
CI Coverage Overview / JSON Export (push) Has been cancelled
Runner Utilization Report / Generate Report (push) Has been cancelled
Release Docker Images ROCm 7.2.0 Nightly Preview (AMD) / publish (all, gfx942-rocm720) (push) Has been cancelled
Release Docker Images ROCm 7.2.0 Nightly Preview (AMD) / publish (all, gfx950-rocm720) (push) Has been cancelled
Release Docker Images Nightly (AMD) / publish (all, gfx942) (push) Has been cancelled
Release Docker Images Nightly (AMD) / publish (all, gfx950) (push) Has been cancelled
Release Docker Images Nightly (AMD) / cache (all, gfx942) (push) Has been cancelled
AMD AITER Scout / resolve-aiter (push) Has been cancelled
AMD AITER Scout / call-nightly-amd (push) Has been cancelled
AMD AITER Scout / call-nightly-amd-rocm720 (push) Has been cancelled
AMD AITER Scout / call-pr-test-amd (push) Has been cancelled
AMD AITER Scout / call-pr-test-amd-rocm720 (push) Has been cancelled
AMD AITER Scout / check-all-jobs (push) Has been cancelled
Release Docker Images Nightly (NPU) / build (8.5.0, 910b) (push) Has been cancelled
Release Docker Images Nightly (NPU) / build (8.5.0, a3) (push) Has been cancelled
Build and Push Development Docker Images / build-dev (arm64, all, 1, linux/arm64, arm-docker-build-node, 12.9.1) (push) Has been cancelled
Build and Push Development Docker Images / build-dev (arm64-cu13, all, 1, linux/arm64, arm-docker-build-node, 13.0.1) (push) Has been cancelled
Build and Push Development Docker Images / build-dev (x86, all, 0, linux/amd64, x64-docker-build-node, 12.9.1) (push) Has been cancelled
Build and Push Development Docker Images / build-dev (x86-cu13, all, 0, linux/amd64, x64-docker-build-node, 13.0.1) (push) Has been cancelled
Build and Push Development Docker Images / create-manifests (map[arm64:arm64 base:dev x86:x86]) (push) Has been cancelled
Build and Push Development Docker Images / create-manifests (map[arm64:arm64-cu13 base:dev-cu13 x86:x86-cu13]) (push) Has been cancelled
Close Inactive Issues / close-inactive-issues (push) Has been cancelled
AMD CI Job Monitor / Custom Job Report (push) Has been cancelled
AMD CI Job Monitor / Parse Workflow Jobs (push) Has been cancelled
AMD CI Job Monitor / PR - ${{ matrix.job_name }} (push) Has been cancelled
AMD CI Job Monitor / Nightly - ${{ matrix.job_name }} (push) Has been cancelled
Weekly Test (Nvidia) / weekly-test-8-gpu-h200 (push) Has been cancelled

Avoid entering the FP8 MegaMoE fused path when the installed DeepGEMM exposes fp8_mega_moe but cannot allocate an fp8xfp8 MegaMoE symmetric buffer. Current B300 sgl-deep-gemm asserts that MegaMoE buffer mma_type is fp8xfp4, so FP8 weights must fall back until dependency support lands.

Tested: PYTHONPYCACHEPREFIX=/private/tmp/sglang_pycache python3 -m py_compile python/sglang/srt/layers/moe/mega_moe.py test/registered/unit/moe/test_glm_megamoe.py

Tested: git diff --check

Remote-tested: root@95.133.252.48 B300 DeepGEMM capability probe showed fp8xfp8 MegaMoE buffer fails with mma_type_str == fp8xfp4.
This commit is contained in:
LuminolT
2026-07-08 12:05:46 +08:00
parent 89ba17ad05
commit ebf11be355
2 changed files with 13 additions and 2 deletions

View File

@@ -91,6 +91,17 @@ def _get_mega_moe_symm_buffer(
return buf return buf
def _deep_gemm_supports_fp8_mega_moe() -> bool:
if not deep_gemm_wrapper.ENABLE_JIT_DEEPGEMM:
return False
if not torch.cuda.is_available():
return False
# Current sgl-deep-gemm exposes fp8_mega_moe, but its Blackwell MegaMoE
# symmetric buffer only accepts fp8xfp4. SM90 uses a separate buffer path
# that can back fp8_mega_moe.
return torch.cuda.get_device_capability()[0] == 9
def should_use_mega_moe(moe, hidden_states: torch.Tensor) -> bool: def should_use_mega_moe(moe, hidden_states: torch.Tensor) -> bool:
if not get_moe_a2a_backend().is_megamoe(): if not get_moe_a2a_backend().is_megamoe():
return False return False
@@ -98,7 +109,7 @@ def should_use_mega_moe(moe, hidden_states: torch.Tensor) -> bool:
return False return False
weight_format = getattr(moe.experts, "_mega_moe_weight_format", None) weight_format = getattr(moe.experts, "_mega_moe_weight_format", None)
if weight_format == "fp8": if weight_format == "fp8":
return deep_gemm_wrapper.ENABLE_JIT_DEEPGEMM return _deep_gemm_supports_fp8_mega_moe()
if weight_format != "fp4": if weight_format != "fp4":
return False return False
if not envs.SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS.get(): if not envs.SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS.get():

View File

@@ -82,7 +82,7 @@ class TestGLMMegaMoE(unittest.TestCase):
with patch.object( with patch.object(
mega_moe, "get_moe_a2a_backend", return_value=_MegaBackend() mega_moe, "get_moe_a2a_backend", return_value=_MegaBackend()
), patch.object( ), patch.object(
mega_moe.deep_gemm_wrapper, "ENABLE_JIT_DEEPGEMM", True mega_moe, "_deep_gemm_supports_fp8_mega_moe", return_value=True
), envs.SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS.override(False): ), envs.SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS.override(False):
self.assertTrue(mega_moe.should_use_mega_moe(moe, hidden_states)) self.assertTrue(mega_moe.should_use_mega_moe(moe, hidden_states))