Prhub

#45302 [ROCm][CI] fix fp8 support for test_deepep_moe

原始 PR 作者 divakar-amd 合并时间 2026-06-12 13:16 文件变更 1 提交数 1 评论 1 代码增减 +12 / -9

执行摘要

修复 ROCm 上 FP8 MOE 测试的 dtype 硬编码

ROCm 平台使用 float8_e4m3fnuz 而非 NVIDIA 的 float8_e4m3fn,测试中硬编码的 dtype 导致 FP8 相关断言和初始化失败,影响 CI 测试 kernels/moe/test_deepep_moe.py::test_deep_ep_moe 的正常运行。

该 PR 是典型的平台兼容性修复,值得 ROCm 开发者关注其模式:使用 current_platform.fp8_dtype() 替代硬编码的 dtype。对于其他测试中的类似硬编码问题,可参考此模式进行修复。

讨论亮点

无 review 评论。审核者 AndreasKaratzas 直接批准。

实现拆解

  1. tests/kernels/moe/test_deepep_moe.py 中新增导入 from vllm.platforms import current_platform
  2. make_weightsTestTensors.makebuild_expert_maptorch_moe_impl_deep_ep_moe 等多个函数中所有 torch.float8_e4m3fn 的引用替换为 current_platform.fp8_dtype()
  3. 将测试参数化列表 DTYPES 中的 torch.float8_e4m3fn 替换为 current_platform.fp8_dtype()
  4. 所有修改仅涉及测试文件,无核心源码变更。
文件 模块 状态 重要度
tests/kernels/moe/test_deepep_moe.py MoE 内核 modified 5.08

关键源码片段

tests/kernels/moe/test_deepep_moe.py test-coverage

唯一变更文件,修复了所有 FP8 dtype 硬编码问题。

# tests/kernels/moe/test_deepep_moe.py ( 关键变更片段 )
from vllm.platforms import current_platform # 新增导入,用于获取平台相关的 FP8 dtypedef make_weights(e, n, k, dtype):
    ...
    # 之前:assert dtype == torch.float8_e4m3fn
    assert dtype == current_platform.fp8_dtype() # 动态适配平台
    ...class TestTensors:
    @staticmethod
    def make(config: TestConfig, low_latency_mode: bool) -> "TestTensors":
        # 之前:assert config.dtype in [torch.bfloat16, torch.float8_e4m3fn]
        assert config.dtype in [torch.bfloat16, current_platform.fp8_dtype()]
        # 之前:token_dtype = torch.bfloat16 if config.dtype == torch.float8_e4m3fn else config.dtype
        token_dtype = (
            torch.bfloat16
            if config.dtype == current_platform.fp8_dtype()
            else config.dtype
        )
        ...# 测试参数化列表也做了同样替换
# 之前:DTYPES = [torch.bfloat16, torch.float8_e4m3fn]
DTYPES = [torch.bfloat16, current_platform.fp8_dtype()]

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

风险极低。变更仅限于测试文件,且替换逻辑通过平台抽象层 current_platform.fp8_dtype() 保证了向后兼容性,NVIDIA 平台下返回 torch.float8_e4m3fn,行为不变。

影响范围限于 ROCm CI 中的 deepep MOE 测试。修复后该测试可在 ROCm 上正常执行,不影响现有 NVIDIA 平台行为。

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论