diff --git a/.gitignore b/.gitignore index 82a26694d84..1a3a5424231 100644 --- a/.gitignore +++ b/.gitignore @@ -4,18 +4,19 @@ bin # cmake build directory build .lintbin -nvfuser/version.py -nvfuser/include -nvfuser/lib -nvfuser/share -nvfuser/cmake -python/build +nvfuser_common/version.py +nvfuser_common/include +nvfuser_comon/lib +nvfuser_common/share +nvfuser_common/cmake + python/nvfuser/version.py -python/nvfuser/include -python/nvfuser/lib -python/nvfuser/share -python/nvfuser/cmake +python/nvfuser_common/build +python/nvfuser_common/include +python/nvfuser_common/lib +python/nvfuser_common/share +python/nvfuser_common/cmake .hypothesis *.egg-info/ diff --git a/CMakeLists.txt b/CMakeLists.txt index bb8811e1211..787f958cf4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(NVFUSER_ROOT ${PROJECT_SOURCE_DIR}) set(NVFUSER_SRCS_DIR "${NVFUSER_ROOT}/csrc") set(NVFUSER_PYTHON_DIR "${NVFUSER_ROOT}/python") +set(NVFUSER_PYTHON_BINDINGS "${NVFUSER_ROOT}/python/python_frontend") set(NVFUSER_THIRD_PARTY_DIR "${NVFUSER_ROOT}/third_party") option(NVFUSER_STANDALONE_BUILD_WITH_UCC "" OFF) @@ -296,13 +297,13 @@ endif() if(BUILD_PYTHON) list(APPEND NVFUSER_SRCS - ${NVFUSER_PYTHON_DIR}/python_frontend/distributed_tensor.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/fusion_cache.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/fusion_definition.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/fusion_state.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/segmentation.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/translation.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/translation_utils.cpp + ${NVFUSER_PYTHON_BINDINGS}/distributed_tensor.cpp + ${NVFUSER_PYTHON_BINDINGS}/fusion_cache.cpp + ${NVFUSER_PYTHON_BINDINGS}/fusion_definition.cpp + ${NVFUSER_PYTHON_BINDINGS}/fusion_state.cpp + ${NVFUSER_PYTHON_BINDINGS}/segmentation.cpp + ${NVFUSER_PYTHON_BINDINGS}/translation.cpp + ${NVFUSER_PYTHON_BINDINGS}/translation_utils.cpp ${NVFUSER_SRCS_DIR}/serde/fusion_record.cpp ) endif() @@ -465,10 +466,10 @@ if(BUILD_PYTHON) # nvfuser python API sources set(NVFUSER_PYTHON_SRCS) list(APPEND NVFUSER_PYTHON_SRCS - ${NVFUSER_PYTHON_DIR}/python_frontend/multidevice_bindings.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/python_bindings.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/python_bindings_extension.cpp - ${NVFUSER_PYTHON_DIR}/python_frontend/schedule_bindings.cpp + ${NVFUSER_PYTHON_BINDINGS}/multidevice_bindings.cpp + ${NVFUSER_PYTHON_BINDINGS}/python_bindings.cpp + ${NVFUSER_PYTHON_BINDINGS}/python_bindings_extension.cpp + ${NVFUSER_PYTHON_BINDINGS}/schedule_bindings.cpp ) add_library(nvf_py_internal OBJECT ${NVFUSER_PYTHON_SRCS}) diff --git a/examples/sinh_extension/setup.py b/examples/sinh_extension/setup.py index 967a1707e4f..c172b2d796d 100644 --- a/examples/sinh_extension/setup.py +++ b/examples/sinh_extension/setup.py @@ -28,7 +28,7 @@ # Ensure nvfuser is installed before trying to find its path try: - nvfuser_spec = importlib.util.find_spec("nvfuser") + nvfuser_spec = importlib.util.find_spec("nvfuser_common") if nvfuser_spec is None or nvfuser_spec.origin is None: raise ImportError("Could not find nvfuser. Is it installed?") nvfuser_lib_dir = str(pathlib.Path(nvfuser_spec.origin).parent / "lib") diff --git a/examples/sinh_libtorch/README.md b/examples/sinh_libtorch/README.md index 9e9610bfd79..3bec9d0354a 100644 --- a/examples/sinh_libtorch/README.md +++ b/examples/sinh_libtorch/README.md @@ -9,7 +9,7 @@ ``` mkdir build cd build -CMAKE_PREFIX_PATH=$(python -c 'import nvfuser.utils; import torch.utils; print(nvfuser.utils.cmake_prefix_path, torch.utils.cmake_prefix_path, sep=";")') +CMAKE_PREFIX_PATH=$(python -c 'import nvfuser_common.utils; import torch.utils; print(nvfuser_common.utils.cmake_prefix_path, torch.utils.cmake_prefix_path, sep=";")') cmake -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -G Ninja .. cmake --build . ``` diff --git a/python/nvfuser_common/__init__.py b/python/nvfuser_common/__init__.py new file mode 100644 index 00000000000..51ba303bccb --- /dev/null +++ b/python/nvfuser_common/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-present NVIDIA CORPORATION & AFFILIATES. +# All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause diff --git a/python/nvfuser/utils.py b/python/nvfuser_common/utils.py similarity index 93% rename from python/nvfuser/utils.py rename to python/nvfuser_common/utils.py index eeea772f8b7..478c95ec736 100644 --- a/python/nvfuser/utils.py +++ b/python/nvfuser_common/utils.py @@ -11,7 +11,7 @@ cmake_prefix_path = os.path.join( os.path.dirname(os.path.dirname(__file__)), - "nvfuser", + "nvfuser_common", "share", "cmake", "nvfuser", diff --git a/python/utils.py b/python/utils.py index 7231e01689b..027298ee53a 100644 --- a/python/utils.py +++ b/python/utils.py @@ -285,7 +285,9 @@ def build_extension(self, ext): filename = self.get_ext_filename(self.get_ext_fullname(ext.name)) fileext = os.path.splitext(filename)[1] - libnvfuser_path = os.path.join("./nvfuser/lib", f"libnvfuser{fileext}") + libnvfuser_path = os.path.join( + "./nvfuser_common/lib", f"libnvfuser{fileext}" + ) assert os.path.exists(libnvfuser_path) install_dst = os.path.join(self.build_lib, filename) if not os.path.exists(os.path.dirname(install_dst)): @@ -391,7 +393,9 @@ def cmake(config, relative_path): os.makedirs(cmake_build_dir) install_prefix = ( - os.path.join(cwd, "nvfuser") if not config.install_dir else config.install_dir + os.path.join(cwd, "nvfuser_common") + if not config.install_dir + else config.install_dir ) from tools.gen_nvfuser_version import ( @@ -518,7 +522,7 @@ def run(config, version_tag, relative_path): # NOTE: package include files for cmake # TODO(crcrpar): Better avoid hardcoding `libnvfuser_codegen.so` # might can be treated by using `exclude_package_data`. - nvfuser_package_data = [ + nvfuser_common_package_data = [ "lib/libnvfuser_codegen.so", "include/nvfuser/*.h", "include/nvfuser/struct.inl", @@ -559,7 +563,7 @@ def run(config, version_tag, relative_path): "clean": create_clean(relative_path), }, package_data={ - "nvfuser": nvfuser_package_data, + "nvfuser_common": nvfuser_common_package_data, }, install_requires=config.install_requires, extras_require={