Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/find-pip-tileiras-in-split-namespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fixed compiler discovery when NVIDIA Python packages are installed across multiple
directories. cuTile now finds the pip-installed ``tileiras`` in later directories
and warns if the compiler packages are installed but no executable is found.
27 changes: 16 additions & 11 deletions src/cuda/tile/_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,19 +832,24 @@ def _find_pip_tileiras() -> Optional[str]:

try:
import nvidia.cu13 as cu13_pkg
cu13_root = cu13_pkg.__path__[0]
except (ImportError, AttributeError, IndexError):
cu13_roots = cu13_pkg.__path__
except (ImportError, AttributeError):
logger.debug("Fail to get nvidia.cu13 package path.", exc_info=True)
return None

pip_bin_dir = os.path.join(cu13_root, "bin")
res = shutil.which("tileiras", path=pip_bin_dir)
if res is None:
logger.debug("Fail to find tileiras under nvidia.cu13 path.")
return None
cu13_roots = ()

logger.debug(f"Found tileiras from pip package: {res}")
return res
binary_name = "tileiras.exe" if is_windows() else "tileiras"
res = _find_file(cu13_roots, ["bin"], [binary_name], require_executable=True)
if res is not None:
tileiras_path, _ = res
logger.debug(f"Found tileiras from pip package: {tileiras_path}")
return tileiras_path

warnings.warn(
"The NVIDIA compiler packages are installed, but tileiras was not found in nvidia.cu13. "
"Falling back to system tileiras.",
stacklevel=3,
)
return None


@cache
Expand Down
37 changes: 37 additions & 0 deletions test/test_compiler_discovery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: Copyright (c) <2026> NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

import os
from pathlib import Path
import sys
from types import SimpleNamespace

import pytest

from cuda.tile import _compile


@pytest.mark.parametrize("installed", [(1,), (0, 1), ()], ids=["second", "both", "neither"])
def test_find_pip_tileiras_in_namespace(tmp_path, monkeypatch, installed):
roots = [tmp_path / "first" / "nvidia" / "cu13", tmp_path / "second" / "nvidia" / "cu13"]
cu13 = SimpleNamespace(__path__=roots)
monkeypatch.setitem(sys.modules, "nvidia", SimpleNamespace(cu13=cu13))
monkeypatch.setitem(sys.modules, "nvidia.cu13", cu13)
monkeypatch.setattr(_compile.importlib.metadata, "version", lambda name: "13.5.37")

binary = "tileiras.exe" if os.name == "nt" else "tileiras"
candidates = [root / "bin" / binary for root in roots]
for index in installed:
path = candidates[index]
path.parent.mkdir(parents=True)
path.touch()
path.chmod(0o755)

if installed:
found = _compile._find_pip_tileiras()
assert found is not None
assert Path(found) == candidates[installed[0]]
else:
with pytest.warns(UserWarning, match="Falling back to system tileiras"):
assert _compile._find_pip_tileiras() is None