Skip to content

Commit 0c6cd6d

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 2458f39 commit 0c6cd6d

File tree

3 files changed

+469
-0
lines changed

3 files changed

+469
-0
lines changed

Diff for: .github/workflows/ci_cpu.yml

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: CI_CPU
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 ##############
16+
lint_py39_torch_release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Set up Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: 3.9
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install flake8 black isort
29+
./scripts/install_via_pip.sh
30+
- name: Lint with flake8
31+
run: flake8 --config ./.github/workflows/flake8_config.ini
32+
- name: Lint with black
33+
run: black --check --diff --color .
34+
- name: Check import order with isort
35+
run: isort -v -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma --check-only .
36+
37+
########### UNIT TESTS ##############
38+
unittest_py38_torch_release:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v2
43+
- name: Set up Python
44+
uses: actions/setup-python@v2
45+
with:
46+
python-version: 3.8
47+
- name: Install dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install pytest coverage coveralls
51+
./scripts/install_via_pip.sh
52+
- name: Run unit tests
53+
run: |
54+
mkdir unittest-py38-release-reports
55+
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py38-release-reports/junit.xml opacus
56+
coverage report -i -m
57+
- name: Store test results
58+
uses: actions/upload-artifact@v2
59+
with:
60+
name: unittest-py38-release-reports
61+
path: unittest-py38-release-reports
62+
63+
unittest_py39_torch_release:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v2
68+
- name: Set up Python
69+
uses: actions/setup-python@v2
70+
with:
71+
python-version: 3.9
72+
- name: Install dependencies
73+
run: |
74+
python -m pip install --upgrade pip
75+
pip install pytest coverage coveralls
76+
./scripts/install_via_pip.sh
77+
- name: Run unit tests
78+
run: |
79+
mkdir unittest-py39-release-reports
80+
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py39-release-reports/junit.xml opacus
81+
coverage report -i -m
82+
- name: Store test results
83+
uses: actions/upload-artifact@v2
84+
with:
85+
name: unittest-py39-release-reports
86+
path: unittest-py39-release-reports
87+
88+
prv_accountant_values:
89+
runs-on: ubuntu-latest
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v2
93+
- name: Set up Python
94+
uses: actions/setup-python@v2
95+
with:
96+
python-version: 3.9
97+
- name: Install dependencies
98+
run: |
99+
python -m pip install --upgrade pip
100+
./scripts/install_via_pip.sh
101+
- name: Run prv accountant unit tests
102+
run: |
103+
python -m unittest opacus.tests.prv_accountant
104+
105+
########### NIGHTLY TEST ##############
106+
unittest_py39_torch_nightly:
107+
runs-on: ubuntu-latest
108+
if: ${{ github.event_name == 'schedule' }}
109+
steps:
110+
- name: Checkout
111+
uses: actions/checkout@v2
112+
- name: Set up Python
113+
uses: actions/setup-python@v2
114+
with:
115+
python-version: 3.9
116+
- name: Install dependencies
117+
run: |
118+
python -m pip install --upgrade pip
119+
pip install pytest coverage coveralls
120+
./scripts/install_via_pip.sh -n
121+
- name: Run unit tests
122+
run: |
123+
mkdir unittest-py39-nightly-reports
124+
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py39-nightly-reports/junit.xml opacus
125+
coverage report -i -m
126+
- name: Store test results
127+
uses: actions/upload-artifact@v2
128+
with:
129+
name: unittest-py39-nightly-reports
130+
path: unittest-py39-nightly-reports
131+
132+
########### INTEGRATION TEST ##############
133+
integrationtest_py39_torch_release_cpu:
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Checkout
137+
uses: actions/checkout@v2
138+
- name: Set up Python
139+
uses: actions/setup-python@v2
140+
with:
141+
python-version: 3.9
142+
- name: Install dependencies
143+
run: |
144+
python -m pip install --upgrade pip
145+
pip install pytest coverage coveralls
146+
./scripts/install_via_pip.sh
147+
- name: Run MNIST integration test (CPU)
148+
run: |
149+
mkdir -p runs/mnist/data
150+
mkdir -p runs/mnist/test-reports
151+
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
152+
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)"
153+
coverage report -i -m
154+
- name: Store test results
155+
uses: actions/upload-artifact@v2
156+
with:
157+
name: mnist-cpu-reports
158+
path: runs/mnist/test-reports
159+
160+
######## FINISH COVERALLS ##########
161+
finish_coveralls_parallel:
162+
runs-on: ubuntu-latest
163+
steps:
164+
- name: Checkout
165+
uses: actions/checkout@v2
166+
- name: Finish Coveralls Parallel
167+
run: |
168+
python -m pip install --upgrade pip
169+
pip install coveralls --user
170+
coveralls --finish
171+
- name: coveralls upload
172+
timeout-minutes: 5
173+
run: |
174+
python -m pip install --upgrade pip
175+
pip install coveralls --user
176+
COVERALLS_PARALLEL=true COVERALLS_FLAG_NAME="${GITHUB_JOB}" coveralls

Diff for: .github/workflows/ci_gpu.yml

+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: CI_GPU
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
unittest_multi_gpu:
12+
runs-on: linux.4xlarge.nvidia.gpu
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: 3.9
21+
22+
- name: Install dependencies
23+
run: |
24+
./scripts/install_via_pip.sh -c
25+
26+
- name: Run multi-GPU unit tests
27+
run: |
28+
nvidia-smi
29+
nvcc --version
30+
python -m unittest opacus.tests.multigpu_gradcheck.GradientComputationTest.test_gradient_correct
31+
32+
33+
integrationtest_py39_torch_release_cuda:
34+
runs-on: ubuntu-latest
35+
needs: [unittest_py39_torch_release]
36+
container:
37+
# https://hub.docker.com/r/nvidia/cuda
38+
image: nvidia/cuda:12.3.1-base-ubuntu22.04
39+
options: --gpus all
40+
env:
41+
TZ: 'UTC'
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v2
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v2
48+
with:
49+
python-version: 3.9
50+
51+
- name: Install dependencies
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install pytest coverage coveralls
55+
./scripts/install_via_pip.sh -c
56+
57+
- name: Install CUDA toolkit and cuDNN
58+
run: |
59+
apt-get update
60+
apt-get install -y --no-install-recommends \
61+
cuda-toolkit-11-1 \
62+
libcudnn8=8.1.1.33-1+cuda11.1 \
63+
libcudnn8-dev=8.1.1.33-1+cuda11.1
64+
65+
- name: Run MNIST integration test (CUDA)
66+
run: |
67+
mkdir -p runs/mnist/data
68+
mkdir -p runs/mnist/test-reports
69+
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
70+
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)"
71+
72+
- name: Store MNIST test results
73+
uses: actions/upload-artifact@v2
74+
with:
75+
name: mnist-gpu-reports
76+
path: runs/mnist/test-reports
77+
78+
- name: Run CIFAR10 integration test (CUDA)
79+
run: |
80+
mkdir -p runs/cifar10/data
81+
mkdir -p runs/cifar10/logs
82+
mkdir -p runs/cifar10/test-reports
83+
pip install tensorboard
84+
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
85+
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)"
86+
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
87+
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)"
88+
89+
- name: Store CIFAR10 test results
90+
uses: actions/upload-artifact@v2
91+
with:
92+
name: cifar10-gpu-reports
93+
path: runs/cifar10/test-reports
94+
95+
- name: Run IMDb integration test (CUDA)
96+
run: |
97+
mkdir -p runs/imdb/data
98+
mkdir -p runs/imdb/test-reports
99+
pip install --user datasets transformers
100+
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
101+
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)"
102+
103+
- name: Store IMDb test results
104+
uses: actions/upload-artifact@v2
105+
with:
106+
name: imdb-gpu-reports
107+
path: runs/imdb/test-reports
108+
109+
- name: Run charlstm integration test (CUDA)
110+
run: |
111+
mkdir -p runs/charlstm/data
112+
wget https://download.pytorch.org/tutorial/data.zip -O runs/charlstm/data/data.zip
113+
unzip runs/charlstm/data/data.zip -d runs/charlstm/data
114+
rm runs/charlstm/data/data.zip
115+
mkdir -p runs/charlstm/test-reports
116+
pip install scikit-learn
117+
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
118+
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)"
119+
120+
- name: Store test results
121+
uses: actions/upload-artifact@v2
122+
with:
123+
name: charlstm-gpu-reports
124+
path: runs/charlstm/test-reports
125+
126+
micro_benchmarks_py39_torch_release_cuda:
127+
runs-on: ubuntu-latest
128+
needs: [integrationtest_py39_torch_release_cuda]
129+
container:
130+
# https://hub.docker.com/r/nvidia/cuda
131+
image: nvidia/cuda:12.3.1-base-ubuntu22.04
132+
options: --gpus all
133+
env:
134+
TZ: 'UTC'
135+
steps:
136+
- name: Checkout
137+
uses: actions/checkout@v2
138+
139+
- name: Set up Python
140+
uses: actions/setup-python@v2
141+
with:
142+
python-version: 3.9
143+
144+
- name: Install dependencies
145+
run: |
146+
python -m pip install --upgrade pip
147+
pip install pytest coverage coveralls
148+
./scripts/install_via_pip.sh
149+
150+
- name: Install CUDA toolkit and cuDNN
151+
run: |
152+
apt-get update
153+
apt-get install -y --no-install-recommends \
154+
cuda-toolkit-11-1 \
155+
libcudnn8=8.1.1.33-1+cuda11.1 \
156+
libcudnn8-dev=8.1.1.33-1+cuda11.1
157+
158+
- name: Run benchmark integration tests (CUDA)
159+
run: |
160+
mkdir -p benchmarks/results/raw
161+
python benchmarks/run_benchmarks.py --batch_size 16 --layers "groupnorm instancenorm layernorm" --config_file ./benchmarks/config.json --root ./benchmarks/results/raw/ --cont
162+
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\/&*/'`
163+
cp -v ${files[@]} /tmp/report_layers
164+
report_id=`IFS=$'-'; echo "${layers[*]}"`
165+
python benchmarks/generate_report.py --path-to-results /tmp/report_layers --save-path benchmarks/results/report-${report_id}.csv --format csv
166+
python benchmarks/generate_report.py --path-to-results /tmp/report_layers --save-path benchmarks/results/report-${report_id}.pkl --format pkl
167+
python benchmarks/check_threshold.py --report-path "./benchmarks/results/report-"$report_id".pkl" --metric runtime --threshold 3.0 --column "hooks/baseline"
168+
python benchmarks/check_threshold.py --report-path "./benchmarks/results/report-"$report_id".pkl" --metric memory --threshold 1.6 --column "hooks/baseline"
169+
170+
- name: Store artifacts
171+
uses: actions/upload-artifact@v2
172+
with:
173+
name: benchmarks-reports
174+
path: benchmarks/results/

0 commit comments

Comments
 (0)