From 335da4abe60e0177872e0b7751e86eeec6756a2b Mon Sep 17 00:00:00 2001
From: Gahow Wang <gahow.wang@gmail.com>
Date: Sat, 11 Jul 2026 22:32:30 +0800
Subject: [PATCH 4/5] Exclude OpProf output path from compile cache key

---
 tests/v1/core/test_opprof.py | 21 ++++++++++++++++++++-
 vllm/envs.py                 |  1 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/tests/v1/core/test_opprof.py b/tests/v1/core/test_opprof.py
index 79c1fae..a820e7e 100644
--- a/tests/v1/core/test_opprof.py
+++ b/tests/v1/core/test_opprof.py
@@ -8,7 +8,7 @@ import logging
 import sys
 import threading
 from pathlib import Path
-from types import SimpleNamespace
+from types import ModuleType, SimpleNamespace
 
 import msgspec
 import pytest
@@ -23,6 +23,25 @@ sys.modules[_SPEC.name] = opprof
 _SPEC.loader.exec_module(opprof)
 
 
+def test_output_dir_is_not_a_compile_factor(monkeypatch: pytest.MonkeyPatch):
+    spec = importlib.util.spec_from_file_location(
+        "envs_standalone", _ROOT / "vllm" / "envs.py"
+    )
+    assert spec is not None and spec.loader is not None
+    envs = importlib.util.module_from_spec(spec)
+    monkeypatch.setitem(sys.modules, spec.name, envs)
+    spec.loader.exec_module(envs)
+
+    monkeypatch.setitem(sys.modules, "vllm", ModuleType("vllm"))
+    monkeypatch.setitem(sys.modules, "vllm.config", ModuleType("vllm.config"))
+    config_utils = ModuleType("vllm.config.utils")
+    config_utils.__dict__["normalize_value"] = lambda value: value
+    monkeypatch.setitem(sys.modules, "vllm.config.utils", config_utils)
+    monkeypatch.setenv("VLLM_OPPROF_DIR", "/tmp/opprof")
+
+    assert "VLLM_OPPROF_DIR" not in envs.compile_factors()
+
+
 class CachedRequests:
     def __init__(self, context_ids=()):
         self.context_ids = set(context_ids)
diff --git a/vllm/envs.py b/vllm/envs.py
index b3093e9..5634708 100755
--- a/vllm/envs.py
+++ b/vllm/envs.py
@@ -2044,6 +2044,7 @@ def compile_factors() -> dict[str, object]:
         "VLLM_LOGGING_CONFIG_PATH",
         "VLLM_LOGGING_COLOR",
         "VLLM_LOG_STATS_INTERVAL",
+        "VLLM_OPPROF_DIR",
         "VLLM_DEBUG_LOG_API_SERVER_RESPONSE",
         "VLLM_TUNED_CONFIG_FOLDER",
         "VLLM_FLASHINFER_AUTOTUNE_CACHE_DIR",
-- 
2.43.0

