From aaaeda98dcc14af75cd5fbd26386751a0e8b79c9 Mon Sep 17 00:00:00 2001 From: Divakar Verma <137818590+divakar-amd@users.noreply.github.com> Date: Sat, 25 Jul 2026 00:15:19 -0400 Subject: [PATCH] [CI] fix compile test | refactor VLLM_DISABLE_COMPILE_CACHE for tests (#49770) Signed-off-by: Divakar Verma --- tests/compile/passes/test_fusion_attn.py | 5 +---- .../compile/passes/test_mla_attn_quant_fusion.py | 5 +---- tests/compile/test_compile_ranges.py | 11 +++++------ tests/conftest.py | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/tests/compile/passes/test_fusion_attn.py b/tests/compile/passes/test_fusion_attn.py index 76536f3387c..da335b91557 100644 --- a/tests/compile/passes/test_fusion_attn.py +++ b/tests/compile/passes/test_fusion_attn.py @@ -290,12 +290,9 @@ def test_attention_quant_pattern( model_class: type[AttentionQuantPatternModel], backend: AttentionBackendEnum, dist_init, - monkeypatch, - use_fresh_inductor_cache, + disable_vllm_compile_cache, ): """Test AttentionStaticQuantPattern fusion pass""" - monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1") - if backend == AttentionBackendEnum.FLASHINFER and ( not current_platform.is_device_capability((10, 0)) or not has_flashinfer() ): diff --git a/tests/compile/passes/test_mla_attn_quant_fusion.py b/tests/compile/passes/test_mla_attn_quant_fusion.py index 0a38ffca483..5b2ef5bfd95 100644 --- a/tests/compile/passes/test_mla_attn_quant_fusion.py +++ b/tests/compile/passes/test_mla_attn_quant_fusion.py @@ -419,8 +419,7 @@ def test_mla_attention_quant_pattern( model_class: type[MLAAttentionQuantPatternModel], backend: AttentionBackendEnum, dist_init, - monkeypatch, - use_fresh_inductor_cache, + disable_vllm_compile_cache, ): """Test MLA AttentionQuantPattern fusion pass""" if ( @@ -429,8 +428,6 @@ def test_mla_attention_quant_pattern( ): pytest.skip("NVFP4 is not supported on this GPU (requires SM 100+).") - monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1") - custom_ops_list = custom_ops.split(",") if custom_ops else [] device = torch.device(f"{DEVICE_TYPE}:0") diff --git a/tests/compile/test_compile_ranges.py b/tests/compile/test_compile_ranges.py index 9fd8e9577ba..4dfea42a6b4 100644 --- a/tests/compile/test_compile_ranges.py +++ b/tests/compile/test_compile_ranges.py @@ -66,7 +66,7 @@ class PostGradRangeChecker(InductorPass): return InductorPass.hash_dict(state) -def test_compile_ranges(use_fresh_inductor_cache): +def test_compile_ranges(disable_vllm_compile_cache): post_grad_range_checker = PostGradRangeChecker( [ Range(start=1, end=8), @@ -168,7 +168,7 @@ class PostGradStaticShapeChecker(InductorPass): return InductorPass.hash_dict(state) -def test_compile_sizes_produce_static_shapes(use_fresh_inductor_cache): +def 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.""" checker = PostGradStaticShapeChecker() @@ -209,10 +209,9 @@ def test_compile_sizes_produce_static_shapes(use_fresh_inductor_cache): ) -def test_inductor_cache_compile_ranges(monkeypatch, use_fresh_inductor_cache): - # To force multiple compilations, we disable the compile cache - monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1") - +def 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. post_grad_range_checker = PostGradRangeChecker( ranges=[ Range(start=1, end=8), diff --git a/tests/conftest.py b/tests/conftest.py index 47071167b56..406cb2ed2ea 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1768,6 +1768,22 @@ def use_fresh_inductor_cache(): yield +@pytest.fixture +def disable_vllm_compile_cache(monkeypatch, use_fresh_inductor_cache): + """ + Use a fresh inductor cache AND disable vLLM's on-disk torch.compile cache. + + This forces compilation (and any custom compile passes) to actually run + instead of being served from a warm cache left behind by previous runs + (e.g. on persistent CI agents). Use this for tests that inspect what + happens during compilation; use ``use_fresh_inductor_cache`` (or + ``fresh_vllm_cache``) instead when the vLLM compile cache must stay + enabled (e.g. cache save/load tests). + """ + monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1") + yield + + @pytest.fixture def fresh_vllm_cache(monkeypatch, use_fresh_inductor_cache): """Temporary VLLM_CACHE_ROOT combined with a fresh inductor cache."""