Skip to content
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

[Feature] Add colossalai strategy #1299

Merged
merged 14 commits into from Aug 18, 2023

Conversation

HAOCHENYE
Copy link
Collaborator

@HAOCHENYE HAOCHENYE commented Aug 9, 2023

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

  1. Add colossalai strategy.
  2. Move DeepSpeedXXX from mmengine/optim and mmengine/model/ to mmengine/_strategy/deepspeed, and delete useless directory

Note: The optimizer state (learning rate) cannot be resumed correctly now. Maybe it will be fixed by ColossalAI in the future.

Environment

  • PyTorch: 2.0.0
  • deepspeed: 0.9.3+d755b9d6
  • CUDA: 11.7
  • GPU: 8 * A100, 80G

Validation

  • resume
  • load_from

Experiment

MMPreTrain

  • vit-large-p16_8xb128-coslr-50e_in1k.py

    ColossalAI GeminiDDP+ bf16: 20.6G per GPU, accuracy: 85.6040

     strategy = dict(
         type='ColossalAIStrategy',
     )
    
     optim_wrapper = dict(
         optimizer=dict(
         type='HybridAdam'),
     )

Training logs

08/14 21:44:53 - mmengine - INFO - Epoch(train)  [1][  20/1252]  base_lr: 4.0000e-03 lr: 9.4379e-09  eta: 11:58:19  time: 0.3768  data_time: 0.0017  memory: 20673  loss: 6.9064
08/14 21:45:00 - mmengine - INFO - Epoch(train)  [1][  40/1252]  base_lr: 4.0000e-03 lr: 1.9056e-08  eta: 9:15:57  time: 0.3779  data_time: 0.0016  memory: 20672  loss: 6.9071
08/14 21:45:08 - mmengine - INFO - Epoch(train)  [1][  60/1252]  base_lr: 4.0000e-03 lr: 2.8673e-08  eta: 8:20:58  time: 0.3760  data_time: 0.0015  memory: 20672  loss: 6.9077
08/14 21:45:16 - mmengine - INFO - Epoch(train)  [1][  80/1252]  base_lr: 4.0000e-03 lr: 3.8291e-08  eta: 7:58:42  time: 0.4151  data_time: 0.0015  memory: 20671  loss: 6.9034
08/14 21:45:25 - mmengine - INFO - Epoch(train)  [1][ 100/1252]  base_lr: 4.0000e-03 lr: 4.7909e-08  eta: 7:57:35  time: 0.3771  data_time: 0.0016  memory: 20671  loss: 6.8877
08/14 21:45:33 - mmengine - INFO - Epoch(train)  [1][ 120/1252]  base_lr: 4.0000e-03 lr: 5.7527e-08  eta: 7:43:16  time: 0.3771  data_time: 0.0015  memory: 20671  loss: 6.8040
08/14 21:45:40 - mmengine - INFO - Epoch(train)  [1][ 140/1252]  base_lr: 4.0000e-03 lr: 6.7144e-08  eta: 7:33:16  time: 0.3781  data_time: 0.0016  memory: 20671  loss: 6.7578
08/14 21:45:48 - mmengine - INFO - Epoch(train)  [1][ 160/1252]  base_lr: 4.0000e-03 lr: 7.6762e-08  eta: 7:25:37  time: 0.3769  data_time: 0.0017  memory: 20671  loss: 6.6219
08/14 21:45:55 - mmengine - INFO - Epoch(train)  [1][ 180/1252]  base_lr: 4.0000e-03 lr: 8.6380e-08  eta: 7:19:39  time: 0.3779  data_time: 0.0016  memory: 20671  loss: 6.4336
08/14 21:46:03 - mmengine - INFO - Epoch(train)  [1][ 200/1252]  base_lr: 4.0000e-03 lr: 9.5998e-08  eta: 7:14:52  time: 0.3765  data_time: 0.0016  memory: 20672  loss: 6.4805
08/14 21:46:12 - mmengine - INFO - Epoch(train)  [1][ 220/1252]  base_lr: 4.0000e-03 lr: 1.0562e-07  eta: 7:18:40  time: 0.5063  data_time: 0.0015  memory: 20671  loss: 6.3190
08/14 21:46:20 - mmengine - INFO - Epoch(train)  [1][ 240/1252]  base_lr: 4.0000e-03 lr: 1.1523e-07  eta: 7:14:53  time: 0.3806  data_time: 0.0016  memory: 20671  loss: 6.2094
08/14 21:46:27 - mmengine - INFO - Epoch(train)  [1][ 260/1252]  base_lr: 4.0000e-03 lr: 1.2485e-07  eta: 7:11:31  time: 0.3773  data_time: 0.0016  memory: 20671  loss: 5.9526
08/14 21:46:35 - mmengine - INFO - Epoch(train)  [1][ 280/1252]  base_lr: 4.0000e-03 lr: 1.3447e-07  eta: 7:08:37  time: 0.3778  data_time: 0.0016  memory: 20671  loss: 6.0162

Modification

Please briefly describe what modification is made in this PR.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@HAOCHENYE HAOCHENYE changed the title update [Feature] Add colossalai strategy Aug 9, 2023
zhouzaida
zhouzaida previously approved these changes Aug 18, 2023
@zhouzaida zhouzaida merged commit db32234 into open-mmlab:main Aug 18, 2023
15 of 19 checks passed
@fanqiNO1 fanqiNO1 mentioned this pull request Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants