Prhub

#46161 [CI] Add TP=4 requirement to `test_mixed_precision_model_accuracies`

原始 PR 作者 fxmarty-amd 合并时间 2026-06-23 07:19 文件变更 1 提交数 2 评论 3 代码增减 +5 / -0

执行摘要

为混合精度测试加上 TP=4 装饰器

该测试在CI runner上因设备不足而失败,PR body 引用 CI 构建链接说明了问题。测试需要 tensor_parallel_size=4,但 runner 未提供足够的 GPU。

PR 较为琐碎,仅作测试稳健性提升,不值得精读。值得注意的点是团队在review中推荐复用已有装饰器而非重复造轮子,体现了良好的代码复用习惯。

讨论亮点

Reviewer AndreasKaratzas 建议使用 tests/utils.py 中已有的 multi_gpu_only 装饰器,而不是手动编写设备计数检查。作者 fxmarty-amd 采纳建议并在第二次提交中修复。最终两位 reviewer 均批准。

实现拆解

  1. 导入装饰器:在 tests/quantization/test_mixed_precision.py 头部新增 from tests.utils import multi_gpu_only
  2. 添加装饰器:在 test_mixed_precision_model_accuracies 函数上增加 @multi_gpu_only(num_gpus=4),使其在 GPU 数量少于 4 时自动跳过。
  3. 移除手动检查:根据 review 评论,将最初的手动 device_count 检查替换为现有的装饰器,保持代码一致。
文件 模块 状态 重要度
tests/quantization/test_mixed_precision.py 量化测试 modified 3.26

关键符号

test_mixed_precision_model_accuracies

关键源码片段

tests/quantization/test_mixed_precision.py test-coverage

唯一变更文件,添加了导入 `multi_gpu_only` 和装饰器,确保测试在设备不足时自动跳过。

# 文件:tests/quantization/test_mixed_precision.py
# 新增导入:复用已有的 multi_gpu_only 装饰器,统一跳过策略
from tests.utils import (
    multi_gpu_only,
)# 在函数定义前添加装饰器,要求至少 4 个 GPU,否则 pytest 跳过
@multi_gpu_only(num_gpus=4)
def test_mixed_precision_model_accuracies(model_name: str, accuracy_numbers: dict):
    results = lm_eval.simple_evaluate(
        model="vllm",
        model_args=EvaluationConfig(model_name).get_model_args(),
        tasks=list(accuracy_numbers.keys()),
        batch_size=8,
    )
    # ... 验证逻辑不变

评论区精华

使用现有装饰器替代手动设备计数检查 style

AndreasKaratzas 建议使用已有的 `multi_gpu_only` 装饰器而非手动 `device_count` + `pytest.skip`。

结论:作者采纳并更新代码,使用 `@multi_gpu_only(num_gpus=4)`。 · 已解决

风险与影响

无技术风险。变更仅为测试跳过条件的改进,不涉及任何生产代码逻辑。

对用户无影响。对CI系统:确保在AMD GPU数量不足4的runner上该测试被正确跳过,避免误报失败。影响范围限定于ROCm CI。

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论