Skip to content

Commit

Permalink
0.14.6 Release
Browse files Browse the repository at this point in the history
* Sync backend changes
  * Consistent C function signatures.

* Update changelog and readme

* Minor fix
  • Loading branch information
alihassanijr committed Mar 21, 2023
1 parent 2e5d3fd commit 3b54c76
Show file tree
Hide file tree
Showing 62 changed files with 10,110 additions and 202 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ dmypy.json

# Output files
*.out

# Don't commit manifest.in
MANIFEST.in
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.14.6] - 2023-03-21
Just a really small update that syncs the changes to the private branch.
It's mostly about the changed signature in both QK and AV (both 1D and 2D), where we now take in both kernel size and dilation.
Up to 0.14.4 we only took in dilation because QK always took in RPB, and RPB's shape is a function of kernel size, and AV took
in attention weights, whose last axis is of size kernel size (kernel size squared in 2D).
As of 0.14.5, we support optional RPB, which means now we have to take in kernel size in QK. To make the signatures consistent,
we added kernel size to AV as well, along with assertions that kernel sizes match up, but that was not synced from the private
branch when we pushed out 0.14.5 because we wanted to support PyTorch 2.0 as soon as possible.
0.14.6 is just mostly to keep the master branch consistent with the latest release, since the signature difference would create
an inconsistency between the pip package and the master branch.

## [0.14.5] - 2023-03-16

### Added
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 SHI Lab
Copyright (c) 2023 Ali Hassani.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.PHONY: clean uninstall install test style quality
.PHONY: sdist clean uninstall install-deps install test style quality

check_dirs := src tests

all: clean uninstall install

full: clean uninstall install-deps install

sdist:
@echo "Generating source dist"
python3 setup.py sdist
Expand Down Expand Up @@ -32,7 +34,6 @@ install-deps:

install:
@echo "Installing NATTEN from source"
${MAKE} install-deps
pip install -e . 2>&1 | tee install.out

test:
Expand Down
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,26 @@ We also welcome contributions in all forms.
Just refer to our website, [shi-labs.com/natten](https://www.shi-labs.com/natten/), select your PyTorch version and the CUDA
version it was compiled with, copy-paste the command and install in seconds!

For example, if you're on `torch==1.12.1+cu116`, you should install NATTEN using the following wheel:
For example, if you're on `torch==2.0.0+cu118`, you should install NATTEN using the following wheel:
```bash
pip3 install natten -f https://shi-labs.com/natten/wheels/cu116/torch1.12.1/index.html
pip3 install natten -f https://shi-labs.com/natten/wheels/cu118/torch2.0.0/index.html
```

More generally:
```bash
pip3 install natten -f https://shi-labs.com/natten/wheels/{cu_version}/torch{torch_version}/index.html
```

**NOTE:** If you do not specify a wheel URL, you will install a "placeholder" version of NATTEN, which is not usable.
We strongly recommend using our website, or building from source.
**NOTE:** If you do not specify a wheel URL, pip will collect NATTEN and try to compile on locally, which depending
on your system might take up to 30 minutes.
We strongly recommend using our website if you're a Linux user.

### Mac
Unfortunately we are not yet able to build Mac wheels, but you can compile on install, so just run:

```bash
pip3 install natten
```

### Windows
NATTEN should support Windows devices with CUDA, but does not yet have Windows wheels.
Expand All @@ -74,13 +82,13 @@ Once you've set up your Python environment and installed PyTorch with CUDA, simp
pip install ninja # Recommended, not required
git clone https://github.com/SHI-Labs/NATTEN
cd NATTEN
pip install -e .
make
```

#### Optional: unit tests
#### Optional: run unit tests
You can optionally run unit tests to verify building from source finished successfully:
```bash
python -m unittest discover -v -s ./tests
make test
```


Expand All @@ -93,7 +101,7 @@ python -m unittest discover -v -s ./tests
- [ ] Neighborhood Attention 3D (CPU)
- [x] Dilation support
- [x] Float16 support and utilization
- [ ] BFloat16 support (awaiting CUDA 11.8/12 builds of torch)
- [ ] BFloat16 support
- [ ] Kepler and Maxwell (30<=SM<60) support
- [ ] Windows builds

Expand Down Expand Up @@ -139,14 +147,11 @@ NATTEN is released under the [MIT License](LICENSE).

## Citation
```bibtex
@article{hassani2022neighborhood,
@inproceedings{hassani2023neighborhood,
title = {Neighborhood Attention Transformer},
author = {Ali Hassani and Steven Walton and Jiachen Li and Shen Li and Humphrey Shi},
year = 2022,
url = {https://arxiv.org/abs/2204.07143},
eprint = {2204.07143},
archiveprefix = {arXiv},
primaryclass = {cs.CV}
year = 2023,
booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}
}
@article{hassani2022dilated,
title = {Dilated Neighborhood Attention Transformer},
Expand Down
33 changes: 22 additions & 11 deletions assets/README_pypi.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,26 @@ We also welcome contributions in all forms.
Just refer to our website, [shi-labs.com/natten](https://www.shi-labs.com/natten/), select your PyTorch version and the CUDA
version it was compiled with, copy-paste the command and install in seconds!

For example, if you're on `torch==1.12.1+cu116`, you should install NATTEN using the following wheel:
For example, if you're on `torch==2.0.0+cu118`, you should install NATTEN using the following wheel:
```bash
pip3 install natten -f https://shi-labs.com/natten/wheels/cu116/torch1.12.1/index.html
pip3 install natten -f https://shi-labs.com/natten/wheels/cu118/torch2.0.0/index.html
```

More generally:
```bash
pip3 install natten -f https://shi-labs.com/natten/wheels/{cu_version}/torch{torch_version}/index.html
```

**NOTE:** If you do not specify a wheel URL, you will install a "placeholder" version of NATTEN, which is not usable.
We strongly recommend using our website, or building from source.
**NOTE:** If you do not specify a wheel URL, pip will collect NATTEN and try to compile on locally, which depending
on your system might take up to 30 minutes.
We strongly recommend using our website if you're a Linux user.

### Mac
Unfortunately we are not yet able to build Mac wheels, but you can compile on install, so just run:

```bash
pip3 install natten
```

### Windows
NATTEN should support Windows devices with CUDA, but does not yet have Windows wheels.
Expand All @@ -74,7 +82,13 @@ Once you've set up your Python environment and installed PyTorch with CUDA, simp
pip install ninja # Recommended, not required
git clone https://github.com/SHI-Labs/NATTEN
cd NATTEN
pip install -e .
make
```

#### Optional: run unit tests
You can optionally run unit tests to verify building from source finished successfully:
```bash
make test
```


Expand Down Expand Up @@ -133,14 +147,11 @@ NATTEN is released under the [MIT License](https://github.com/SHI-Labs/NATTEN/bl

## Citation
```bibtex
@article{hassani2022neighborhood,
@inproceedings{hassani2023neighborhood,
title = {Neighborhood Attention Transformer},
author = {Ali Hassani and Steven Walton and Jiachen Li and Shen Li and Humphrey Shi},
year = 2022,
url = {https://arxiv.org/abs/2204.07143},
eprint = {2204.07143},
archiveprefix = {arXiv},
primaryclass = {cs.CV}
year = 2023,
booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}
}
@article{hassani2022dilated,
title = {Dilated Neighborhood Attention Transformer},
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-f https://download.pytorch.org/whl/cu117
torch==1.13.0
-f https://download.pytorch.org/whl/cu117
torchvision==0.14.0
-f https://download.pytorch.org/whl/cu118
torch==2.0.0
-f https://download.pytorch.org/whl/cu118
torchvision==0.15.1
ninja
flake8
black
Expand Down
29 changes: 23 additions & 6 deletions src/natten/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
"""
Neighborhood Attention
#################################################################################################
# Copyright (c) 2023 Ali Hassani.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#################################################################################################

This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from .natten1d import NeighborhoodAttention1D
from .natten2d import NeighborhoodAttention2D

__version__ = "0.14.5"
__version__ = "0.14.6"
27 changes: 27 additions & 0 deletions src/natten/csrc/context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/***************************************************************************************************
* Copyright (c) 2023 Ali Hassani.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**************************************************************************************************/

namespace natten {

} // namespace natten

29 changes: 24 additions & 5 deletions src/natten/csrc/cpu/natten1dav_cpu_kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
/*
NATTEN1D-AV TORCH EXTENSION (CPU)
/***************************************************************************************************
* Copyright (c) 2023 Ali Hassani.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**************************************************************************************************/

This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
*/
#include <torch/extension.h>
#include <vector>
#include <ATen/ATen.h>
#include <ATen/AccumulateType.h>

#if defined(AVX_INT)
#include <ATen/cpu/vec/functional.h>
#include <ATen/cpu/vec/vec.h>
#endif

#include "natten_cpu_commons.h"

namespace natten {
Expand Down
29 changes: 24 additions & 5 deletions src/natten/csrc/cpu/natten1dqkrpb_cpu_kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
/*
NATTEN1D-QKRPB TORCH EXTENSION (CPU)
/***************************************************************************************************
* Copyright (c) 2023 Ali Hassani.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**************************************************************************************************/

This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
*/
#include <torch/extension.h>
#include <vector>
#include <ATen/ATen.h>
#include <ATen/AccumulateType.h>

#if defined(AVX_INT)
#include <ATen/cpu/vec/functional.h>
#include <ATen/cpu/vec/vec.h>
#endif

#include "natten_cpu_commons.h"

namespace natten {
Expand Down
29 changes: 24 additions & 5 deletions src/natten/csrc/cpu/natten2dav_cpu_kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
/*
NATTEN2D-AV TORCH EXTENSION (CPU)
/***************************************************************************************************
* Copyright (c) 2023 Ali Hassani.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**************************************************************************************************/

This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
*/
#include <torch/extension.h>
#include <vector>
#include <ATen/ATen.h>
#include <ATen/AccumulateType.h>

#if defined(AVX_INT)
#include <ATen/cpu/vec/functional.h>
#include <ATen/cpu/vec/vec.h>
#endif

#include "natten_cpu_commons.h"

namespace natten {
Expand Down
Loading

0 comments on commit 3b54c76

Please sign in to comment.