Skip to content

Commit 302c707

Browse files
authored
Fix pytorch versions ci (#3289)
* Fixed torch.pi usage unavailable in pytorch 1.5.1, 1.8.1 * Fix pytorch versions CI failures
1 parent 6a1ef07 commit 302c707

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Diff for: .github/workflows/pytorch-version-tests.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@ jobs:
1919
# will drop python version and related pytorch versions
2020
python-version: [3.8, 3.9, "3.10"]
2121
pytorch-version:
22-
[2.3.1, 2.2.2, 2.1.2, 2.0.1, 1.13.1, 1.12.1, 1.10.0, 1.8.1, 1.5.1]
22+
[2.3.1, 2.2.2, 2.1.2, 2.0.1, 1.13.1, 1.12.1, 1.10.0, 1.8.1]
2323
exclude:
24-
- pytorch-version: 1.5.1
25-
python-version: 3.9
26-
- pytorch-version: 1.5.1
27-
python-version: "3.10"
28-
2924
# disabling python 3.9 support with PyTorch 1.7.1 and 1.8.1, to stop repeated pytorch-version test fail.
3025
# https://github.com/pytorch/ignite/issues/2383
3126
- pytorch-version: 1.8.1
@@ -74,6 +69,13 @@ jobs:
7469
shell: bash -l {0}
7570
run: |
7671
conda install pytorch=${{ matrix.pytorch-version }} torchvision cpuonly python=${{ matrix.python-version }} -c pytorch
72+
73+
# We should install numpy<2.0 for pytorch<2.3
74+
numpy_one_pth_version=$(python -c "import torch; print(float('.'.join(torch.__version__.split('.')[:2])) < 2.3)")
75+
if [ "${numpy_one_pth_version}" == "True" ]; then
76+
pip install -U "numpy<2.0"
77+
fi
78+
7779
pip install -r requirements-dev.txt
7880
python setup.py install
7981

Diff for: ignite/metrics/hsic.py

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def update(self, output: Sequence[Tensor]) -> None:
134134

135135
vx: Union[Tensor, float]
136136
if self.sigma_x < 0:
137+
# vx = torch.quantile(dxx, 0.5)
137138
vx = torch.quantile(dxx, 0.5)
138139
else:
139140
vx = self.sigma_x**2

Diff for: tests/ignite/metrics/test_hsic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
from typing import Tuple
23

34
import numpy as np
@@ -74,7 +75,7 @@ def test_case(request) -> Tuple[Tensor, Tensor, int]:
7475
N = 200
7576
b = 20
7677
x = torch.randn(N, 5)
77-
y = x @ torch.normal(0.0, torch.pi, size=(5, 3))
78+
y = x @ torch.normal(0.0, math.pi, size=(5, 3))
7879
y = (
7980
torch.stack([torch.sin(y[:, 0]), torch.cos(y[:, 1]), torch.exp(y[:, 2])], dim=1)
8081
+ torch.randn_like(y) * 1e-4

0 commit comments

Comments
 (0)