Prhub

#41919 [CI][Arm] skip e2e model tests if HF_TOKEN is not set

原始 PR 作者 fadara01 合并时间 2026-05-07 19:31 文件变更 1 提交数 1 评论 6 代码增减 +15 / -7

执行摘要

ARM CI 无条件跳过需模型下载的 e2e 测试

PR body 指出 CI agent 未设置 HF_TOKEN,导致模型下载触发 Hugging Face Hub 速率限制,影响 e2e 测试稳定性。

该 PR 为临时性 CI 调整,值得关注的是设计决策:kernel 测试前置确保基础功能覆盖,e2e 测试在有 HF_TOKEN 时正常执行。

讨论亮点

haosdent 建议在 cpu.yaml 中使用 skip 属性跳过整个 job,但 fadara01 指出这会跳过所有测试(包括 kernel 测试),不可取。haosdent 随后建议在脚本内检测 HF_TOKEN 后 return,fadara01 接受该方案。

实现拆解

  1. 在 .buildkite/scripts/hardware_ci/run-cpu-test-arm.sh 的 cpu_tests() 函数中,将 kernel 测试(无需下载模型)提前执行。
  2. 在 kernel 测试之后,添加 if [ -z "$HF_TOKEN" ] 判断,若环境变量未设置则打印警告并 return,跳过后续的离线推理、模型测试和在线 serving 测试。
  3. 原脚本中 kernel 测试位于模型测试之后,现将其前置以确保始终运行。
文件 模块 状态 重要度
.buildkite/scripts/hardware_ci/run-cpu-test-arm.sh CI 脚本 modified 3.66

关键符号

cpu_tests

关键源码片段

.buildkite/scripts/hardware_ci/run-cpu-test-arm.sh infrastructure

唯一变更文件,调整 ARM CI 测试执行顺序并添加 HF_TOKEN 检测条件,避免无 token 时 e2e 测试因速率限制失败。

# kernel tests — no model download, always run
docker exec cpu-test bash -c "
    set -e
    pytest -x -v -s tests/kernels/test_onednn.py
    pytest -x -v -s tests/kernels/attention/test_cpu_attn.py
    pytest -x -v -s tests/kernels/core/test_cpu_activation.py
    pytest -x -v -s tests/kernels/moe/test_moe.py -k test_cpu_fused_moe_basic
"
​
# skip tests requiring model downloads if HF_TOKEN is not set
# due to rate-limits on Hugging Face Hub
if [ -z "$HF_TOKEN" ]; then
    echo "Warning: HF_TOKEN is not set. Skipping tests that require model downloads."
    return # exit cpu_tests early, kernel tests have already run
fi
​
# offline inference (requires model download)
docker exec cpu-test bash -c "
    set -e
    ...
"

评论区精华

使用 skip 属性 vs 脚本内 return 设计

haosdent 建议在 cpu.yaml 中设置 skip 属性跳过整个 job,fadara01 指出这会跳过所有测试,希望保留 kernel 测试。haosdent 随后建议在脚本中使用 return 跳过后续 e2e 测试。

结论:采用脚本内检测 HF_TOKEN 后 return 的方案,kernel 测试始终运行。 · 已解决

风险与影响

kernel 测试始终运行,无回归风险。e2e 测试在 HF_TOKEN 缺失时被跳过,若 HF_TOKEN 后续配置但未恢复脚本,则 e2e 测试会被错误跳过,需确保 CI agent 配置 HF_TOKEN 后及时移除该逻辑。

仅影响 ARM CPU CI 的 e2e 测试阶段。kernel 测试不受影响。用户无感知。

临时性变更 缺少 HF_TOKEN 恢复后自动移除检测的机制

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论