Skip to content

Commit e2ba3df

Browse files
authored
Merge pull request #939 from ProGamerGov/optim-wip-master-1
Optim-wip: Merge master branch into optim-wip
2 parents 77c80f0 + 9bb7d47 commit e2ba3df

File tree

310 files changed

+31983
-3751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+31983
-3751
lines changed

.circleci/config.yml

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,12 @@ commands:
3131
name: "Lint with flake8"
3232
command: flake8
3333

34-
lint_black:
35-
description: "Lint with black"
34+
ufmt_check:
35+
description: "Check formatting with ufmt"
3636
steps:
3737
- run:
38-
name: "Lint with black"
39-
command: black --check --diff .
40-
41-
isort:
42-
description: "Check import order with isort"
43-
steps:
44-
- run:
45-
name: "Check import order with isort"
46-
command: isort --check-only -v .
38+
name: "Check formatting with ufmt"
39+
command: ufmt check .
4740

4841
mypy_check:
4942
description: "Static type checking with mypy"
@@ -86,7 +79,7 @@ commands:
8679
name: "Deploy website to GitHub Pages"
8780
# TODO: make the installation above conditional on there being relevant changes (no need to install if there are none)
8881
command: |
89-
if ! git diff --name-only HEAD^ | grep -E "(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then
82+
if ! git diff --name-only HEAD^ | grep -E "(^captum\/.*)|(^\.circleci\/.*)|(^docs\/.*)|(^website\/.*)|(^scripts\/.*)|(^sphinx\/.*)|(^tutorials\/.*)"; then
9083
echo "Skipping deploy. No relevant website files have changed"
9184
elif [[ $CIRCLE_PROJECT_USERNAME == "pytorch" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then
9285
mkdir -p website/static/.circleci && cp -a .circleci/. website/static/.circleci/.
@@ -113,6 +106,7 @@ commands:
113106
name: "Switch to Python v3.7"
114107
command: |
115108
pyenv versions
109+
pyenv install 3.7.0
116110
pyenv global 3.7.0
117111
118112
install_cuda:
@@ -121,76 +115,96 @@ commands:
121115
- run:
122116
name: "Install CUDA"
123117
command: |
124-
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-ubuntu1604.pin
125-
sudo mv cuda-ubuntu1604.pin /etc/apt/preferences.d/cuda-repository-pin-600
126-
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1604-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
127-
sudo dpkg -i cuda-repo-ubuntu1604-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
128-
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
118+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
119+
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
120+
wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb
121+
sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb
122+
sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub
129123
sudo apt-get update
130124
sudo apt-get --yes --force-yes install cuda
131125
132126
jobs:
133127

134-
lint_test_py36_pip:
128+
lint_py36:
129+
docker:
130+
- image: circleci/python:3.6.8
131+
steps:
132+
- checkout
133+
- pip_install
134+
- lint_flake8
135+
- ufmt_check
136+
- sphinx
137+
138+
test_py36_pip:
135139
docker:
136140
- image: circleci/python:3.6.8
137141
steps:
138142
- checkout
139143
- pip_install:
140144
args: "-n"
141-
- lint_flake8
142-
- lint_black
143-
- isort
145+
- mypy_check
144146
- unit_tests
145-
- sphinx
146147

147-
lint_test_py36_pip_release:
148+
test_py36_pip_release:
148149
docker:
149150
- image: circleci/python:3.6.8
150151
steps:
151152
- checkout
152153
- pip_install
153-
- lint_flake8
154-
- lint_black
155-
- isort
156154
- mypy_check
157155
- unit_tests
158-
- sphinx
159156

160-
test_py36_pip_torch_1_3:
157+
test_py36_pip_torch_1_6:
158+
docker:
159+
- image: circleci/python:3.6.8
160+
steps:
161+
- checkout
162+
- pip_install:
163+
args: "-v 1.6"
164+
- unit_tests
165+
166+
test_py36_pip_torch_1_7:
161167
docker:
162168
- image: circleci/python:3.6.8
163169
steps:
164170
- checkout
165171
- pip_install:
166-
args: "-v 1.3"
172+
args: "-v 1.7"
167173
- unit_tests
168174

169-
test_py36_pip_torch_1_2:
175+
test_py36_pip_torch_1_8:
170176
docker:
171177
- image: circleci/python:3.6.8
172178
steps:
173179
- checkout
174180
- pip_install:
175-
args: "-v 1.2"
181+
args: "-v 1.8"
176182
- unit_tests
177183

178-
lint_test_py37_conda:
184+
test_py36_pip_torch_1_9:
185+
docker:
186+
- image: circleci/python:3.6.8
187+
steps:
188+
- checkout
189+
- pip_install:
190+
args: "-v 1.9"
191+
- unit_tests
192+
193+
194+
test_py37_conda:
179195
docker:
180196
- image: continuumio/miniconda3
181197
steps:
182198
- checkout
183199
- conda_install:
184200
args: "-n"
185-
- lint_flake8
186-
- isort
187201
- unit_tests
188-
- sphinx
202+
189203

190204
test_cuda_multi_gpu:
191205
machine:
192-
image: ubuntu-1604:201903-01
193-
resource_class: gpu.large
206+
image: ubuntu-2004:202201-02
207+
resource_class: gpu.nvidia.medium.multi
194208
steps:
195209
- checkout
196210
- install_cuda
@@ -205,11 +219,6 @@ jobs:
205219
- checkout
206220
- pip_install:
207221
args: "-n -d"
208-
- lint_flake8
209-
- lint_black
210-
- isort
211-
- unit_tests
212-
- sphinx
213222
- configure_github_bot
214223
- deploy_site
215224

@@ -225,24 +234,38 @@ aliases:
225234

226235
workflows:
227236

228-
lint_and_test:
237+
lint_test_and_deploy_site:
229238
jobs:
230-
- lint_test_py36_pip:
239+
- lint_py36:
231240
filters: *exclude_ghpages_fbconfig
232-
- lint_test_py36_pip_release:
241+
- test_py36_pip:
233242
filters: *exclude_ghpages_fbconfig
234-
- lint_test_py37_conda:
243+
- test_py36_pip_release:
235244
filters: *exclude_ghpages_fbconfig
236-
- test_py36_pip_torch_1_2:
245+
- test_py37_conda:
237246
filters: *exclude_ghpages_fbconfig
238-
- test_py36_pip_torch_1_3:
247+
- test_py36_pip_torch_1_6:
248+
filters: *exclude_ghpages_fbconfig
249+
- test_py36_pip_torch_1_7:
250+
filters: *exclude_ghpages_fbconfig
251+
- test_py36_pip_torch_1_8:
252+
filters: *exclude_ghpages_fbconfig
253+
- test_py36_pip_torch_1_9:
239254
filters: *exclude_ghpages_fbconfig
240255
- test_cuda_multi_gpu:
241256
filters: *exclude_ghpages_fbconfig
242257

243-
auto_deploy_site:
244-
jobs:
245258
- auto_deploy_site:
259+
requires:
260+
- lint_py36
261+
- test_py36_pip
262+
- test_py36_pip_release
263+
- test_py37_conda
264+
- test_py36_pip_torch_1_6
265+
- test_py36_pip_torch_1_7
266+
- test_py36_pip_torch_1_8
267+
- test_py36_pip_torch_1_9
268+
- test_cuda_multi_gpu
246269
filters:
247270
branches:
248271
only:

.conda/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ requirements:
1616
- python>=3.6
1717
run:
1818
- numpy
19-
- pytorch>=1.2
20-
- matplotlib
19+
- pytorch>=1.6
20+
- matplotlib-base
2121

2222
test:
2323
imports:

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
tutorials/* linguist-documentation
2+
*.pt binary

.github/ISSUE_TEMPLATE/---documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ assignees: ''
99

1010
## 📚 Documentation
1111

12-
<!-- A clear and concise description of what content in https://captum.ai/docs, https://captum.ai/tutorials or https://captum.ai/api is an issue.
12+
<!-- A clear and concise description of what content in https://captum.ai/docs, https://captum.ai/tutorials or https://captum.ai/api is an issue.
1313
Feel free also to file an issue if you see any problems in the README.md or in the code documentation
1414
-->

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ website/pages/tutorials/*
109109

110110
## Generated for Sphinx
111111
website/pages/api/
112-
website/static/js/*
113-
!website/static/js/mathjax.js
114-
!website/static/js/code_block_buttons.js
115-
website/static/_sphinx-sources/
116-
node_modules
112+
website/static/_sphinx/
113+
114+
# Insight
115+
captum/insights/attr_vis/frontend/node_modules/
116+
captum/insights/attr_vis/widget/static

.isort.cfg

Lines changed: 0 additions & 7 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Contributing to Captum
22

3-
We want to make contributing to Captum as easy and transparent as possible.
3+
Thank you for your interest in contributing to Captum! We want to make contributing to Captum as easy and transparent as possible.
4+
Before you begin writing code, it is important that you share your intention to contribute with the team, based on the type of contribution:
5+
6+
7+
1. You want to propose and implement a new algorithm, add a new feature or fix a bug. This can be both code and documentation proposals.
8+
1. For all non-outstanding features, bug-fixes and algorithms in the Captum issue list (https://github.com/pytorch/captum/issues) please create an issue first.
9+
2. If the implementation requires API or any other major code changes (new files, packages or algorithms), we will likely request a design document to review and discuss the design and implementation before making changes. An example design document for LIME can be found here (https://github.com/pytorch/captum/issues/467).
10+
3. Once we agree that the plan looks good or confirmed that the change is small enough to not require a detailed design discussion, go ahead and implement it!
11+
12+
2. You want to implement a feature or bug-fix for an outstanding issue.
13+
14+
1. Search for your issue in the Captum issue list (https://github.com/pytorch/captum/issues).
15+
2. Pick an issue and comment that you'd like to work on the feature or bug-fix.
16+
3. If you need more context on a particular issue, please ask and we’ll be happy to help.
17+
18+
Once you implement and test your feature or bug-fix, please submit a Pull Request to https://github.com/pytorch/captum (https://github.com/pytorch/pytorch).
19+
20+
This document covers some of the techical aspects of contributing to Captum. More details on what we are looking for in the contributions can be found in the [Contributing Guidelines](https://captum.ai/docs/contribution_guidelines).
421

522

623
## Development installation
@@ -18,45 +35,35 @@ pip install -e .[dev]
1835

1936
#### Code Style
2037

21-
Captum uses [black](https://github.com/ambv/black) and [flake8](https://github.com/PyCQA/flake8) to
22-
enforce a common code style across the code base. black and flake8 are installed easily via
23-
pip using `pip install black flake8`, and run locally by calling
38+
Captum uses [ufmt](https://pypi.org/project/ufmt/) and [flake8](https://github.com/PyCQA/flake8) to
39+
enforce a common code style across the code base. ufmt and flake8 are installed easily via
40+
pip using `pip install ufmt flake8`, and run locally by calling
2441
```bash
25-
black .
42+
ufmt format .
2643
flake8 .
2744
```
28-
from the repository root. No additional configuration should be needed (see the
29-
[black documentation](https://black.readthedocs.io/en/stable/installation_and_usage.html#usage)
30-
for advanced usage).
31-
32-
Captum also uses [isort](https://github.com/timothycrosley/isort) to sort imports
33-
alphabetically and separate into sections. isort is installed easily via
34-
pip using `pip install isort`, and run locally by calling
35-
```bash
36-
isort
37-
```
38-
from the repository root. Configuration for isort is located in .isort.cfg.
45+
from the repository root.
3946

4047
We feel strongly that having a consistent code style is extremely important, so
41-
CircleCI will fail on your PR if it does not adhere to the black or flake8 formatting style or isort import ordering.
48+
CircleCI will fail on your PR if it does not adhere to the ufmt or flake8 formatting style.
4249

4350

4451
#### Type Hints
4552

4653
Captum is fully typed using python 3.6+
4754
[type hints](https://www.python.org/dev/peps/pep-0484/).
48-
We expect any contributions to also use proper type annotations, and we enforce
49-
consistency of these in our continuous integration tests.
55+
We expect any contributions to also use proper type annotations, and we enforce
56+
consistency of these in our continuous integration tests.
5057

51-
To type check your code locally, install [mypy](https://github.com/python/mypy),
58+
To type check your code locally, install [mypy](https://github.com/python/mypy),
5259
which can be done with pip using `pip install "mypy>=0.760"`
5360
Then run this script from the repository root:
5461
```bash
5562
./scripts/run_mypy.sh
5663
```
57-
Note that we expect mypy to have version 0.760 or higher, and when type checking, use PyTorch 1.4 or
58-
higher due to fixes to PyTorch type hints available in 1.4. We also use the Literal feature which is
59-
available only in Python 3.8 or above. If type-checking using a previous version of Python, you will
64+
Note that we expect mypy to have version 0.760 or higher, and when type checking, use PyTorch 1.4 or
65+
higher due to fixes to PyTorch type hints available in 1.4. We also use the Literal feature which is
66+
available only in Python 3.8 or above. If type-checking using a previous version of Python, you will
6067
need to install the typing-extension package which can be done with pip using `pip install typing-extensions`.
6168

6269
#### Unit Tests

0 commit comments

Comments
 (0)