Skip to content
Merged
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
19 changes: 8 additions & 11 deletions python/infinicore/_preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def _should_preload_device(device_type: str) -> bool:
for env_var in env_vars:
if os.getenv(env_var):
return True
if device_type == "HYGON":
dtk_root = os.getenv("DTK_ROOT") or "/opt/dtk"
if os.path.isdir(dtk_root):
return True
return False


Expand All @@ -181,6 +185,7 @@ def preload_device(device_type: str) -> None:
preload_hpcc()
elif device_type == "HYGON":
preload_torch_hip()
preload_flash_attn()
# Add other device preload functions here as needed:
# elif device_type == "ASCEND":
# preload_ascend()
Expand All @@ -194,17 +199,9 @@ def preload() -> None:
This function detects available device types and preloads their runtime libraries
if the environment indicates they are needed.
"""
# Always try torch HIP preload first (best-effort, no-op if torch/HIP is absent).
try:
preload_torch_hip()
except Exception:
pass
try:
preload_flash_attn()
except Exception:
pass

# Device types that may require preload
# Device types that may require preload. Keep Hygon-only preloads gated by
# Hygon environment markers so other CUDA-compatible platforms do not load
# unrelated torch/flash-attn libraries during package import.
device_types = [
"METAX", # HPCC/METAX
"HYGON",
Expand Down
19 changes: 15 additions & 4 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,22 @@ target("infiniop")

local public_cuda_root = get_config("cuda") or os.getenv("CUDA_HOME") or os.getenv("CUDA_PATH")
if public_cuda_root and public_cuda_root ~= "" then
add_includedirs(path.join(public_cuda_root, "include"))
add_linkdirs(
for _, include_dir in ipairs({
path.join(public_cuda_root, "include"),
path.join(public_cuda_root, "targets", "x86_64-linux", "include"),
}) do
if os.isdir(include_dir) then
add_includedirs(include_dir)
end
end
for _, link_dir in ipairs({
path.join(public_cuda_root, "lib64"),
path.join(public_cuda_root, "targets", "x86_64-linux", "lib")
)
path.join(public_cuda_root, "targets", "x86_64-linux", "lib"),
}) do
if os.isdir(link_dir) then
add_linkdirs(link_dir)
end
end
elseif has_config("nv-gpu") then
add_includedirs(path.join("/usr/local/cuda", "include"))
end
Expand Down
Loading