Prhub

#49609 [CI][Bugfix] Fix test isolation in block_int8/ptpc_fp8 MoE kernel tests

原始 PR 作者 njhill 合并时间 2026-07-24 01:26 文件变更 2 提交数 1 评论 0 代码增减 +4 / -4

执行摘要

修复 MoE 核测试中 fixture scope 导致测试隔离失败

test_batched_moe 等前序测试模块修改了 torch 的默认设备状态后,scope 为 "module" 的 autouse fixture 不会重新执行,导致后续测试的默认设备不是 CUDA,触发 NotImplementedError

可立即合并,解决 CI 中测试隔离问题。建议审查其他测试文件是否存在类似问题(使用 scope="module" 的 autouse fixture)。

讨论亮点

无 review 评论。AndreasKaratzas 已批准。

实现拆解

  1. 修改 tests/kernels/moe/test_block_int8.pysetup_cuda fixture 的 scope 参数从 "module" 移除(默认为 "function")。
  2. 修改 tests/kernels/moe/test_triton_moe_ptpc_fp8.pysetup_cuda fixture 的 scope 参数从 "module" 移除(默认为 "function")。
  3. 更新对应 docstring 以反映新的行为:"Sets the default CUDA device before each test in this module."
文件 模块 状态 重要度
tests/kernels/moe/test_block_int8.py 测试 modified 3.83
tests/kernels/moe/test_triton_moe_ptpc_fp8.py 测试 modified 3.83

关键符号

setup_cuda

分析完成后,这里会展示 LLM 生成的相对完整源码片段和详细注释。

评论区精华

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

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

风险与影响

变更仅涉及测试 fixture scope,不涉及生产代码,风险极低。每次测试都重新设置默认设备会引入微小开销,但对测试运行时间影响可忽略。

影响 test_block_int8.pytest_triton_moe_ptpc_fp8.py 两个测试文件的执行行为,修复测试隔离问题,避免 CI 中因测试顺序导致的不可重现失败。无外部用户影响。

低风险

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论