Skip to content

Commit

Permalink
Fix building on Windows with presence of Triton (#6749)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
woct0rdho and loadams authored Jan 8, 2025
1 parent 6628127 commit b62c84d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deepspeed/ops/transformer/inference/triton/matmul_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b62c84d

Please # to comment.