Skip to content

Commit c94e74a

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 c94e74a

File tree

2 files changed

+464
-0
lines changed

2 files changed

+464
-0
lines changed

.github/workflows/ci.yml

+345
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
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+
coverage run 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+
coverage report -i -m
150+
- name: Store test results
151+
uses: actions/upload-artifact@v2
152+
with:
153+
name: mnist-cpu-reports
154+
path: runs/mnist/test-reports
155+
156+
integrationtest_py39_torch_release_cuda:
157+
runs-on: ubuntu-latest
158+
needs: [unittest_py39_torch_release]
159+
container:
160+
# https://hub.docker.com/r/nvidia/cuda
161+
image: nvidia/cuda:12.3.1-base-ubuntu22.04
162+
options: --gpus all
163+
env:
164+
TZ: 'UTC'
165+
steps:
166+
- name: Checkout
167+
uses: actions/checkout@v2
168+
169+
- name: Set up Python
170+
uses: actions/setup-python@v2
171+
with:
172+
python-version: 3.9
173+
174+
- name: Install dependencies
175+
run: |
176+
python -m pip install --upgrade pip
177+
pip install pytest coverage coveralls
178+
./scripts/install_via_pip.sh -c
179+
180+
- name: Install CUDA toolkit and cuDNN
181+
run: |
182+
apt-get update
183+
apt-get install -y --no-install-recommends \
184+
cuda-toolkit-11-1 \
185+
libcudnn8=8.1.1.33-1+cuda11.1 \
186+
libcudnn8-dev=8.1.1.33-1+cuda11.1
187+
188+
- name: Run MNIST integration test (CUDA)
189+
run: |
190+
mkdir -p runs/mnist/data
191+
mkdir -p runs/mnist/test-reports
192+
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
193+
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)"
194+
195+
- name: Store MNIST test results
196+
uses: actions/upload-artifact@v2
197+
with:
198+
name: mnist-gpu-reports
199+
path: runs/mnist/test-reports
200+
201+
- name: Run CIFAR10 integration test (CUDA)
202+
run: |
203+
mkdir -p runs/cifar10/data
204+
mkdir -p runs/cifar10/logs
205+
mkdir -p runs/cifar10/test-reports
206+
pip install tensorboard
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
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+
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
210+
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)"
211+
212+
- name: Store CIFAR10 test results
213+
uses: actions/upload-artifact@v2
214+
with:
215+
name: cifar10-gpu-reports
216+
path: runs/cifar10/test-reports
217+
218+
- name: Run IMDb integration test (CUDA)
219+
run: |
220+
mkdir -p runs/imdb/data
221+
mkdir -p runs/imdb/test-reports
222+
pip install --user datasets transformers
223+
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
224+
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)"
225+
226+
- name: Store IMDb test results
227+
uses: actions/upload-artifact@v2
228+
with:
229+
name: imdb-gpu-reports
230+
path: runs/imdb/test-reports
231+
232+
- name: Run charlstm integration test (CUDA)
233+
run: |
234+
mkdir -p runs/charlstm/data
235+
wget https://download.pytorch.org/tutorial/data.zip -O runs/charlstm/data/data.zip
236+
unzip runs/charlstm/data/data.zip -d runs/charlstm/data
237+
rm runs/charlstm/data/data.zip
238+
mkdir -p runs/charlstm/test-reports
239+
pip install scikit-learn
240+
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
241+
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)"
242+
243+
- name: Store test results
244+
uses: actions/upload-artifact@v2
245+
with:
246+
name: charlstm-gpu-reports
247+
path: runs/charlstm/test-reports
248+
249+
micro_benchmarks_py39_torch_release_cuda:
250+
runs-on: ubuntu-latest
251+
needs: [integrationtest_py39_torch_release_cuda]
252+
container:
253+
# https://hub.docker.com/r/nvidia/cuda
254+
image: nvidia/cuda:12.3.1-base-ubuntu22.04
255+
options: --gpus all
256+
env:
257+
TZ: 'UTC'
258+
steps:
259+
- name: Checkout
260+
uses: actions/checkout@v2
261+
262+
- name: Set up Python
263+
uses: actions/setup-python@v2
264+
with:
265+
python-version: 3.9
266+
267+
- name: Install dependencies
268+
run: |
269+
python -m pip install --upgrade pip
270+
pip install pytest coverage coveralls
271+
./scripts/install_via_pip.sh
272+
273+
- name: Install CUDA toolkit and cuDNN
274+
run: |
275+
apt-get update
276+
apt-get install -y --no-install-recommends \
277+
cuda-toolkit-11-1 \
278+
libcudnn8=8.1.1.33-1+cuda11.1 \
279+
libcudnn8-dev=8.1.1.33-1+cuda11.1
280+
281+
- name: Run benchmark integration tests (CUDA)
282+
run: |
283+
mkdir -p benchmarks/results/raw
284+
python benchmarks/run_benchmarks.py --batch_size 16 --layers "groupnorm instancenorm layernorm" --config_file ./benchmarks/config.json --root ./benchmarks/results/raw/ --cont
285+
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\/&*/'`
286+
cp -v ${files[@]} /tmp/report_layers
287+
report_id=`IFS=$'-'; echo "${layers[*]}"`
288+
python benchmarks/generate_report.py --path-to-results /tmp/report_layers --save-path benchmarks/results/report-${report_id}.csv --format csv
289+
python benchmarks/generate_report.py --path-to-results /tmp/report_layers --save-path benchmarks/results/report-${report_id}.pkl --format pkl
290+
python benchmarks/check_threshold.py --report-path "./benchmarks/results/report-"$report_id".pkl" --metric runtime --threshold 3.0 --column "hooks/baseline"
291+
python benchmarks/check_threshold.py --report-path "./benchmarks/results/report-"$report_id".pkl" --metric memory --threshold 1.6 --column "hooks/baseline"
292+
293+
- name: Store artifacts
294+
uses: actions/upload-artifact@v2
295+
with:
296+
name: benchmarks-reports
297+
path: benchmarks/results/
298+
299+
unittest_multi_gpu:
300+
runs-on: linux.4xlarge.nvidia.gpu
301+
steps:
302+
- name: Checkout
303+
uses: actions/checkout@v2
304+
305+
- name: Set up Python
306+
uses: actions/setup-python@v2
307+
with:
308+
python-version: 3.x
309+
310+
- name: Install dependencies
311+
run: |
312+
python -m pip install --upgrade pip
313+
pip install pytest coverage coveralls
314+
./scripts/install_via_pip.sh -c
315+
316+
- name: Run multi-GPU unit tests
317+
run: |
318+
nvidia-smi
319+
nvcc --version | grep "cuda_"
320+
mkdir unittest-multigpu-reports
321+
coverage run -m unittest opacus.tests.multigpu_gradcheck.GradientComputationTest.test_gradient_correct
322+
coverage report -i -m
323+
324+
- name: Store test results
325+
uses: actions/upload-artifact@v2
326+
with:
327+
name: unittest-multigpu-reports
328+
path: unittest-multigpu-reports
329+
330+
finish_coveralls_parallel:
331+
runs-on: ubuntu-latest
332+
steps:
333+
- name: Checkout
334+
uses: actions/checkout@v2
335+
- name: Finish Coveralls Parallel
336+
run: |
337+
python -m pip install --upgrade pip
338+
pip install coveralls --user
339+
coveralls --finish
340+
- name: coveralls upload
341+
timeout-minutes: 5
342+
run: |
343+
python -m pip install --upgrade pip
344+
pip install coveralls --user
345+
COVERALLS_PARALLEL=true COVERALLS_FLAG_NAME="${GITHUB_JOB}" coveralls

0 commit comments

Comments
 (0)