Skip to content

Commit 970b8e4

Browse files
authored
ci: Test dependency lower bounds (#553)
* Increase permutation invariance tolerance for UPGrad * Stop using nn.Buffer in tests (did not exist in torch 2.3.0) * Add testing of dependency lower-bounds * Increase lower bound of numpy to 1.21.2 (from 1.21.0) and of torch to 2.3.0 (from 2.0.0) * Add changelog entry
1 parent 4912882 commit 970b8e4

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

.github/workflows/checks.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
tests:
1414
# Default config: py3.14, ubuntu-latest, float32, full options.
1515
# The idea is to make each of those params vary one by one, to limit the number of tests to run.
16-
name: Tests (py${{ matrix.python-version || '3.14' }}, ${{ matrix.os || 'ubuntu-latest' }}, ${{ matrix.dtype || 'float32' }}, ${{ matrix.options || 'full' }})
16+
name: Tests (py${{ matrix.python-version || '3.14' }}, ${{ matrix.os || 'ubuntu-latest' }}, ${{ matrix.dtype || 'float32' }}, ${{ matrix.options || 'full' }}${{ matrix.extra_groups && format(', {0}', matrix.extra_groups) || '' }})
1717
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
1818
strategy:
1919
fail-fast: false
@@ -32,6 +32,9 @@ jobs:
3232
- dtype: float64
3333
# Installation options variations
3434
- options: 'none'
35+
# Lower-bounds of all dependencies and Python version.
36+
- python-version: '3.10.0'
37+
extra_groups: 'lower_bounds'
3538

3639
steps:
3740
- name: Checkout repository
@@ -45,7 +48,7 @@ jobs:
4548
- uses: ./.github/actions/install-deps
4649
with:
4750
options: ${{ matrix.options || 'full' }}
48-
groups: test
51+
groups: test ${{ matrix.extra_groups }}
4952

5053
- name: Run tests
5154
run: uv run pytest -W error tests/unit tests/doc --cov=src --cov-report=xml

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ changelog does not include internal changes that do not affect the user.
5050
of `autojac`.
5151
- Removed an unnecessary internal cloning of gradient. This should slightly improve the memory
5252
efficiency of `autojac`.
53+
- Increased the lower bounds of the torch (from 2.0.0 to 2.3.0) and numpy (from 1.21.0
54+
to 1.21.2) dependencies to reflect what really works with torchjd. We now also run torchjd's tests
55+
with the dependency lower-bounds specified in `pyproject.toml`, so we should now always accurately
56+
reflect the actual lower-bounds.
5357

5458
## [0.8.1] - 2026-01-07
5559

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ authors = [
1313
]
1414
requires-python = ">=3.10"
1515
dependencies = [
16-
"torch>=2.0.0",
16+
"torch>=2.3.0", # Problems before 2.4.0, especially with autogram.
1717
"quadprog>=0.1.9, != 0.1.10", # Doesn't work before 0.1.9, 0.1.10 is yanked
18-
"numpy>=1.21.0", # Does not work before 1.21
18+
"numpy>=1.21.2", # Does not work before 1.21. No python 3.10 wheel before 1.21.2.
1919
"qpsolvers>=1.0.1", # Does not work before 1.0.1
2020
]
2121
classifiers = [
@@ -83,7 +83,7 @@ test = [
8383
"pytest>=7.3", # Before version 7.3, not all tests are run
8484
"pytest-cov>=6.0.0", # Recent version to avoid problems, could be relaxed
8585
"lightning>=2.0.9", # No OptimizerLRScheduler public type before 2.0.9
86-
"torchvision>=0.22.1" # Recent version to avoid problems, could be relaxed
86+
"torchvision>=0.18.0"
8787
]
8888

8989
plot = [
@@ -92,6 +92,13 @@ plot = [
9292
"kaleido==0.2.1", # Only works with locked version
9393
"matplotlib>=3.10.0", # Recent version to avoid problems, could be relaxed
9494
]
95+
# Dependency group allowing to easily resolve version of the core dependencies to the lower bound.
96+
lower_bounds = [
97+
"torch==2.3.0",
98+
"numpy==1.21.2",
99+
"quadprog==0.1.9",
100+
"qpsolvers==1.0.1",
101+
]
95102

96103
[project.optional-dependencies]
97104
nash_mtl = [

tests/unit/aggregation/test_upgrad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_non_conflicting(aggregator: UPGrad, matrix: Tensor):
3333

3434
@mark.parametrize(["aggregator", "matrix"], typical_pairs)
3535
def test_permutation_invariant(aggregator: UPGrad, matrix: Tensor):
36-
assert_permutation_invariant(aggregator, matrix, n_runs=5, atol=4e-07, rtol=4e-07)
36+
assert_permutation_invariant(aggregator, matrix, n_runs=5, atol=5e-07, rtol=5e-07)
3737

3838

3939
@mark.parametrize(["aggregator", "matrix"], typical_pairs)

tests/utils/architectures.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,11 @@ class WithBuffered(ShapedModule):
595595
OUTPUT_SHAPES = (10,)
596596

597597
class _Buffered(nn.Module):
598+
buffer: Tensor
599+
598600
def __init__(self):
599601
super().__init__()
600-
self.buffer = nn.Buffer(torch.tensor(1.5))
602+
self.register_buffer("buffer", torch.tensor(1.5))
601603

602604
def forward(self, input: Tensor) -> Tensor:
603605
return input * self.buffer
@@ -636,7 +638,7 @@ class WithSideEffect(ShapedModule):
636638
def __init__(self):
637639
super().__init__()
638640
self.matrix = nn.Parameter(torch.randn(9, 10))
639-
self.buffer = nn.Buffer(torch.zeros((9,)))
641+
self.register_buffer("buffer", torch.zeros((9,)))
640642

641643
def forward(self, input: Tensor) -> Tensor:
642644
self.buffer = self.buffer + 1.0

0 commit comments

Comments
 (0)