-
Notifications
You must be signed in to change notification settings - Fork 125
feat(metax): enable standalone InfiniRT graph bridge #1400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: issue/1373
Are you sure you want to change the base?
Changes from all commits
4d004ad
79c6393
2b3c4a0
b1b1436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个文件的修改必要嘛?之前为啥不需要来着,我看后面好像也有几个相关的文件跟这个类似,就是跟这个 preload 和
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里好像是之前在mars上,只有lib64是符合实际的,lib是不行,环境问题 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,7 @@ | |
|
|
||
| def _candidate_prefixes(path: str) -> List[str]: | ||
| """ | ||
| Return HPCC install prefixes to search for libs. | ||
| Prefer HPCC_PATH; if absent and explicitly opted-in, fall back to /opt/hpcc. | ||
| Return unique runtime install prefixes to search for libraries. | ||
| """ | ||
| prefixes: List[str] = [] | ||
| if path: | ||
|
|
@@ -30,14 +29,15 @@ def _candidate_prefixes(path: str) -> List[str]: | |
| def _try_load(paths: Iterable[str], name: str) -> bool: | ||
| """Try to load a shared library from given paths or system search path.""" | ||
| for path in paths: | ||
| full = os.path.join(path, "lib", name) | ||
| if os.path.exists(full): | ||
| try: | ||
| ctypes.CDLL(full, mode=ctypes.RTLD_GLOBAL) | ||
| return True | ||
| except OSError: | ||
| # Try next candidate | ||
| continue | ||
| for subdir in ("lib", "lib64"): | ||
| full = os.path.join(path, subdir, name) | ||
| if os.path.exists(full): | ||
| try: | ||
| ctypes.CDLL(full, mode=ctypes.RTLD_GLOBAL) | ||
| return True | ||
| except OSError: | ||
| # Try next candidate | ||
| continue | ||
| # Last resort: rely on loader search path | ||
| try: | ||
| ctypes.CDLL(name, mode=ctypes.RTLD_GLOBAL) | ||
|
|
@@ -53,7 +53,9 @@ def preload_hpcc() -> None: | |
| This mirrors the behavior of torch's HPCC build that loads libtorch_global_deps.so, | ||
| but avoids introducing a hard torch dependency. All failures are swallowed. | ||
| """ | ||
| hpcc_path = os.getenv("HPCC_PATH") | ||
| hpcc_path = os.getenv("HPCC_PATH") or os.getenv("HPCC_HOME") | ||
| if not hpcc_path and os.getenv("INFINICORE_PRELOAD_HPCC"): | ||
| hpcc_path = "/opt/hpcc" | ||
| if not hpcc_path: | ||
| return | ||
|
|
||
|
|
@@ -157,7 +159,7 @@ def _should_preload_device(device_type: str) -> bool: | |
| Check if preload is needed for a specific device type. | ||
| """ | ||
| device_env_map = { | ||
| "METAX": ["HPCC_PATH", "INFINICORE_PRELOAD_HPCC"], # HPCC/METAX | ||
| "MARS": ["HPCC_PATH", "HPCC_HOME", "INFINICORE_PRELOAD_HPCC"], | ||
| "HYGON": ["DTK_ROOT", "INFINICORE_PRELOAD_TORCH_HIP"], | ||
| # Add other device types here as needed: | ||
| # "ASCEND": ["ASCEND_PATH"], | ||
|
|
@@ -180,9 +182,9 @@ def preload_device(device_type: str) -> None: | |
| Preload runtime libraries for a specific device type if needed. | ||
|
|
||
| Args: | ||
| device_type: Device type name (e.g., "METAX", "ASCEND", etc.) | ||
| device_type: Device type name (e.g., "MARS" or "HYGON") | ||
| """ | ||
| if device_type == "METAX": | ||
| if device_type == "MARS": | ||
| preload_hpcc() | ||
| elif device_type == "HYGON": | ||
| preload_torch_hip() | ||
|
|
@@ -200,11 +202,11 @@ def preload() -> None: | |
| This function detects available device types and preloads their runtime libraries | ||
| if the environment indicates they are needed. | ||
| """ | ||
| # 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 that may require preload. Gate each preload by its own | ||
| # environment markers so CUDA-compatible platforms do not load one another's | ||
| # runtime libraries during package import. | ||
| device_types = [ | ||
| "METAX", # HPCC/METAX | ||
| "MARS", | ||
|
Comment on lines
162
to
+209
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这些地方直接把
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不会,这里之前的METAX实际就是MARS,实际调用的是preload_hpcc,其实只有MARS设备 |
||
| "HYGON", | ||
| # Add other device types here as they are implemented: | ||
| # "ASCEND", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分先去掉吧,有点突兀,包括
--mars-flash-attn-abi也得想办法去掉。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的