Prhub

#50190 [ROCm][CI] Stabilize ngram and suffix correctness test

原始 PR 作者 AndreasKaratzas 合并时间 2026-07-29 10:29 文件变更 1 提交数 1 评论 0 代码增减 +19 / -8

执行摘要

修复 ROCm 上 spec decode 测试的间歇性故障

ROCm CI 在 Buildkite build 11367 中,test_ngram_and_suffix_correctness 测试(ngram 案例完成、引擎关机超时后,suffix 案例出现异步 GPU 故障)间歇性失败,需要提升测试稳定性。

该 PR 是典型的 CI 稳定性修复,技术价值有限但对 ROCm 持续集成很重要。建议合并。

讨论亮点

无 review 评论。

实现拆解

  1. 新增 fixture disable_vllm_compile_cache_on_rocm:在 tests/v1/e2e/spec_decode/test_spec_decode.py 中定义一个自动使用的 fixture,仅在 ROCm 平台下通过 request.getfixturevalue("disable_vllm_compile_cache") 调用已有的 disable_vllm_compile_cache fixture,避免 vLLM 编译缓存影响。
  2. 替换手动 LLM 生命周期为 VllmRunner 上下文管理器:将 test_ngram_and_suffix_correctness 中的手动 LLM 创建、删除、缓存清除和分布式清理替换为 vllm_runner 上下文管理器,利用其内置的 60 秒关机超时、分布式清理和 ROCm 内存等待机制。
  3. 调整 import 和装饰器:新增 from vllm.config import CompilationConfig 导入,并给测试函数添加 @pytest.mark.usefixtures("disable_vllm_compile_cache_on_rocm") 装饰器。通过 compilation_config=CompilationConfig() 保持默认编译配置,避免 VllmRunner 注入缩小的测试编译大小。
文件 模块 状态 重要度
tests/v1/e2e/spec_decode/test_spec_decode.py 推测解码 modified 5.65

关键符号

disable_vllm_compile_cache_on_rocm test_ngram_and_suffix_correctness

关键源码片段

tests/v1/e2e/spec_decode/test_spec_decode.py test-coverage

唯一变更文件,通过新增 ROCm 平台编译缓存隔离和替换 VllmRunner 上下文管理器来稳定测试。

# tests/v1/e2e/spec_decode/test_spec_decode.py
# ( 省略 import 部分 )@pytest.fixture
def disable_vllm_compile_cache_on_rocm(request: pytest.FixtureRequest) -> None:
    """仅在 ROCm 平台下禁用 vLLM 编译缓存,避免缓存冲突引起故障"""
    if current_platform.is_rocm():
        request.getfixturevalue("disable_vllm_compile_cache")@pytest.mark.parametrize(
    "speculative_config",
    [
        {
            "method": "ngram",
            "prompt_lookup_max": 5,
            "prompt_lookup_min": 3,
            "num_speculative_tokens": 3,
        },
        {
            "method": "suffix",
            "suffix_decoding_max_spec_factor": 2.0,
        },
    ],
)
@pytest.mark.usefixtures("disable_vllm_compile_cache_on_rocm")
@single_gpu_only
@large_gpu_mark(min_gb=20)
def test_ngram_and_suffix_correctness(
    speculative_config: dict,
    model_name: str,
    vllm_runner,
):
    """使用 VllmRunner 上下文管理器保证引擎优雅关闭和内存清理"""
    with vllm_runner(
        model_name,
        trust_remote_code=False,
        enable_chunked_prefill=None,
        speculative_config=speculative_config,
        max_model_len=4096,
        # 保持 LLM 默认编译 / cudagraph 配置,防止 VllmRunner 注入测试专用缩小尺寸
        compilation_config=CompilationConfig(),
    ) as runner:
        evaluate_llm_for_gsm8k(runner.llm)

评论区精华

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

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

风险与影响

低风险。变更仅限于测试文件,未改动生产代码。新增 fixture 仅在 ROCm 平台生效,不影响其他平台。VllmRunner 上下文管理器的使用在 vLLM 测试中已有广泛先例,可靠性可接受。

直接影响 ROCm CI 中 ngram/suffix spec decode 正确性测试的稳定性,降低间歇性故障率。对用户和生产路径无影响。

仅 CI 影响

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论