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

add zero optimizer parallel #593

Merged
merged 18 commits into from
Sep 11, 2024
Merged

add zero optimizer parallel #593

merged 18 commits into from
Sep 11, 2024

Conversation

CaitinZhao
Copy link
Collaborator

@CaitinZhao CaitinZhao commented Jul 12, 2024

What does this PR do?

参考deepspeed的zero,在MindSpore的数据并行模式下实现优化器并行算法

Fixes # (issue)

Adds # (feature)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline?
  • Did you make sure to update the documentation with your changes? E.g. record bug fixes or new features in What's New. Here are the
    documentation guidelines
  • Did you build and run the code without any errors?
  • Did you report the running environment (NPU type/MS version) and performance in the doc? (better record it for data loading, model inference, or training tasks)
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@xxx

print(f"rank_id: {rank_id}, group_size: {group_size}")
ms.reset_auto_parallel_context()
ms.set_auto_parallel_context(
parallel_mode=ms.ParallelMode.DATA_PARALLEL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the difference between it ParallelMode.SEMI_AUTO_PARALLEL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented a new version of zero optimizer parallel in DATA_PARALLEL refer to DeepSpeed. Not use the MindSpore automatic parallel process.

@CaitinZhao CaitinZhao force-pushed the master branch 8 times, most recently from 0e46851 to c0a8757 Compare July 17, 2024 03:36
@zhtmike zhtmike mentioned this pull request Aug 6, 2024
6 tasks
@CaitinZhao CaitinZhao force-pushed the master branch 2 times, most recently from 2755198 to dc2d467 Compare August 23, 2024 01:34
@CaitinZhao CaitinZhao force-pushed the master branch 2 times, most recently from e4978fe to 69cce29 Compare September 3, 2024 03:57
Copy link
Collaborator

@SamitHuang SamitHuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: supplement the script for checkpoint merging.

@@ -104,6 +115,10 @@ def construct(self, *inputs):

# 1. compute gradients (of the up-scaled loss w.r.t. the model weights)
grads = self.grad(self.network, weights)(*inputs, scaling_sens_filled)

# Gradient communication
grads = self.zero_helper.cal_gradients(grads)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.zero_helper can be None, need to to add a if condition

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@CaitinZhao CaitinZhao force-pushed the master branch 2 times, most recently from 60c7aaa to a19b806 Compare September 3, 2024 08:25
@CaitinZhao CaitinZhao force-pushed the master branch 2 times, most recently from d9b877e to bb21538 Compare September 10, 2024 09:07
@vigo999 vigo999 added this pull request to the merge queue Sep 11, 2024
Merged via the queue into mindspore-lab:master with commit 5831703 Sep 11, 2024
3 checks passed
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.

4 participants