-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Enhancement] Support deepspeed with flexible runner #1673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c357701
[Feature] Support deepspeed with flexible runner
fanqiNO1 7b7cb46
[Fix] Reformat with yapf
fanqiNO1 871b656
[Refacor] Rename configs
fanqiNO1 046c0ec
[Fix] Reformat with yapf
fanqiNO1 0822aea
[Refactor] Remove unused keys
fanqiNO1 0282eb0
[Refactor] Change the _base_ path
fanqiNO1 9841292
[Refactor] Reformat
fanqiNO1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
configs/mae/benchmarks/vit-huge-p14_8xb128-ds-zero3-coslr-50e_in1k.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
_base_ = [ | ||
'../../_base_/datasets/imagenet_bs64_swin_224.py', | ||
'../../_base_/schedules/imagenet_bs1024_adamw_swin.py', | ||
'../../_base_/default_runtime.py', 'vit-huge-p14_8xb128-coslr-50e_in1k.py' | ||
] | ||
|
||
# optimizer wrapper | ||
# learning rate and layer decay rate are set to 0.004 and 0.75 respectively | ||
optim_wrapper = dict( | ||
type='DeepSpeedOptimWrapper', | ||
optimizer=dict( | ||
type='AdamW', lr=4e-3, weight_decay=0.05, betas=(0.9, 0.999)), | ||
constructor='LearningRateDecayOptimWrapperConstructor', | ||
paramwise_cfg=dict( | ||
layer_decay_rate=0.75, | ||
custom_keys={ | ||
'.ln': dict(decay_mult=0.0), | ||
'.bias': dict(decay_mult=0.0), | ||
'.cls_token': dict(decay_mult=0.0), | ||
'.pos_embed': dict(decay_mult=0.0) | ||
})) | ||
|
||
# training strategy | ||
# Deepspeed with ZeRO3 + fp16 | ||
strategy = dict( | ||
type='DeepSpeedStrategy', | ||
fp16=dict( | ||
enabled=True, | ||
fp16_master_weights_and_grads=False, | ||
loss_scale=0, | ||
loss_scale_window=500, | ||
hysteresis=2, | ||
min_loss_scale=1, | ||
initial_scale_power=15, | ||
), | ||
inputs_to_half=['inputs'], | ||
zero_optimization=dict( | ||
stage=3, | ||
allgather_partitions=True, | ||
reduce_scatter=True, | ||
allgather_bucket_size=50000000, | ||
reduce_bucket_size=50000000, | ||
overlap_comm=True, | ||
contiguous_gradients=True, | ||
cpu_offload=False, | ||
)) | ||
|
||
# runner which supports strategies | ||
runner_type = 'FlexibleRunner' |
49 changes: 49 additions & 0 deletions
49
configs/mae/benchmarks/vit-large-p16_8xb128-ds-zero3-coslr-50e_in1k.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
_base_ = [ | ||
fanqiNO1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'../../_base_/datasets/imagenet_bs64_swin_224.py', | ||
'../../_base_/schedules/imagenet_bs1024_adamw_swin.py', | ||
'../../_base_/default_runtime.py', 'vit-large-p16_8xb128-coslr-50e_in1k.py' | ||
] | ||
|
||
# optimizer wrapper | ||
# learning rate and layer decay rate are set to 0.004 and 0.75 respectively | ||
optim_wrapper = dict( | ||
type='DeepSpeedOptimWrapper', | ||
optimizer=dict( | ||
type='AdamW', lr=4e-3, weight_decay=0.05, betas=(0.9, 0.999)), | ||
constructor='LearningRateDecayOptimWrapperConstructor', | ||
paramwise_cfg=dict( | ||
layer_decay_rate=0.75, | ||
custom_keys={ | ||
'.ln': dict(decay_mult=0.0), | ||
'.bias': dict(decay_mult=0.0), | ||
'.cls_token': dict(decay_mult=0.0), | ||
'.pos_embed': dict(decay_mult=0.0) | ||
})) | ||
|
||
# training strategy | ||
# Deepspeed with ZeRO3 + fp16 | ||
strategy = dict( | ||
type='DeepSpeedStrategy', | ||
fp16=dict( | ||
enabled=True, | ||
fp16_master_weights_and_grads=False, | ||
loss_scale=0, | ||
loss_scale_window=500, | ||
hysteresis=2, | ||
min_loss_scale=1, | ||
initial_scale_power=15, | ||
), | ||
inputs_to_half=['inputs'], | ||
zero_optimization=dict( | ||
stage=3, | ||
allgather_partitions=True, | ||
reduce_scatter=True, | ||
allgather_bucket_size=50000000, | ||
reduce_bucket_size=50000000, | ||
overlap_comm=True, | ||
contiguous_gradients=True, | ||
cpu_offload=False, | ||
)) | ||
|
||
# runner which supports strategies | ||
runner_type = 'FlexibleRunner' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.