Skip to content

Commit 3400ff0

Browse files
Karthik Prasadfacebook-github-bot
Karthik Prasad
authored andcommitted
Move CI to Github Actions (#620)
Summary: Moves the continuous integration (CI) processy from CircleCI to Github Actions. The changes include creating a new ci.yml file to define the CI workflow that largely mimics the existing circleCi config. Differential Revision: D53107145
1 parent f4dc430 commit 3400ff0

File tree

2 files changed

+465
-0
lines changed

2 files changed

+465
-0
lines changed

.github/workflows/ci.yml

+346
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: '4 4 * * *' # This schedule runs the nightly job every night at 4:04AM
12+
13+
14+
jobs:
15+
lint_py39_torch_release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Set up Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: 3.9
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install flake8 black isort
28+
./scripts/install_via_pip.sh
29+
- name: Lint with flake8
30+
run: flake8 --config ./.github/workflows/flake8_config.ini
31+
- name: Lint with black
32+
run: black --check --diff --color .
33+
- name: Check import order with isort
34+
run: isort -v -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma --check-only .
35+
36+
unittest_py38_torch_release:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v2
41+
- name: Set up Python
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: 3.8
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install pytest coverage coveralls
49+
./scripts/install_via_pip.sh
50+
- name: Run unit tests
51+
run: |
52+
mkdir unittest-py38-release-reports
53+
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py38-release-reports/junit.xml opacus
54+
coverage report -i -m
55+
- name: Store test results
56+
uses: actions/upload-artifact@v2
57+
with:
58+
name: unittest-py38-release-reports
59+
path: unittest-py38-release-reports
60+
61+
unittest_py39_torch_release:
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v2
66+
- name: Set up Python
67+
uses: actions/setup-python@v2
68+
with:
69+
python-version: 3.9
70+
- name: Install dependencies
71+
run: |
72+
python -m pip install --upgrade pip
73+
pip install pytest coverage coveralls
74+
./scripts/install_via_pip.sh
75+
- name: Run unit tests
76+
run: |
77+
mkdir unittest-py39-release-reports
78+
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py39-release-reports/junit.xml opacus
79+
coverage report -i -m
80+
- name: Store test results
81+
uses: actions/upload-artifact@v2
82+
with:
83+
name: unittest-py39-release-reports
84+
path: unittest-py39-release-reports
85+
86+
unittest_py39_torch_nightly:
87+
runs-on: ubuntu-latest
88+
if: ${{ github.event_name == 'schedule' }}
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v2
92+
- name: Set up Python
93+
uses: actions/setup-python@v2
94+
with:
95+
python-version: 3.9
96+
- name: Install dependencies
97+
run: |
98+
python -m pip install --upgrade pip
99+
pip install pytest coverage coveralls
100+
./scripts/install_via_pip.sh -n
101+
- name: Run unit tests
102+
run: |
103+
mkdir unittest-py39-nightly-reports
104+
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py39-nightly-reports/junit.xml opacus
105+
coverage report -i -m
106+
- name: Store test results
107+
uses: actions/upload-artifact@v2
108+
with:
109+
name: unittest-py39-nightly-reports
110+
path: unittest-py39-nightly-reports
111+
112+
prv_accountant_values:
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@v2
117+
- name: Set up Python
118+
uses: actions/setup-python@v2
119+
with:
120+
python-version: 3.9
121+
- name: Install dependencies
122+
run: |
123+
python -m pip install --upgrade pip
124+
./scripts/install_via_pip.sh
125+
- name: Run prv accountant unit tests
126+
run: |
127+
python -m unittest opacus.tests.prv_accountant
128+
129+
integrationtest_py39_torch_release_cpu:
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Checkout
133+
uses: actions/checkout@v2
134+
- name: Set up Python
135+
uses: actions/setup-python@v2
136+
with:
137+
python-version: 3.9
138+
- name: Install dependencies
139+
run: |
140+
python -m pip install --upgrade pip
141+
pip install pytest coverage coveralls
142+
./scripts/install_via_pip.sh
143+
- name: Run MNIST integration test (CPU)
144+
run: |
145+
mkdir -p runs/mnist/data
146+
mkdir -p runs/mnist/test-reports
147+
python examples/mnist.py --lr 0.25 --sigma 0.7 -c 1.5 --batch-size 64 --epochs 1 --data-root runs/mnist/data --n-runs 1 --device cpu
148+
python -c "import torch; accuracy = torch.load('run_results_mnist_0.25_0.7_1.5_64_1.pt'); exit(0) if (accuracy[0]>0.78 and accuracy[0]<0.95) else exit(1)"
149+
- name: Store test results
150+
uses: actions/upload-artifact@v2
151+
with:
152+
name: mnist-cpu-reports
153+
path: runs/mnist/test-reports
154+
155+
integrationtest_py39_torch_release_cuda:
156+
runs-on: ubuntu-latest
157+
needs: [unittest_py39_torch_release]
158+
container:
159+
image: nvidia/cuda:11.1-base-ubuntu20.04
160+
options: --gpus all
161+
env:
162+
TZ: 'UTC'
163+
steps:
164+
- name: Checkout
165+
uses: actions/checkout@v2
166+
167+
- name: Set up Python
168+
uses: actions/setup-python@v2
169+
with:
170+
python-version: 3.9
171+
172+
- name: Install dependencies
173+
run: |
174+
python -m pip install --upgrade pip
175+
pip install pytest coverage coveralls
176+
./scripts/install_via_pip.sh
177+
178+
- name: Install CUDA toolkit and cuDNN
179+
run: |
180+
apt-get update
181+
apt-get install -y --no-install-recommends \
182+
cuda-toolkit-11-1 \
183+
libcudnn8=8.1.1.33-1+cuda11.1 \
184+
libcudnn8-dev=8.1.1.33-1+cuda11.1
185+
186+
- name: Run MNIST integration test (CUDA)
187+
run: |
188+
mkdir -p runs/mnist/data
189+
mkdir -p runs/mnist/test-reports
190+
python examples/mnist.py --lr 0.25 --sigma 0.7 -c 1.5 --batch-size 64 --epochs 1 --data-root runs/mnist/data --n-runs 1 --device cuda
191+
python -c "import torch; accuracy = torch.load('run_results_mnist_0.25_0.7_1.5_64_1.pt'); exit(0) if (accuracy[0]>0.78 and accuracy[0]<0.95) else exit(1)"
192+
193+
- name: Store MNIST test results
194+
uses: actions/upload-artifact@v2
195+
with:
196+
name: mnist-gpu-reports
197+
path: runs/mnist/test-reports
198+
199+
- name: Run CIFAR10 integration test (CUDA)
200+
run: |
201+
mkdir -p runs/cifar10/data
202+
mkdir -p runs/cifar10/logs
203+
mkdir -p runs/cifar10/test-reports
204+
pip install tensorboard
205+
python examples/cifar10.py --lr 0.1 --sigma 1.5 -c 10 --batch-size 2000 --epochs 10 --data-root runs/cifar10/data --log-dir runs/cifar10/logs --device cuda
206+
python -c "import torch; model = torch.load('model_best.pth.tar'); exit(0) if (model['best_acc1']>0.4 and model['best_acc1']<0.49) else exit(1)"
207+
python examples/cifar10.py --lr 0.1 --sigma 1.5 -c 10 --batch-size 2000 --epochs 10 --data-root runs/cifar10/data --log-dir runs/cifar10/logs --device cuda --grad_sample_mode no_op
208+
python -c "import torch; model = torch.load('model_best.pth.tar'); exit(0) if (model['best_acc1']>0.4 and model['best_acc1']<0.49) else exit(1)"
209+
210+
- name: Store CIFAR10 test results
211+
uses: actions/upload-artifact@v2
212+
with:
213+
name: cifar10-gpu-reports
214+
path: runs/cifar10/test-reports
215+
216+
- name: Run IMDb integration test (CUDA)
217+
run: |
218+
mkdir -p runs/imdb/data
219+
mkdir -p runs/imdb/test-reports
220+
pip install --user datasets transformers
221+
python examples/imdb.py --lr 0.02 --sigma 1.0 -c 1.0 --batch-size 64 --max-sequence-length 256 --epochs 2 --data-root runs/imdb/data --device cuda
222+
python -c "import torch; accuracy = torch.load('run_results_imdb_classification.pt'); exit(0) if (accuracy>0.54 and accuracy<0.66) else exit(1)"
223+
224+
- name: Store IMDb test results
225+
uses: actions/upload-artifact@v2
226+
with:
227+
name: imdb-gpu-reports
228+
path: runs/imdb/test-reports
229+
230+
- name: Run charlstm integration test (CUDA)
231+
run: |
232+
mkdir -p runs/charlstm/data
233+
wget https://download.pytorch.org/tutorial/data.zip -O runs/charlstm/data/data.zip
234+
unzip runs/charlstm/data/data.zip -d runs/charlstm/data
235+
rm runs/charlstm/data/data.zip
236+
mkdir -p runs/charlstm/test-reports
237+
pip install scikit-learn
238+
python examples/char-lstm-classification.py --epochs=20 --learning-rate=2.0 --hidden-size=128 --delta=8e-5 --batch-size 400 --n-layers=1 --sigma=1.0 --max-per-sample-grad-norm=1.5 --data-root="runs/charlstm/data/data/names/" --device cuda --test-every 5
239+
python -c "import torch; accuracy = torch.load('run_results_chr_lstm_classification.pt'); exit(0) if (accuracy>0.60 and accuracy<0.80) else exit(1)"
240+
241+
- name: Store test results
242+
uses: actions/upload-artifact@v2
243+
with:
244+
name: charlstm-gpu-reports
245+
path: runs/charlstm/test-reports
246+
247+
micro_benchmarks_py39_torch_release_cuda:
248+
runs-on: ubuntu-latest
249+
needs: [integrationtest_py39_torch_release_cuda]
250+
container:
251+
image: nvidia/cuda:11.1-base-ubuntu20.04
252+
options: --gpus all
253+
env:
254+
TZ: 'UTC'
255+
steps:
256+
- name: Checkout
257+
uses: actions/checkout@v2
258+
259+
- name: Set up Python
260+
uses: actions/setup-python@v2
261+
with:
262+
python-version: 3.9
263+
264+
- name: Install dependencies
265+
run: |
266+
python -m pip install --upgrade pip
267+
pip install pytest coverage coveralls
268+
./scripts/install_via_pip.sh
269+
270+
- name: Install CUDA toolkit and cuDNN
271+
run: |
272+
apt-get update
273+
apt-get install -y --no-install-recommends \
274+
cuda-toolkit-11-1 \
275+
libcudnn8=8.1.1.33-1+cuda11.1 \
276+
libcudnn8-dev=8.1.1.33-1+cuda11.1
277+
278+
- name: Run benchmark integration tests (CUDA)
279+
run: |
280+
mkdir -p benchmarks/results/raw
281+
python benchmarks/run_benchmarks.py --batch_size 16 --layers "groupnorm instancenorm layernorm" --config_file ./benchmarks/config.json --root ./benchmarks/results/raw/ --cont
282+
IFS=$' ';layers=("groupnorm" "instancenorm" "layernorm"); rm -rf /tmp/report_layers; mkdir -p /tmp/report_layers; IFS=$'\n'; files=`( echo "${layers[*]}" ) | sed 's/.*/.\/benchmarks\/results\/raw\/&*/'`
283+
cp -v ${files[@]} /tmp/report_layers
284+
report_id=`IFS=$'-'; echo "${layers[*]}"`
285+
python benchmarks/generate_report.py --path-to-results /tmp/report_layers --save-path benchmarks/results/report-${report_id}.csv --format csv
286+
python benchmarks/generate_report.py --path-to-results /tmp/report_layers --save-path benchmarks/results/report-${report_id}.pkl --format pkl
287+
python benchmarks/check_threshold.py --report-path "./benchmarks/results/report-"$report_id".pkl" --metric runtime --threshold 3.0 --column "hooks/baseline"
288+
python benchmarks/check_threshold.py --report-path "./benchmarks/results/report-"$report_id".pkl" --metric memory --threshold 1.6 --column "hooks/baseline"
289+
290+
- name: Store artifacts
291+
uses: actions/upload-artifact@v2
292+
with:
293+
name: benchmarks-reports
294+
path: benchmarks/results/
295+
296+
unittest_multi_gpu:
297+
runs-on: ubuntu-latest
298+
container:
299+
image: nvidia/cuda:11.1-base-ubuntu20.04
300+
options: --gpus all
301+
env:
302+
TZ: 'UTC'
303+
steps:
304+
- name: Checkout
305+
uses: actions/checkout@v2
306+
307+
- name: Set up Python
308+
uses: actions/setup-python@v2
309+
with:
310+
python-version: 3.9
311+
312+
- name: Install dependencies
313+
run: |
314+
python -m pip install --upgrade pip
315+
pip install pytest coverage coveralls
316+
./scripts/install_via_pip.sh
317+
318+
- name: Run multi-GPU unit tests
319+
run: |
320+
nvidia-smi
321+
mkdir unittest-multigpu-reports
322+
coverage run -m unittest opacus.tests.multigpu_gradcheck.GradientComputationTest.test_gradient_correct
323+
coverage report -i -m
324+
325+
- name: Store test results
326+
uses: actions/upload-artifact@v2
327+
with:
328+
name: unittest-multigpu-reports
329+
path: unittest-multigpu-reports
330+
331+
finish_coveralls_parallel:
332+
runs-on: ubuntu-latest
333+
steps:
334+
- name: Checkout
335+
uses: actions/checkout@v2
336+
- name: Finish Coveralls Parallel
337+
run: |
338+
python -m pip install --upgrade pip
339+
pip install coveralls --user
340+
coveralls --finish
341+
- name: coveralls upload
342+
timeout-minutes: 5
343+
run: |
344+
python -m pip install --upgrade pip
345+
pip install coveralls --user
346+
COVERALLS_PARALLEL=true COVERALLS_FLAG_NAME="${GITHUB_JOB}" coveralls

0 commit comments

Comments
 (0)