Prhub

#24569 [AMD] Register 8 CPU-bound unit tests for AMD 1-GPU PR CI

原始 PR 作者 michaelzhang-ai 合并时间 2026-05-09 07:01 文件变更 8 提交数 2 评论 4 代码增减 +16 / -8

执行摘要

为 AMD CI 注册 8 个 CPU-bound 单元测试

这些单元测试已经是 NVIDIA per-commit CI 的一部分,且仅使用纯 Python/CPU torch 操作,没有 FlashInfer、FA3、ModelOpt/Marlin 等 GPU 专属依赖。将它们注册到 AMD CI 中,可以在不增加额外维护负担的前提下,更好地在 AMD 平台上发现回归问题,确保代码跨平台兼容性。PR body 中明确列出了每个测试的预估时间和安全依据。

建议其他平台的开发者在添加新的 CPU-bound 测试时,参考此模式同时注册 register_cuda_ciregister_amd_ci,以最大化跨平台覆盖。该 PR 本身逻辑简单,无需深度精读,但团队的 CI 基础设施设计(通过装饰器式注册分离套件定义)值得借鉴。

讨论亮点

该 PR 的 review 过程非常简洁,HaiShaw 直接 approve,没有提出任何修改意见或讨论。PR author 在 comment 中发布了 CI 状态确认,所有新增测试均通过。因此没有实质性的技术争论。

实现拆解

  1. 识别可移植的 CPU-bound 测试:从现有 NVIDIA CI 的 stage-b-test-1-gpu-small 套件中,筛选出仅依赖纯 Python 和 CPU torch ops 的测试文件,共 8 个,涵盖 auto_benchmark 工具、conv 层、LoRA 内存池、模型加载模拟(Llava)以及 radix cache 等模块。
  2. 导入并注册 AMD CI:在每个测试文件的导入区,将 register_cuda_ci 的导入替换为同时导入 register_amd_ciregister_cuda_ci,并在已有 register_cuda_ci 调用下方新增一行 register_amd_ci(est_time=..., suite="stage-b-test-1-gpu-small-amd"),预估时间与 NVIDIA CI 设置一致。
  3. 验证注册结果:使用 AST 基于收集器重新扫描 test/registered/,确认 AMD CI 测试计数从 88 升至 96,且所有新文件都出现在 stage-b-test-1-gpu-small-amd 套件中。通过 AMD PR CI 实际运行,所有 14 个分区的测试全部通过。
  4. 保持 NVIDIA CI 不变:原有 register_cuda_ci 调用和测试逻辑未做任何修改,确保对 NVIDIA CI 无影响。
文件 模块 状态 重要度
test/registered/unit/models/test_llava.py llava 测试 modified 4.21
test/registered/unit/auto_benchmark/test_dataset_tools.py 数据集 modified 3.86
test/registered/unit/auto_benchmark/test_run_candidate.py 候选实验 modified 3.86
test/registered/unit/auto_benchmark/test_search_tools.py 搜索工具 modified 3.86
test/registered/unit/layers/test_conv_layer.py 卷积层 modified 3.86
test/registered/unit/lora/test_mem_pool_ep_unit.py LoRA 池 modified 3.86
test/registered/unit/mem_cache/test_decode_radix_lock_ref.py radix 锁 modified 3.86
test/registered/unit/mem_cache/test_radix_cache_slru_accuracy.py radix 缓存 modified 3.86

关键源码片段

test/registered/unit/models/test_llava.py test-coverage

核心变更文件之一,为 Llava 模型加载测试添加 AMD CI 注册,重要性评分最高。

import unittest
from unittest.mock import patchfrom sglang.srt.models.llava import AutoModel, LlavaForConditionalGeneration
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import CustomTestCase# 注册到 NVIDIA CI(保持不变)
register_cuda_ci(est_time=9, suite="stage-b-test-1-gpu-small")
# 新增注册到 AMD CI(测试不依赖 GPU 专属库,可安全运行)
register_amd_ci(est_time=9, suite="stage-b-test-1-gpu-small-amd")

评论区精华

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

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

风险与影响

风险极低。变更仅涉及在每个测试文件中增加一行注册调用和一个导入语句,不修改任何测试逻辑或生产代码。PR author 已确认测试仅使用 CPU 和 plain torch ops,不依赖任何 AMD 不支持的 GPU 专属库,因此 AMD CI 上执行失败的可能性很小。实际 CI 运行结果也验证了这一点:所有 14 个分区的测试均稳定通过。

对最终用户无直接功能影响。对开发团队:AMD PR CI 的单元测试数量从 88 增加到 96,覆盖了更多模块(auto_benchmark、conv 层、LoRA、模型加载模拟、radix cache 等),有助于在 AMD 平台上提前发现回归。新增测试总预计执行时间约 61 秒,分散在 14 个分区中,对 CI 整体耗时影响可忽略。

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论