feat: configure Torch Dynamo recompile limit from environment (#7243)

Signed-off-by: Xiaodong Ye <xiaodong.ye@mthreads.com>
This commit is contained in:
R0CKSTAR authored and GitHub committed 2026-09-26 22:54:47 +08:00
1 parent d418004b6b
commit 6715c57b2d
6 files changed
+111 -1

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
import os
import subprocess
import sys
from pathlib import Path
import pytest
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
_IMPORT_SCRIPT = """
import sys
import types
import torch._dynamo.config as dynamo_config
# Isolate package startup from unrelated vLLM patches and model registration.
version = types.ModuleType("vllm_omni.version")
version.__version__ = "dev"
version.__version_tuple__ = (0, 0, "dev")
sys.modules[version.__name__] = version
for name in ("vllm_omni.patch", "vllm_omni.transformers_utils.configs",
"vllm_omni.transformers_utils.parsers"):
sys.modules[name] = types.ModuleType(name)
config = types.ModuleType("vllm_omni.config")
config.OmniModelConfig = object
sys.modules[config.__name__] = config
dynamo_config.recompile_limit = 11
import vllm_omni
assert dynamo_config.recompile_limit == int(sys.argv[1])
"""
@pytest.mark.parametrize("value", [None, "2", "64", "0", "-1", "not-an-int"])
def test_package_import_configures_recompile_limit(value: str | None) -> None:
env = os.environ.copy()
name = "VLLM_OMNI_TORCH_DYNAMO_RECOMPILE_LIMIT"
env.pop(name, None)
if value is not None:
env[name] = value
result = subprocess.run(
[sys.executable, "-c", _IMPORT_SCRIPT, value or "11"],
cwd=Path(__file__).resolve().parents[2],
env=env,
capture_output=True,
text=True,
timeout=60,
)
if value in {"0", "-1", "not-an-int"}:
assert result.returncode != 0
assert f"ValueError: {name} must be" in result.stderr
else:
assert result.returncode == 0, result.stderr
+1 -1
View File
@@ -164,7 +164,7 @@ def test_inventory_matches_reviewed_snapshot_counts():
"""Make an inventory expansion an explicit review decision."""
category_counts = Counter(item.category for item in ENVIRONMENT_VARIABLE_INVENTORY.values())
assert category_counts == {
EnvironmentVariableCategory.PUBLIC_OMNI: 30,
EnvironmentVariableCategory.PUBLIC_OMNI: 31,
EnvironmentVariableCategory.INHERITED_VLLM: 20,
EnvironmentVariableCategory.PLATFORM_EXTERNAL: 29,
EnvironmentVariableCategory.MODEL_SPECIFIC: 58,