From 62d6e25861fddd4cb5268d8f0e48caeb4d48771f Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 15:03:45 -0700 Subject: [PATCH 1/9] make sure directory exists --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0716af6fff4..0fceda7b4701 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,6 +395,9 @@ message(STATUS "vllm-flash-attn is available at ${vllm-flash-attn_SOURCE_DIR}") install(CODE "set(CMAKE_INSTALL_PREFIX \"\${OLD_CMAKE_INSTALL_PREFIX}\")" COMPONENT vllm_flash_attn_c) install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" COMPONENT vllm_flash_attn_c) +# make sure vllm/vllm_flash_attn exists +make_directory(${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn) + # Copy over the vllm-flash-attn python files install( DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/ From f57ac9f4ed089e89295d862ffd8bfb0c82af6f20 Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 15:42:05 -0700 Subject: [PATCH 2/9] change command --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fceda7b4701..5badc4dc160c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -382,6 +382,9 @@ endif() # Set the parent build flag so that the vllm-flash-attn library does not redo compile flag and arch initialization. set(VLLM_PARENT_BUILD ON) +# make sure vllm/vllm_flash_attn exists +file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn) + # Make sure vllm-flash-attn install rules are nested under vllm/ install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY FALSE)" COMPONENT vllm_flash_attn_c) install(CODE "set(OLD_CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}\")" COMPONENT vllm_flash_attn_c) @@ -395,9 +398,6 @@ message(STATUS "vllm-flash-attn is available at ${vllm-flash-attn_SOURCE_DIR}") install(CODE "set(CMAKE_INSTALL_PREFIX \"\${OLD_CMAKE_INSTALL_PREFIX}\")" COMPONENT vllm_flash_attn_c) install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" COMPONENT vllm_flash_attn_c) -# make sure vllm/vllm_flash_attn exists -make_directory(${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn) - # Copy over the vllm-flash-attn python files install( DIRECTORY ${vllm-flash-attn_SOURCE_DIR}/vllm_flash_attn/ From 94ea4faadf5c2ca4e9026ac5519e3330e34b1b39 Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 16:05:28 -0700 Subject: [PATCH 3/9] change command --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5badc4dc160c..03937e4e0658 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -382,8 +382,8 @@ endif() # Set the parent build flag so that the vllm-flash-attn library does not redo compile flag and arch initialization. set(VLLM_PARENT_BUILD ON) -# make sure vllm/vllm_flash_attn exists -file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn) +# Ensure the vllm/vllm_flash_attn directory exists before installation +install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/vllm/vllm_flash_attn\")" COMPONENT vllm_flash_attn_c) # Make sure vllm-flash-attn install rules are nested under vllm/ install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY FALSE)" COMPONENT vllm_flash_attn_c) From ada3ef409cc5fa9b8dea71a93489bfae87efb88b Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 16:12:38 -0700 Subject: [PATCH 4/9] add directory --- vllm/vllm_flash_attn/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 vllm/vllm_flash_attn/.gitkeep diff --git a/vllm/vllm_flash_attn/.gitkeep b/vllm/vllm_flash_attn/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 From 314e3108bb8d97193a316dd228ecd5ca18e2830a Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 16:49:53 -0700 Subject: [PATCH 5/9] include python files --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cc559f26c6f3..a861380bafe9 100644 --- a/setup.py +++ b/setup.py @@ -493,7 +493,9 @@ def _read_requirements(filename: str) -> List[str]: ext_modules.append(CMakeExtension(name="vllm._C")) package_data = { - "vllm": ["py.typed", "model_executor/layers/fused_moe/configs/*.json"] + "vllm": ["py.typed", "model_executor/layers/fused_moe/configs/*.json"], + # Include all Python files in vllm_flash_attn + 'vllm.vllm_flash_attn': ['*.py'], } if envs.VLLM_USE_PRECOMPILED: ext_modules = [] From 7bb4921c1ebd298adb2edd55827311da23954e11 Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 17:03:57 -0700 Subject: [PATCH 6/9] restore --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a861380bafe9..cc559f26c6f3 100644 --- a/setup.py +++ b/setup.py @@ -493,9 +493,7 @@ def _read_requirements(filename: str) -> List[str]: ext_modules.append(CMakeExtension(name="vllm._C")) package_data = { - "vllm": ["py.typed", "model_executor/layers/fused_moe/configs/*.json"], - # Include all Python files in vllm_flash_attn - 'vllm.vllm_flash_attn': ['*.py'], + "vllm": ["py.typed", "model_executor/layers/fused_moe/configs/*.json"] } if envs.VLLM_USE_PRECOMPILED: ext_modules = [] From 02df756308fe518b0dcdc6c2706606856390a930 Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 17:05:00 -0700 Subject: [PATCH 7/9] add py files --- MANIFEST.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 82be639ef4d7..78562682a6b5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,5 +6,8 @@ include requirements-neuron.txt include requirements-cpu.txt include CMakeLists.txt +# Include Python files in specific directories +include vllm/vllm_flash_attn/*.py + recursive-include cmake * recursive-include csrc * From 6a1086125295c4dc8ba4546db8fdd46d4ec813a5 Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 17:55:53 -0700 Subject: [PATCH 8/9] hard copy --- setup.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/setup.py b/setup.py index cc559f26c6f3..60e31af0a8d3 100644 --- a/setup.py +++ b/setup.py @@ -258,6 +258,21 @@ def build_extensions(self) -> None: ] subprocess.check_call(install_args, cwd=self.build_temp) + def run(self): + # First, run the standard build_ext command to compile the extensions + super().run() + + # copy vllm/vllm_flash_attn/*.py from self.build_lib to current + # directory so that they can be included in the editable build + import glob + files = glob.glob( + os.path.join(self.build_lib, "vllm", "vllm_flash_attn", "*.py")) + for file in files: + dst_file = os.path.join("vllm/vllm_flash_attn", + os.path.basename(file)) + print(f"Copying {file} to {dst_file}") + self.copy_file(file, dst_file) + def _no_device() -> bool: return VLLM_TARGET_DEVICE == "empty" From ac640f83b36f13c92468acf66223a28f29b11a07 Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 21 Sep 2024 17:56:23 -0700 Subject: [PATCH 9/9] revert --- MANIFEST.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 78562682a6b5..82be639ef4d7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,8 +6,5 @@ include requirements-neuron.txt include requirements-cpu.txt include CMakeLists.txt -# Include Python files in specific directories -include vllm/vllm_flash_attn/*.py - recursive-include cmake * recursive-include csrc *