Skip to content

Commit 736c50a

Browse files
authored
Expand test matrix to also install different computation backends (#90)
* also install torchvision and torchaudio * test cu116 * fix candidate selection * revert cu116 * try computation backend ci * fix rocm install * fix cu102 * disable rocm for now
1 parent 91ce620 commit 736c50a

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

.github/workflows/install.yml

Lines changed: 87 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
pull_request:
1010

1111
jobs:
12-
torch_cpu:
12+
channel:
1313
strategy:
1414
matrix:
1515
os:
@@ -49,14 +49,96 @@ jobs:
4949
- name: Collect environment information
5050
run: python scripts/collect_env.py
5151

52-
- name: Install torch
53-
run: ltt install --cpuonly --pytorch-channel=${{ matrix.pytorch-channel }} torch
52+
- name: Install PyTorch distributions
53+
run:
54+
ltt install --pytorch-channel=${{ matrix.pytorch-channel }} torch torchvision
55+
torchaudio
5456

5557
- name: Check if CPU only
5658
shell: python
5759
run: |
5860
import sys
5961
import torch
6062
61-
compiled_with_cuda = hasattr(torch._C, "_cuda_getDeviceCount")
62-
sys.exit(compiled_with_cuda)
63+
cuda = torch.version.cuda
64+
print(f"cuda = {cuda}")
65+
66+
hip = torch.version.hip
67+
print(f"hip = {hip}")
68+
69+
sys.exit(cuda or hip)
70+
71+
computation-backend:
72+
strategy:
73+
matrix:
74+
os:
75+
- ubuntu-latest
76+
- windows-latest
77+
- macos-latest
78+
python-version:
79+
- "3.7"
80+
- "3.8"
81+
- "3.9"
82+
- "3.10"
83+
pytorch-computation-backend:
84+
- cpu
85+
- cu113
86+
- cu116
87+
exclude:
88+
- os: macos-latest
89+
pytorch-computation-backend: cu113
90+
- os: macos-latest
91+
pytorch-computation-backend: cu116
92+
include:
93+
- os: ubuntu-latest
94+
pytorch-computation-backend: cu102
95+
# TODO: find a way to test this
96+
# - os: ubuntu-latest
97+
# pytorch-computation-backend: rocm5.1.1
98+
fail-fast: false
99+
100+
runs-on: ${{ matrix.os }}
101+
102+
steps:
103+
- name: Checkout repository
104+
uses: actions/checkout@v2
105+
with:
106+
fetch-depth: 0
107+
108+
- name: Setup development environment
109+
uses: ./.github/actions/setup-dev-env
110+
with:
111+
python-version: ${{ matrix.python-version }}
112+
113+
- name: Collect environment information
114+
run: python scripts/collect_env.py
115+
116+
- name: Install torch
117+
run:
118+
ltt install --pytorch-computation-backend=${{
119+
matrix.pytorch-computation-backend }} torch==1.12.1
120+
121+
- name: Check computation backend
122+
shell: python
123+
run: |
124+
import sys
125+
import torch
126+
from light_the_torch._cb import ComputationBackend, CUDABackend, ROCmBackend, CPUBackend
127+
128+
expected = ComputationBackend.from_str("${{ matrix.pytorch-computation-backend }}")
129+
130+
cuda = torch.version.cuda
131+
print(f"cuda = {cuda}")
132+
133+
hip = torch.version.hip
134+
print(f"hip = {hip}")
135+
136+
if cuda:
137+
actual = CUDABackend.from_str(f"cu{torch.version.cuda}")
138+
elif hip:
139+
rocm = ".".join(torch.version.hip.split(".")[:2])
140+
actual = ROCmBackend.from_str(f"rocm{rocm}")
141+
else:
142+
actual = CPUBackend()
143+
144+
sys.exit(actual != expected)

light_the_torch/_patch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ def extract_local_specifier(candidate):
278278
return local
279279

280280
def preprocessing(input):
281+
if not input.candidates:
282+
return
283+
281284
candidates = iter(input.candidates)
282285
candidate = next(candidates)
283286

0 commit comments

Comments
 (0)