[ROCm] Defer tilelang import through its import from vllm.tilelang_utils import tilelang and relaxed has_tilelang (#51159)

Signed-off-by: Felix Marty <Felix.Marty@amd.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
fxmarty-amd
2026-08-13 13:12:40 -05:00
committed by GitHub
co-authored by Andreas Karatzas mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent e6b2a8ad5e
commit c5b7c069a4
8 changed files with 313 additions and 52 deletions
@@ -92,6 +92,15 @@ CHECK_IMPORTS = {
),
allowed_files={"vllm/triton_utils/importing.py"},
),
"tilelang": ForbiddenImport(
pattern=r"^(from|import)\s+tilelang(\s|\.|$)",
tip="Use 'from vllm.tilelang_utils import tilelang, T' instead.",
allowed_pattern=re.compile(
r"from\s+vllm\.tilelang_utils\s+import\s+"
r"(tilelang|T|T, tilelang|tilelang, T)\b"
),
allowed_files={"vllm/tilelang_utils/__init__.py"},
),
"huggingface_hub repo API": ForbiddenImport(
# Catch `from huggingface_hub import <fn>`, including parenthesized,
# multi-line imports.
@@ -182,6 +191,29 @@ def test_regex():
f"(expected {should_match}, got {result})"
)
tilelang_cases = [
# Should match
("import tilelang", True),
("import tilelang.language as T", True),
("from tilelang.jit import JITImpl", True),
("from tilelang.jit.kernel import JITKernel", True),
# Should not match: indented (local) imports are allowed, mirroring
# the "triton" rule, so mocked-module test imports are not flagged.
(" import tilelang", False),
(" from tilelang.jit import JITImpl", False),
("from vllm.tilelang_utils import tilelang", False),
("from vllm.tilelang_utils import T", False),
("from vllm.tilelang_utils import T, tilelang", False),
("from vllm.tilelang_utils import tilelang, T", False),
("import tilelang_kernels", False),
]
for i, (content, should_match) in enumerate(tilelang_cases):
result = matches("tilelang", content)
assert result == should_match, (
f"tilelang case {i} failed: {content!r} "
f"(expected {should_match}, got {result})"
)
hf_cases = [
# Should match
("from huggingface_hub import snapshot_download", True),