From b62c84d88db26f6ce8c8f9caeef132638599a74d Mon Sep 17 00:00:00 2001 From: woctordho Date: Thu, 9 Jan 2025 02:59:41 +0800 Subject: [PATCH] Fix building on Windows with presence of Triton (#6749) This fixes some errors when installing DeepSpeed on Windows with the presence of Triton. I guess we can assume we don't need the warning about NFS on Windows for now. I did not try how to detect NFS path on Windows, but we can detect UNC path starting with `\\` if needed. `os.rename` does not allow overwriting the file on Windows, and `os.replace` is more cross-platform. Co-authored-by: Logan Adams <114770087+loadams@users.noreply.github.com> --- deepspeed/ops/transformer/inference/triton/matmul_ext.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deepspeed/ops/transformer/inference/triton/matmul_ext.py b/deepspeed/ops/transformer/inference/triton/matmul_ext.py index 412c8740a216..9be4b0098c37 100644 --- a/deepspeed/ops/transformer/inference/triton/matmul_ext.py +++ b/deepspeed/ops/transformer/inference/triton/matmul_ext.py @@ -19,6 +19,9 @@ # ----------------------------------------------------------------------------- # util class/functions for triton def is_nfs_path(path): + if os.name == 'nt': + return False + # Normalize the path to get the absolute path path = os.path.abspath(path) @@ -99,7 +102,7 @@ def put(self, table): with FileLock(self.lock_path): with open(self.file_path + ".tmp", 'wb') as handle: pickle.dump(table, handle) - os.rename(self.file_path + ".tmp", self.file_path) + os.replace(self.file_path + ".tmp", self.file_path) def load(self): if os.path.exists(self.file_path):