From 16c16301c8218a28eefcdec07757a782e5ddc643 Mon Sep 17 00:00:00 2001 From: afeldman-nm <156691304+afeldman-nm@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:08:00 -0400 Subject: [PATCH] Disable "Forbid direct 'import triton'" check for `vllm/triton_utils/importing.py` in an extensible way (#19783) Signed-off-by: Andrew Feldman --- tools/check_triton_import.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/check_triton_import.py b/tools/check_triton_import.py index 77b2dfc391..c01d9d4ab0 100644 --- a/tools/check_triton_import.py +++ b/tools/check_triton_import.py @@ -14,6 +14,12 @@ ALLOWED_LINES = { "from vllm.triton_utils import tl, triton", } +ALLOWED_FILES = {"vllm/triton_utils/importing.py"} + + +def is_allowed_file(current_file: str) -> bool: + return current_file in ALLOWED_FILES + def is_forbidden_import(line: str) -> bool: stripped = line.strip() @@ -25,10 +31,14 @@ def parse_diff(diff: str) -> list[str]: violations = [] current_file = None current_lineno = None + skip_allowed_file = False for line in diff.splitlines(): if line.startswith("+++ b/"): current_file = line[6:] + skip_allowed_file = is_allowed_file(current_file) + elif skip_allowed_file: + continue elif line.startswith("@@"): match = re.search(r"\+(\d+)", line) if match: