Skip to content

Commit

Permalink
Merge release 1.7.0 to master
Browse files Browse the repository at this point in the history
Merge release `1.7.0` to `master`
  • Loading branch information
f-dangel authored Nov 12, 2024
2 parents 1ebfb40 + 5706ccd commit 5eccc68
Show file tree
Hide file tree
Showing 170 changed files with 943 additions and 383 deletions.
6 changes: 3 additions & 3 deletions .conda_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- pytorch
- defaults
dependencies:
- pip=21.2.4
- python=3.8.5
- python=3.9.16
- pip=23.1.2
- pip:
- -e .[lint,test,doc]
- -e .[lint,test,docs]
28 changes: 14 additions & 14 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -30,10 +30,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -45,10 +45,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -61,10 +61,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -77,10 +77,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -92,10 +92,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -107,10 +107,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install --upgrade twine build
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
16 changes: 2 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ jobs:

strategy:
matrix:
python-version: [3.8, 3.9]
python-version: [3.9]
pytorch-version:
- "==1.9.1"
- "==1.10.1"
- "==1.11.0"
- "==1.12.1"
- "==1.13.1"
- "==2.0.1"
- "==2.2.0"
- "" # latest
steps:
- uses: actions/checkout@v1
Expand All @@ -46,10 +41,3 @@ jobs:
if: contains('refs/heads/master refs/heads/development refs/heads/release', github.ref) != 1
run: |
make test-light
- name: Test coveralls - python ${{ matrix.python-version }}
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.python-version }}
parallel: true
15 changes: 9 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ version: 2
sphinx:
configuration: docs_src/rtd/conf.py

build:
os: ubuntu-22.04
tools:
python: "3.9"

python:
version: 3.8
install:
- method: pip
path: .
extra_requirements:
- docs
system_packages: true
- method: pip
path: .
extra_requirements:
- docs
1 change: 1 addition & 0 deletions backpack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""BackPACK."""

from inspect import isclass
from types import TracebackType
from typing import Callable, Optional, Tuple, Type, Union
Expand Down
1 change: 1 addition & 0 deletions backpack/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Context class for BackPACK."""

from typing import Callable, Iterable, List, Tuple, Type

from torch.nn import Module
Expand Down
11 changes: 1 addition & 10 deletions backpack/core/derivatives/adaptive_avg_pool_nd.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Implements the derivatives for AdaptiveAvgPool."""

from typing import List, Tuple, Union
from warnings import warn

from torch import Size
from torch.nn import AdaptiveAvgPool1d, AdaptiveAvgPool2d, AdaptiveAvgPool3d

from backpack.core.derivatives.avgpoolnd import AvgPoolNDDerivatives
from backpack.utils import ADAPTIVE_AVG_POOL_BUG


class AdaptiveAvgPoolNDDerivatives(AvgPoolNDDerivatives):
Expand All @@ -28,14 +27,6 @@ def check_parameters(
Raises:
NotImplementedError: if the given shapes do not match
"""
if ADAPTIVE_AVG_POOL_BUG and module.input0.is_cuda and (self.N == 3):
warn(
"Be careful when computing gradients of AdaptiveAvgPool3d. "
"There is a bug using autograd.grad on cuda with AdaptiveAvgPool3d. "
"https://discuss.pytorch.org/t/bug-report-autograd-grad-adaptiveavgpool3d-cuda/124614 " # noqa: B950
"BackPACK derivatives are correct."
)

shape_input: Size = module.input0.shape
shape_output: Size = module.output.shape

Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/avgpoolnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Average pooling can be expressed as convolution over grouped channels with a constant
kernel.
"""

from typing import Any, List, Tuple

from einops import rearrange
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/basederivatives.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes for more flexible Jacobians and second-order information."""

import warnings
from abc import ABC
from typing import Callable, List, Tuple
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/batchnorm_nd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains derivatives for BatchNorm."""

from typing import List, Tuple, Union

from torch import Size, Tensor, einsum
Expand Down
9 changes: 2 additions & 7 deletions backpack/core/derivatives/conv_transposend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for ``torch.nn.ConvTranspose{1,2,3}d``."""

from typing import List, Tuple, Union

from einops import rearrange
Expand All @@ -7,19 +8,13 @@
from torch.nn import ConvTranspose1d, ConvTranspose2d, ConvTranspose3d, Module

from backpack.core.derivatives.basederivatives import BaseParameterDerivatives
from backpack.utils import TORCH_VERSION_AT_LEAST_1_13
from backpack.utils.conv import get_conv_function
from backpack.utils.conv import _grad_input_padding, get_conv_function
from backpack.utils.conv_transpose import (
get_conv_transpose_function,
unfold_by_conv_transpose,
)
from backpack.utils.subsampling import subsample

if TORCH_VERSION_AT_LEAST_1_13:
from backpack.utils.conv import _grad_input_padding
else:
from torch.nn.grad import _grad_input_padding


class ConvTransposeNDDerivatives(BaseParameterDerivatives):
"""Base class for partial derivatives of transpose convolution."""
Expand Down
8 changes: 1 addition & 7 deletions backpack/core/derivatives/convnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
from torch.nn import Conv1d, Conv2d, Conv3d, Module

from backpack.core.derivatives.basederivatives import BaseParameterDerivatives
from backpack.utils import TORCH_VERSION_AT_LEAST_1_13
from backpack.utils.conv import get_conv_function, unfold_by_conv
from backpack.utils.conv import _grad_input_padding, get_conv_function, unfold_by_conv
from backpack.utils.conv_transpose import get_conv_transpose_function
from backpack.utils.subsampling import subsample

if TORCH_VERSION_AT_LEAST_1_13:
from backpack.utils.conv import _grad_input_padding
else:
from torch.nn.grad import _grad_input_padding


class weight_jac_t_save_memory:
"""Choose algorithm to apply transposed convolution weight Jacobian."""
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/crossentropyloss.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for cross-entropy loss."""

from math import sqrt
from typing import Callable, Dict, List, Tuple

Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/dropout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the dropout layer."""

from typing import List, Tuple

from torch import Tensor, eq, ones_like
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/elu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the ELU activation function."""

from typing import List, Tuple

from torch import Tensor, exp, le, ones_like, zeros_like
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/embedding.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Derivatives for Embedding."""

from typing import List, Tuple

from torch import Tensor, einsum, zeros
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/flatten.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives of the flatten layer."""

from typing import List, Tuple

from torch import Tensor
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/leakyrelu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the leaky ReLU layer."""

from typing import List, Tuple

from torch import Tensor, gt
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/linear.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains partial derivatives for the ``torch.nn.Linear`` layer."""

from typing import List, Tuple

from torch import Size, Tensor, einsum
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/logsigmoid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains partial derivatives for the ``torch.nn.LogSigmoid`` layer."""

from typing import List, Tuple

from torch import Tensor, exp
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/lstm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for nn.LSTM."""

from typing import List, Tuple

from torch import Tensor, cat, einsum, sigmoid, tanh, zeros
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/nll_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivative bases for NLL losses."""

from math import sqrt
from typing import List, Tuple

Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/permute.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing derivatives of Permute."""

from typing import List, Tuple

from torch import Tensor, argsort
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/relu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the ReLU activation function."""

from typing import List, Tuple

from torch import Tensor, gt
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/rnn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the torch.nn.RNN layer."""

from typing import List, Tuple

from torch import Tensor, cat, einsum, zeros
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/scale_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Derivatives of ScaleModule (implies Identity)."""

from typing import List, Tuple, Union

from torch import Tensor
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/selu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the SELU activation function."""

from typing import List, Tuple

from torch import Tensor, exp, le, ones_like, zeros_like
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/shape_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Helpers to check input and output sizes of Jacobian-matrix products.
"""

import functools
from typing import Any, Callable

Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/sigmoid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the Sigmoid activation function."""

from typing import List, Tuple

from torch import Tensor
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/slicing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains derivatives of slicing operation."""

from typing import List, Tuple

from torch import Tensor, zeros
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/sum_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains derivatives for SumModule."""

from typing import List, Tuple

from torch import Tensor
Expand Down
1 change: 1 addition & 0 deletions backpack/core/derivatives/tanh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Partial derivatives for the Tanh activation function."""

from typing import List, Tuple

from torch import Tensor
Expand Down
Loading

0 comments on commit 5eccc68

Please sign in to comment.