-
Notifications
You must be signed in to change notification settings - Fork 262
/
config.yml
612 lines (482 loc) · 19.8 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
# Adopted from
# https://github.com/facebookresearch/detectron2/blob/main/.circleci/config.yml
#
# Pro tip: download circle ci cli to validate the config locally during development.
#
# To reset/clean the cache update the CACHE_VERSION variable in project settings
# in the fairscale project in CircleCI's web UI. The CACHE_VERSION follows the convention
# v$(FAIRSCALE_VERSION)-${CACHE_NUMBER}. E.g. v0.4.2-1. CACHE_NUMBER must start
# at 1 and increase in whole numbers. When changing the CACHE_VERSION manually
# always set the FAIRSCALE_VERSION value to the fairscale version being tested.
# To reset the cache when not updating the fairscale version, only update the
# CACHE_NUMBER value.
version: 2.1
orbs:
codecov: codecov/codecov@1.0.2
# -------------------------------------------------------------------------------------
# Environments to run the jobs in
# -------------------------------------------------------------------------------------
cpu_py38: &cpu_py38
docker:
- image: circleci/python:3.8
resource_class: large
cpu_py39: &cpu_py39
docker:
- image: circleci/python:3.9
resource_class: large
cpu_py310: &cpu_py310
docker:
- image: circleci/python:3.10
resource_class: large
# Here is the list of GPU images:
# https://circleci.com/docs/2.0/configuration-reference/#available-linux-gpu-images
# We need to use multiple gpus for several jobs. The resource_class
# values are available here T101565170
# gpu.nvidia.small.multi = 2 gpus with 16 GB ram each
# gpu.nvidia.medium.multi = 4 gpus with 16 GB ram each
gpu_cu_11_2_small_multi: &gpu_cu_11_2_small_multi
environment:
CUDA_VERSION: "11.2"
CUDA_HOME: /usr/local/cuda-11.2
machine:
image: ubuntu-2004-cuda-11.2:202103-01
resource_class: gpu.nvidia.small.multi
gpu_cu_11_2_medium_multi: &gpu_cu_11_2_medium_multi
environment:
CUDA_VERSION: "11.2"
CUDA_HOME: /usr/local/cuda-11.2
machine:
image: ubuntu-2004-cuda-11.2:202103-01
resource_class: gpu.nvidia.medium.multi
# -------------------------------------------------------------------------------------
# Re-usable commands
# -------------------------------------------------------------------------------------
setup_venv: &setup_venv
- run:
name: Setup Virtual Env
working_directory: ~/
# use bash -x for debug early commands executed in .bashrc.
shell: /bin/bash
command: |
set -e
set -o pipefail
python -m venv ~/venv
echo ". ~/venv/bin/activate" >> $BASH_ENV
. ~/venv/bin/activate
python --version
which python
which pip
pip install --upgrade pip
# most recent LTS version
install_dep_pytorch_lts: &install_dep_pytorch_lts
- run:
name: Install Dependencies with torch 1.8.2 (LTS)
command: |
# check if we have restored venv cache (/home/circleci/venv) correctly, if so, just skip
if [ -f /home/circleci/venv/check_version.py ]; then python /home/circleci/venv/check_version.py torch eq 1.8 && exit 0; fi
# start installing
pip install --progress-bar off torch==1.8.2+cu111 torchvision==0.9.2+cu111 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu111
pip install --progress-bar off -r requirements-dev.txt
pip install --progress-bar off -r requirements-benchmarks.txt
python -c 'import torch; print("Torch version:", torch.__version__)'
python -c 'import torch; assert torch.__version__.split(".")[:2] == ["1", "8"], f"wrong torch version {torch.__version__}"'
python -m torch.utils.collect_env
wget -O /home/circleci/venv/check_version.py https://raw.githubusercontent.com/min-xu-ai/check_verion/main/check_version.py
# most recent stable version
install_dep_pytorch_stable: &install_dep_pytorch_stable
- run:
name: Install Dependencies with torch 1.13.0
command: |
# check if we have restored venv cache (/home/circleci/venv) correctly, if so, just skip
if [ -f /home/circleci/venv/check_version.py ]; then python /home/circleci/venv/check_version.py torch eq 1.13 && exit 0; fi
# start installing
pip install --progress-bar off torch==1.13.0 torchvision==0.14.0 --extra-index-url https://download.pytorch.org/whl/cu113
pip install --progress-bar off -r requirements-dev.txt
pip install --progress-bar off -r requirements-benchmarks.txt
python -c 'import torch; print("Torch version:", torch.__version__)'
python -c 'import torch; assert torch.__version__.split(".")[:2] == ["1", "13"], f"wrong torch version {torch.__version__}"'
python -m torch.utils.collect_env
wget -O /home/circleci/venv/check_version.py https://raw.githubusercontent.com/min-xu-ai/check_verion/main/check_version.py
install_dep_pytorch_nightly: &install_dep_pytorch_nightly
- run:
name: Install Dependencies with a torch nightly preview build
command: |
# check if we have restored venv cache (/home/circleci/venv) correctly, if so, just skip
if [ -f /home/circleci/venv/check_version.py ]; then python /home/circleci/venv/check_version.py torch eq 1.14 && exit 0; fi
# start installing
pip install --pre torch==1.14.0.dev20221121+cu117 torchvision==0.15.0.dev20221121+cu117 --extra-index-url https://download.pytorch.org/whl/nightly/cu117
pip install --progress-bar off -r requirements-dev.txt
pip install --progress-bar off -r requirements-benchmarks.txt
python -c 'import torch; print("Torch version:", torch.__version__)'
python -c 'import torch; assert torch.__version__.split(".")[:2] == ["1", "14"], f"wrong torch version {torch.__version__}"'
python -m torch.utils.collect_env
wget -O /home/circleci/venv/check_version.py https://raw.githubusercontent.com/min-xu-ai/check_verion/main/check_version.py
install_repo: &install_repo
- run:
name: Install Repository
command: |
pip install .
# Test import.
python -c 'import sys; sys.path = sys.path[1:]; import fairscale'
check_test_list: &check_test_list
- run:
name: Verify that unit test list files are correct
command: |
bash ./tests/ci_test_list_check.sh
upload_coverage: &upload_coverage
- codecov/upload:
file: 'coverage.xml'
token: $CODECOV_TOKEN
run_offload_benchmark: &run_offload_benchmark
- run:
name: Run Offload Benchmark
command: |
PYTHONPATH=. python benchmarks/experimental/offload.py --checkpoint_activation
run_fsdp_benchmark: &run_fsdp_benchmark
- run:
name: Run FSDP Benchmark
command: |
PYTHONPATH=. python benchmarks/fsdp.py --use_synthetic_data
run_pipe_benchmark: &run_pipe_benchmark
- run:
name: Run Pipe Benchmark
command: |
PYTHONPATH=. python benchmarks/pipe.py
run_oss_benchmark: &run_oss_benchmark
- run:
name: Run OSS Benchmark
command: |
PYTHONPATH=. python benchmarks/oss.py --world_size 4 --epochs 2
PYTHONPATH=. python benchmarks/oss.py --check_regression --world_size 4 --optim_type oss_sharded_ddp --epochs 12
run_oss_gloo: &run_oss_gloo
- run:
name: Run OSS with Gloo
command: |
PYTHONPATH=. python benchmarks/oss.py --gloo --optim_type oss_ddp --epochs 2
PYTHONPATH=. python benchmarks/oss.py --gloo --optim_type oss_sharded_ddp --epochs 2
run_oss_amp: &run_oss_amp
- run:
name: Run OSS with Torch AMP
command: |
PYTHONPATH=. python benchmarks/oss.py --amp --epochs 3 --optim_type oss_sharded_ddp
run_oss_for_each: &run_oss_for_each
- run:
name: Run OSS with Torch AMP and ForEach optmizer
command: |
PYTHONPATH=. python benchmarks/oss.py --amp --epochs 3 --optim_type oss_sharded_ddp --multi_tensor_optim
run_doc_build: &run_doc_build
- run:
name: Testing doc build
command: |
cd docs
pip install --progress-bar off -r requirements.txt
make help
make singlehtml | tee make.out
! tail make.out | grep -q warning
# This is an alias to run all unit tests possible on a platform.
run_unittests: &run_unittests
- run:
name: Run all unit tests.
# We run all and not stopping on failure on CPU since docker time is cheaper.
command: |
ulimit -n 10000
pytest --junitxml=test-results/junit.xml --verbose --timeout 60 --cov-report=xml --cov=./
commands:
# This is a command (like a function) that run tests from a given test_list_file.
# If test_list_file is not given, this results in an error.
run_unittests_from_list:
parameters:
test_list_file:
type: string
default: "/dev/non_exist" # Default to error out
steps:
- run:
name: Run Unit Tests
command: |
ulimit -n 10000
if [ ! -f <<parameters.test_list_file>> ]; then exit 1; fi
pytest --junitxml=test-results/junit.xml --verbose --timeout 70 --cov-report=xml --cov=./ `cat <<parameters.test_list_file>>`
setup_pyenv:
parameters:
version:
type: string
steps:
# Cache the pyenv download directory to avoid re-downloading over and over.
- restore_cache:
keys:
- cache-key-pyenv-3-9-7-v1
- run:
name: Setup pyenv
# We used to use the following commands to update pyenv.
# git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update
# pyenv update
# However, it is not deterministic since pyenv is being updated.
# It is now fixed to a version. (v2.3.0 is broken since it cause bash to fail when it try to do "eval $(pyenv init -)")
#
# We use "-sf" to skip already installed version after cache restoring the pyenv dir. This should avoid redoing
# downloading and installing. The key name has a "v1" in the end so that we can debug and try different cache objects
# while doing development.
command: |
cd /opt/circleci/.pyenv/
git remote update
git checkout v2.2.0
pyenv install -sf <<parameters.version>>
pyenv global <<parameters.version>>
- save_cache:
paths:
- /opt/circleci/.pyenv
key: cache-key-pyenv-3-9-7-v1
# -------------------------------------------------------------------------------------
# Jobs to run
# -------------------------------------------------------------------------------------
jobs:
cpu_tests_py38:
<<: *cpu_py38
working_directory: ~/fairscale
steps:
- checkout
- <<: *check_test_list
- <<: *setup_venv
# Do this first to test repo dependencies. Basic import should work after this
# installation. See issue #1042 for an example.
- <<: *install_repo
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-cpu-py38-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_dep_pytorch_stable
- save_cache:
paths:
- ~/venv
key: cache-key-cpu-py38-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *run_unittests
- <<: *run_doc_build
- store_test_results:
path: test-results
cpu_tests_py39:
<<: *cpu_py39
working_directory: ~/fairscale
steps:
- checkout
- <<: *check_test_list
- <<: *setup_venv
# Do this first to test repo dependencies. Basic import should work after this
# installation. See issue #1042 for an example.
- <<: *install_repo
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-cpu-py39-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_dep_pytorch_stable
- save_cache:
paths:
- ~/venv
key: cache-key-cpu-py39-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *run_unittests
- <<: *run_doc_build
- store_test_results:
path: test-results
cpu_tests_py310:
<<: *cpu_py310
working_directory: ~/fairscale
steps:
- checkout
- <<: *check_test_list
- <<: *setup_venv
# Do this first to test repo dependencies. Basic import should work after this
# installation. See issue #1042 for an example.
- <<: *install_repo
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-cpu-py310-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_dep_pytorch_stable
- save_cache:
paths:
- ~/venv
key: cache-key-cpu-py310-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *run_unittests
- <<: *run_doc_build
- store_test_results:
path: test-results
gpu_tests_lts:
parameters:
test_list_file:
type: string
default: "/dev/non_exist"
<<: *gpu_cu_11_2_small_multi
working_directory: ~/fairscale
steps:
- checkout
- run: nvidia-smi
# Run this to make sure we use python3 from the system.
- setup_pyenv:
version: 3.9.7
- <<: *setup_venv
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-py-3-9-7-gpu-torch-1-8-2-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_dep_pytorch_lts
- save_cache:
paths:
- ~/venv
key: cache-key-py-3-9-7-gpu-torch-1-8-2-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_repo
- run_unittests_from_list:
test_list_file: <<parameters.test_list_file>>
- store_test_results:
path: test-results
# Disabled codecov since https://codecov.io/bash seems to be down.
#- <<: *upload_coverage
gpu_tests_stable:
parameters:
test_list_file:
type: string
default: "/dev/non_exist"
<<: *gpu_cu_11_2_small_multi
working_directory: ~/fairscale
steps:
- checkout
- run: nvidia-smi
# Run this to make sure we use python3 from the system.
- setup_pyenv:
version: 3.9.7
- <<: *setup_venv
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-py-3-9-7-gpu-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_dep_pytorch_stable
- save_cache:
paths:
- ~/venv
key: cache-key-py-3-9-7-gpu-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_repo
- run_unittests_from_list:
test_list_file: <<parameters.test_list_file>>
- store_test_results:
path: test-results
gpu_tests_pytorch_nightly:
parameters:
test_list_file:
type: string
default: "/dev/non_exist"
<<: *gpu_cu_11_2_medium_multi
working_directory: ~/fairscale
steps:
- checkout
- run: nvidia-smi
# Run this to make sure we use python3 from the system.
- setup_pyenv:
version: 3.9.7
- <<: *setup_venv
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-py-3-9-7-gpu-torch-1-12-0424-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_dep_pytorch_nightly
- save_cache:
paths:
- ~/venv
key: cache-key-py-3-9-7-gpu-torch-1-12-0424-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_repo
- run_unittests_from_list:
test_list_file: <<parameters.test_list_file>>
- store_test_results:
path: test-results
benchmarks_1:
<<: *gpu_cu_11_2_small_multi
working_directory: ~/fairscale
steps:
- checkout
- run: nvidia-smi
- setup_pyenv:
version: 3.9.7
- <<: *setup_venv
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-py-3-9-7-benchmarks-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
# Cache the MNIST directory that contains benchmark data
- restore_cache:
keys:
- cache-key-benchmark-MNIST-{{.Environment.CACHE_VERSION}}-{{checksum "benchmarks/datasets/mnist.py"}}
- <<: *install_dep_pytorch_stable
- save_cache:
paths:
- ~/venv
key: cache-key-py-3-9-7-benchmarks-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *install_repo
- <<: *run_pipe_benchmark
- <<: *run_offload_benchmark
- <<: *run_oss_amp
- <<: *run_oss_for_each
- <<: *run_oss_gloo
- <<: *run_fsdp_benchmark
- save_cache:
paths:
- /tmp/MNIST
key: cache-key-benchmark-MNIST-{{.Environment.CACHE_VERSION}}-{{checksum "benchmarks/datasets/mnist.py"}}
benchmarks_2:
<<: *gpu_cu_11_2_medium_multi
working_directory: ~/fairscale
steps:
- checkout
- run: nvidia-smi
- setup_pyenv:
version: 3.9.7
- <<: *setup_venv
# Do this first to test an issue like #1042. We keep benchmark_1 doing it
# after requirements-dev.txt, but change benchmark_2 to do this earlier to
# ensure both cases are tested.
- <<: *install_repo
# Cache the venv directory that contains dependencies
- restore_cache:
keys:
- cache-key-py-3-9-7-benchmarks-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
# Cache the MNIST directory that contains benchmark data
- restore_cache:
keys:
- cache-key-benchmark-MNIST-{{.Environment.CACHE_VERSION}}-{{checksum "benchmarks/datasets/mnist.py"}}
- <<: *install_dep_pytorch_stable
- save_cache:
paths:
- ~/venv
key: cache-key-py-3-9-7-benchmarks-torch-1-11-0-{{.Environment.CACHE_VERSION}}-{{checksum "setup.py"}}-{{checksum "requirements-dev.txt"}}
- <<: *run_oss_benchmark
- save_cache:
paths:
- /tmp/MNIST
key: cache-key-benchmark-MNIST-{{.Environment.CACHE_VERSION}}-{{checksum "benchmarks/datasets/mnist.py"}}
workflows:
version: 2
build:
jobs:
- cpu_tests_py38
- cpu_tests_py39
- cpu_tests_py310
- gpu_tests_lts:
test_list_file: tests/ci_test_list_1.txt
- gpu_tests_stable:
test_list_file: tests/ci_test_list_1.txt
- gpu_tests_pytorch_nightly:
test_list_file: tests/ci_test_list_1.txt
- gpu_tests_lts:
test_list_file: tests/ci_test_list_2.txt
- gpu_tests_stable:
test_list_file: tests/ci_test_list_2.txt
- gpu_tests_pytorch_nightly:
test_list_file: tests/ci_test_list_2.txt
- gpu_tests_lts:
test_list_file: tests/ci_test_list_3.txt
- gpu_tests_stable:
test_list_file: tests/ci_test_list_3.txt
- gpu_tests_pytorch_nightly:
test_list_file: tests/ci_test_list_3.txt
- benchmarks_1
- benchmarks_2