Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
55657dc
synced gpus
stas00 Mar 16, 2021
05bddda
fix
stas00 Mar 16, 2021
a5adf30
fix
stas00 Mar 16, 2021
a241298
Merge remote-tracking branch 'origin/master' into ds-zero-3
stas00 Mar 16, 2021
08e43f2
need to use t5-small for quality tests
stas00 Mar 16, 2021
2cd947b
notes
stas00 Mar 17, 2021
a374e57
Merge remote-tracking branch 'origin/master' into ds-zero-3
stas00 Mar 17, 2021
d48ad17
complete merge
stas00 Mar 17, 2021
ad7605d
fix a disappearing std stream problem
stas00 Mar 18, 2021
a7fafbb
start zero3 tests
stas00 Mar 18, 2021
b725c96
Merge remote-tracking branch 'origin/master' into ds-zero-3
stas00 Mar 18, 2021
f936858
wip
stas00 Mar 19, 2021
0a5d872
tune params
stas00 Mar 19, 2021
80fbbe7
sorting out the pre-trained model loading
stas00 Mar 23, 2021
538a402
reworking generate loop wip
stas00 Mar 23, 2021
a3ce950
wip
stas00 Mar 30, 2021
050abd6
Merge remote-tracking branch 'origin/master' into ds-zero-3
stas00 Mar 30, 2021
0f58b8d
style
stas00 Mar 30, 2021
d2f1f70
fix tests
stas00 Mar 30, 2021
d585c8c
split the tests
stas00 Mar 30, 2021
399b981
refactor tests
stas00 Mar 30, 2021
dfe28b3
wip
stas00 Mar 30, 2021
2c3564e
parameterized
stas00 Mar 30, 2021
46e2368
fix
stas00 Mar 30, 2021
8f26f9a
workout the resume from non-ds checkpoint pass + test
stas00 Mar 31, 2021
47e3556
cleanup
stas00 Mar 31, 2021
1cfec3c
remove no longer needed code
stas00 Mar 31, 2021
1cde0d8
Merge remote-tracking branch 'origin/master' into ds-zero-3
stas00 Mar 31, 2021
17e0464
split getter/setter functions
stas00 Mar 31, 2021
ea44db6
complete the docs
stas00 Apr 1, 2021
aa63fc2
suggestions
stas00 Apr 1, 2021
1399f59
gpus and their compute capabilities link
stas00 Apr 1, 2021
cb0de9d
Apply suggestions from code review
stas00 Apr 1, 2021
f34a62b
style
stas00 Apr 2, 2021
376fe60
Merge branch 'ds-zero-3' of github.com:stas00/transformers into ds-ze…
stas00 Apr 2, 2021
0799eac
remove invalid paramgd
stas00 Apr 5, 2021
e365dfe
automatically configure zero3 params that rely on hidden size
stas00 Apr 6, 2021
b3137ae
make _get_resized_embeddings zero3-aware
stas00 Apr 6, 2021
1708a82
add test exercising resize_token_embeddings()
stas00 Apr 6, 2021
6ee8744
add docstring
stas00 Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion docs/source/main_classes/trainer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ which ZeRO stages you want to enable and how to configure them.
}
}

Notes:
Performance tuning:

- enabling ``cpu_offload`` should reduce GPU RAM usage (it requires ``"stage": 2``)
- ``"overlap_comm": true`` trades off increased GPU RAM usage to lower all-reduce latency. ``overlap_comm`` uses 4.5x
Expand All @@ -752,6 +752,31 @@ This section has to be configured exclusively via DeepSpeed configuration - the
no equivalent command line arguments.


ZeRO-3
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Performance tuning:
- ``stage3_max_live_parameters``: ``1e9``
- ``stage3_max_reuse_distance``: ``1e9``
- ``stage3_prefetch_bucket_size``: ``0.9 * hidden_size*hidden_size``
- ``stage3_param_persitance_threshold``: ``10*hidden_size``
- ``reduce_bucket_size``: ``hidden_size*hidden_size``
- ``sub_group_size`` ~``1e15``

If hitting OOM reduce ``stage3_max_live_parameters`` and ``stage3_max_reuse_distance``. They should have minimal impact on perf unless you are doing activation checkpointing. ``1e9`` would consume ~2GB.
The memory is shared by ``stage3_max_live_parameters`` and ``stage3_max_reuse_distance``, so its not additive, its just 2GB total.

``stage3_max_live_parameters`` is the upper limit on how many full parameters you want to keep on the GPU at any given time. ``reuse_distance`` is a metric we are using to figure out when will a parameter be used again in the future, and we use the ``stage3_max_reuse_distance`` to decide whether to throw away the parameter or to keep it. If a parameter is going to be used again in near future (less than ``stage3_max_reuse_distance``) then we keep it to reduce communication overhead. This is super helpful when you have activation check-pointing enabled, where we do a forward recompute and backward passes a a single layer granularity and want to keep the parameter in the forward recompute till the backward


If you set ``reduce_bucket_size``, ``stage3_prefetch_bucket_size`` and ``stage3_param_persitance_threshold``: as recommended above, they will already be fairly small so you wont have to tune those much.

Other:

``allgather_partitions``, ``allgather_bucket_size`` and ``reduce_scatter`` are not used in ZeRO-3.


Optimizer and Scheduler
=======================================================================================================================
Expand Down
5 changes: 5 additions & 0 deletions examples/seq2seq/run_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,4 +592,9 @@ def _mp_fn(index):


if __name__ == "__main__":

import faulthandler, signal

#faulthandler.dump_traceback_later(20, repeat=True)

main()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 32,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},
Expand All @@ -19,6 +19,8 @@
"cpu_offload": true
},

"zero_allow_untested_optimizer": true,

"optimizer": {
"type": "AdamW",
"params": {
Expand Down
48 changes: 48 additions & 0 deletions examples/tests/deepspeed/ds_config_zero3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"fp16": {
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},

"zero_optimization": {
"stage": 3,
"cpu_offload": true,
"cpu_offload_params": true,
"cpu_offload_use_pin_memory" : true,
"overlap_comm": true,
"contiguous_gradients": true,
"stage3_max_live_parameters": 1e9,
"stage3_max_reuse_distance": 1e8,
"stage3_prefetch_bucket_size": 2e5,
"stage3_param_persitance_threshold": 1e5,
"reduce_bucket_size": 3e6,
"prefetch_bucket_size": 3e6,
"sub_group_size": 1e6
},

"optimizer": {
"type": "AdamW",
"params": {
"lr": 3e-5,
"betas": [0.8, 0.999],
"eps": 1e-8,
"weight_decay": 3e-7
}
},

"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": 3e-5,
"warmup_num_steps": 500
}
},

"steps_per_print": 2000,
"wall_clock_breakdown": false
}
Loading