Skip to content

Commit 7d51139

Browse files
authored
Make installable without torch (#5001)
Fixes #4984
1 parent 538ffb4 commit 7d51139

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.github/workflows/release.yml

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ jobs:
1616
ref: "master"
1717
- id: setup-venv
1818
uses: ./.github/workflows/setup-venv
19-
- name: Install torch
20-
run: |
21-
pip install torch
2219
- name: Get release version from tag
2320
run: |
2421
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

op_builder/xpu/async_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import distutils.spawn
77
import subprocess
8-
import torch
98

109
from .builder import OpBuilder
1110

@@ -33,6 +32,7 @@ def include_paths(self):
3332
return ['csrc/aio/py_lib', 'csrc/aio/common']
3433

3534
def cxx_args(self):
35+
import torch
3636
# -O0 for improved debugging, since performance is bound by I/O
3737
CPU_ARCH = self.cpu_arch()
3838
SIMD_WIDTH = self.simd_width()

op_builder/xpu/builder.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# is op_builder from deepspeed or a 3p version? this should only succeed if it's deepspeed
1212
# if successful this also means we're doing a local install and not JIT compile path
1313
from op_builder import __deepspeed__ # noqa: F401 # type: ignore
14-
from op_builder.builder import OpBuilder, TORCH_MAJOR, TORCH_MINOR
14+
from op_builder.builder import OpBuilder
1515
except ImportError:
16-
from deepspeed.ops.op_builder.builder import OpBuilder, TORCH_MAJOR, TORCH_MINOR
16+
from deepspeed.ops.op_builder.builder import OpBuilder
1717

1818

1919
class SYCLOpBuilder(OpBuilder):
@@ -35,6 +35,10 @@ def builder(self):
3535
return dpcpp_ext
3636

3737
def version_dependent_macros(self):
38+
try:
39+
from op_builder.builder import TORCH_MAJOR, TORCH_MINOR
40+
except ImportError:
41+
from deepspeed.ops.op_builder.builder import TORCH_MAJOR, TORCH_MINOR
3842
# Fix from apex that might be relevant for us as well, related to https://github.com/NVIDIA/apex/issues/456
3943
version_ge_1_1 = []
4044
if (TORCH_MAJOR > 1) or (TORCH_MAJOR == 1 and TORCH_MINOR > 0):

0 commit comments

Comments
 (0)