Prhub

#49770 [CI] fix compile test | refactor VLLM_DISABLE_COMPILE_CACHE for tests

原始 PR 作者 divakar-amd 合并时间 2026-07-25 12:15 文件变更 4 提交数 1 评论 0 代码增减 +23 / -14

执行摘要

重构测试编译缓存禁用方式,修复 CI 不稳定

修复 tests/compile/test_compile_ranges.py 在持久化 CI Agent 上的间歇性失败。根本原因是 warm vLLM compile cache 导致已编译图从磁盘加载,从而跳过了自定义 post-grad passes,使得测试无法正确计数。

值得快速合并。该 PR 解决了实际 CI 问题,且重构后代码更清晰、更 DRY。建议团队在后续类似测试中优先使用 disable_vllm_compile_cache fixture。

讨论亮点

AndreasKaratzas 审核时只回复了 "LGTM",没有实质讨论。Claude Bot 自动评论提醒这是 fork 来的 PR,未执行自动审查。因此本 PR 没有显著的争论或设计权衡讨论。

实现拆解

  1. 新增 fixture disable_vllm_compile_cachetests/conftest.py):组合 use_fresh_inductor_cachemonkeypatch.setenv('VLLM_DISABLE_COMPILE_CACHE', '1'),一次性确保每次测试都使用全新 Inductor 缓存并禁止 vLLM 级联缓存,强制编译过程实际执行。
  2. 迁移 test_compile_ranges.py 的三个测试:将 test_compile_rangestest_compile_sizes_produce_static_shapestest_inductor_cache_compile_ranges 的 fixture 从 use_fresh_inductor_cache 改为 disable_vllm_compile_cache,并移除 test_inductor_cache_compile_ranges 中手动的 monkeypatch.setenv('VLLM_DISABLE_COMPILE_CACHE', '1')
  3. 迁移 test_fusion_attn.py:将 test_attention_quant_pattern 的参数从 monkeypatch, use_fresh_inductor_cache 替换为 disable_vllm_compile_cache,并删除函数体内的手动 monkeypatch.setenv('VLLM_DISABLE_COMPILE_CACHE', '1')
  4. 迁移 test_mla_attn_quant_fusion.py:类似地,将 test_mla_attention_quant_pattern 的参数从 monkeypatch, use_fresh_inductor_cache 替换为 disable_vllm_compile_cache,并删除手动环境变量设置。
文件 模块 状态 重要度
tests/conftest.py 测试配置 modified 5.62
tests/compile/test_compile_ranges.py 编译范围 modified 5.38
tests/compile/passes/test_fusion_attn.py 融合注意力 modified 3.49
tests/compile/passes/test_mla_attn_quant_fusion.py MLA 量化融合 modified 3.49

关键符号

disable_vllm_compile_cache test_compile_ranges test_compile_sizes_produce_static_shapes test_inductor_cache_compile_ranges test_attention_quant_pattern test_mla_attention_quant_pattern

关键源码片段

tests/compile/test_compile_ranges.py test-coverage

主要修复对象:三个测试因 warm compile cache 间歇性失败,通过 fixture 替换修复。

# Before:
# def test_compile_ranges(use_fresh_inductor_cache):
# ...
# def test_inductor_cache_compile_ranges(monkeypatch, use_fresh_inductor_cache):
# monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1")# After: 统一使用 disable_vllm_compile_cache fixture
def test_compile_ranges(disable_vllm_compile_cache):
    # ... 测试使用 post_grad_range_checker 验证编译范围
    passdef test_compile_sizes_produce_static_shapes(disable_vllm_compile_cache):
    """Verify that compile_sizes entries are compiled with fully concrete
    shapes (no SymInts), while compile_ranges entries retain dynamic shapes."""
    # ...
    passdef test_inductor_cache_compile_ranges(disable_vllm_compile_cache):
    # disable_vllm_compile_cache sets VLLM_DISABLE_COMPILE_CACHE=1 to force
    # multiple compilations by disabling vLLM's on-disk compile cache.
    # ...
    pass

评论区精华

审核流程 other

Claude Bot 自动评论说明由于 PR 来自 fork,未执行自动审查;AndreasKaratzas 直接批准。

结论:无实质技术讨论,直接合并。 · RESOLVED

风险与影响

风险极低。所有变更仅限于测试代码,且只是对已有逻辑的封装和 de-dup。新 fixture 的语义与之前的手动设置完全一致,不影响任何非测试流程。唯一需要注意:若未来有人修改 VLLM_DISABLE_COMPILE_CACHE 的行为,需同步更新 fixture 注释。

直接影响四个测试文件中的编译测试,消除 CI 上的间歇性失败,提高 CI 稳定性。对其他系统模块无影响。团队在后续编写需要强制重新编译的测试时应直接使用 disable_vllm_compile_cache fixture,而不是手动设置环境变量。

测试变更 CI 稳定性修复

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论