-
Notifications
You must be signed in to change notification settings - Fork 532
chore: allow custom paths for external dependencies like CUTLASS #1827
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -74,15 +74,39 @@ def _get_workspace_dir_name() -> pathlib.Path: | |||||||
FLASHINFER_CSRC_DIR = _package_root / "data" / "csrc" | ||||||||
# FLASHINFER_SRC_DIR = _package_root / "data" / "src" | ||||||||
FLASHINFER_AOT_DIR = _package_root / "data" / "aot" | ||||||||
CUTLASS_INCLUDE_DIRS = [ | ||||||||
_package_root / "data" / "cutlass" / "include", | ||||||||
_package_root / "data" / "cutlass" / "tools" / "util" / "include", | ||||||||
] | ||||||||
SPDLOG_INCLUDE_DIR = _package_root / "data" / "spdlog" / "include" | ||||||||
|
||||||||
|
||||||||
def get_cutlass_include_dirs(): | ||||||||
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. For performance and consistency, it's a good practice to cache the results of this getter function. Since environment variables are not expected to change during the program's execution, caching will prevent redundant lookups and path processing. You can use Please apply this caching to
Suggested change
|
||||||||
paths = os.environ.get("FLASHINFER_CUTLASS_INCLUDE_PATH") | ||||||||
if paths is not None: | ||||||||
return [pathlib.Path(p) for p in paths.split(os.pathsep) if p] | ||||||||
|
||||||||
# Fall back to default paths | ||||||||
return [ | ||||||||
_package_root / "data" / "cutlass" / "include", | ||||||||
_package_root / "data" / "cutlass" / "tools" / "util" / "include", | ||||||||
] | ||||||||
|
||||||||
|
||||||||
def get_spdlog_include_dir(): | ||||||||
path = os.environ.get("FLASHINFER_SPDLOG_INCLUDE_PATH") | ||||||||
if path is not None: | ||||||||
return pathlib.Path(path) | ||||||||
|
||||||||
# Fall back to default path | ||||||||
return _package_root / "data" / "spdlog" / "include" | ||||||||
|
||||||||
|
||||||||
# For backward compatibility, keep these as properties | ||||||||
CUTLASS_INCLUDE_DIRS = get_cutlass_include_dirs() | ||||||||
SPDLOG_INCLUDE_DIR = get_spdlog_include_dir() | ||||||||
|
||||||||
|
||||||||
def get_nvshmem_include_dirs(): | ||||||||
paths = os.environ.get("NVSHMEM_INCLUDE_PATH") | ||||||||
# Check new environment variable first, then fall back to old one for backward compatibility | ||||||||
paths = os.environ.get("FLASHINFER_NVSHMEM_INCLUDE_PATH") or os.environ.get( | ||||||||
"NVSHMEM_INCLUDE_PATH" | ||||||||
) | ||||||||
if paths is not None: | ||||||||
return [pathlib.Path(p) for p in paths.split(os.pathsep) if p] | ||||||||
|
||||||||
|
@@ -93,7 +117,10 @@ def get_nvshmem_include_dirs(): | |||||||
|
||||||||
|
||||||||
def get_nvshmem_lib_dirs(): | ||||||||
paths = os.environ.get("NVSHMEM_LIBRARY_PATH") | ||||||||
# Check new environment variable first, then fall back to old one for backward compatibility | ||||||||
paths = os.environ.get("FLASHINFER_NVSHMEM_LIBRARY_PATH") or os.environ.get( | ||||||||
"NVSHMEM_LIBRARY_PATH" | ||||||||
) | ||||||||
if paths is not None: | ||||||||
return [pathlib.Path(p) for p in paths.split(os.pathsep) if p] | ||||||||
|
||||||||
|
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.
shall we have documentation collecting these FLASHINFER* vars in some .md file, and briefly mention what they may affect and the order in which related vars are consulted. this could help both users and developers understand the expected behavior (which could otherwise run away after a few ppl modifying the same)
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.
currently user can run
do display these environment variables, but yes let's clearly document it.