Prhub

#47208 [CI][Bugfix] Rerun test_engine_log_metrics_ray on Ray GCS startup timeout

原始 PR 作者 peizhang56 合并时间 2026-07-02 10:32 文件变更 1 提交数 1 评论 0 代码增减 +13 / -0

执行摘要

对 ROCM CI 上 Ray GCS 超时测试增加重试机制

tests/v1/metrics/test_ray_metrics.py::test_engine_log_metrics_ray在ROCm CI上间歇性失败,错误为RuntimeError: Timed out waiting for file .../gcs_server_port_...。这是Ray集群启动竞态问题,而非vLLM缺陷。Ray的30秒超时不可配置,唯一可行的方案是重试测试(重新ray.init()会获得新的GCS子进程和新的30秒窗口)。

推荐合入以消除ROCm CI上的不稳定测试。该PR模式(使用pytest-rerunfailuresonly_rerun限定重试范围)值得作为测试不稳定问题的标准处理方式。

讨论亮点

无review评论。维护者AndreasKaratzas直接批准了该PR。

实现拆解

  1. 导入current_platform:在文件顶部新增from vllm.platforms import current_platform,用于条件判断。
  2. 添加@pytest.mark.flaky装饰器:在test_engine_log_metrics_ray函数上方添加该装饰器,参数为reruns=2(最多重试2次)、reruns_delay=5(重试间隔5秒)、only_rerun="Timed out waiting for file"(仅当异常信息包含该字符串时重试)、condition=current_platform.is_rocm()(仅在ROCm平台生效)。
  3. 添加详细注释:在装饰器前添加多行注释,解释GCS超时原因及重试策略。
文件 模块 状态 重要度
tests/v1/metrics/test_ray_metrics.py 测试 modified 4.87

关键源码片段

tests/v1/metrics/test_ray_metrics.py test-coverage

唯一变更文件,新增 `@pytest.mark.flaky` 装饰器并导入 `current_platform`,用于对 Ray GCS 超时失败进行重试。

# SPDX-License-Identifier: Apache-2.0from unittest.mock import MagicMockimport pytest
import rayfrom vllm.config.model import ModelDType
from vllm.platforms import current_platform # 新增导入,用于条件判断
from vllm.sampling_params import SamplingParams
from vllm.v1.engine.async_llm import AsyncEngineArgs, AsyncLLM
from vllm.v1.metrics.ray_wrappers import (
    RayCounterWrapper,
    RayGaugeWrapper,
    RayHistogramWrapper,
    RayPrometheusMetric,
    RayPrometheusStatLogger,
)MODELS = ["distilbert/distilgpt2"]
​
​
# The first .remote() call starts a local Ray cluster via ray.init(), whose
# GCS server occasionally fails to start within Ray's fixed 30s bootstrap
# window on ROCm CI (RuntimeError: "Timed out waiting for file
# .../gcs_server_port_..."). 该超时不可配置,因此重试整个测试:
# 重新 ray.init() 会获得新的 GCS 进程。限定重试范围到该错误,
# 以便真正的失败仍然立即失败。
@pytest.mark.flaky(
    reruns=2, # 最多重试 2 次
    reruns_delay=5, # 重试间隔 5 秒
    only_rerun="Timed out waiting for file", # 仅对 GCS 超时重试
    condition=current_platform.is_rocm(), # 仅在 ROCm 平台生效
)
@pytest.mark.parametrize("model", MODELS)
@pytest.mark.parametrize("dtype", ["half"])
@pytest.mark.parametrize("max_tokens", [16])
def test_engine_log_metrics_ray(
    example_prompts,
    model: str,
    dtype: ModelDType,
    max_tokens: int,
) -> None:
    """Simple smoke test, verifying this can be used without exceptions."""
    @ray.remote(num_gpus=1)
    class EngineTestActor:
        async def run(self):
            engine_args = AsyncEngineArgs(
                model=model, dtype=dtype, disable_log_stats=False, enforce_eager=True
            )
            engine = AsyncLLM.from_engine_args(
                engine_args, stat_loggers=[RayPrometheusStatLogger]
            )
            for i, prompt in enumerate(example_prompts):
                results = engine.generate(
                    request_id=f"request-id-{i}",
                    prompt=prompt,
                    sampling_params=SamplingParams(max_tokens=max_tokens),
                )
                async for _ in results:
                    pass

评论区精华

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

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

风险与影响

风险极低:仅修改测试文件,增加重试逻辑并限定了重试条件和平台。only_rerun参数确保非GCS超时的真正失败不会被掩盖;condition参数确保仅ROCm平台启用重试,不影响其他平台。

影响范围限定于ROCm CI上test_engine_log_metrics_ray测试的稳定性,减少因Ray集群启动超时导致的误报。对其他平台和产品功能无影响。

仅测试变更

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论