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

Z3: optimizations for grad norm calculation and gradient clipping #5504

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

nelyahu
Copy link
Contributor

@nelyahu nelyahu commented May 7, 2024

This PR add the below functionality:

  1. complete_grad_norm_calculation_for_cpu_offload: move total_norm to CPU, as expected device in such case is CPU..
  2. repalce get_global_norm() with torch.linalg.norm for better performance.
  3. unscale_and_clip_grads: replace clipping based on if statement to use torch.clamp for better performance.

change (3) is taken from #5547 (which was closed)

@jomayeri
Copy link
Contributor

Changing this line has been associated with several bugs #5422, #5538

@nelyahu nelyahu changed the title z3 scaled_global_grad_norm: repalce get_global_norm with torch.norm Z3: optimizations for grad norm calculation and gradient clipping May 27, 2024
@loadams
Copy link
Contributor

loadams commented Jun 26, 2024

Changing this line has been associated with several bugs #5422, #5538

@nelyahu - thoughts on this comment, seems last time this line was modified users ran into issues?

@nelyahu
Copy link
Contributor Author

nelyahu commented Jun 26, 2024

Changing this line has been associated with several bugs #5422, #5538

@nelyahu - thoughts on this comment, seems last time this line was modified users ran into issues?

@loadams, Yes - this optimization was already pushed and reverted due to ds-chat (failures in cpu-offload configurations).
i did offline debugging of those failure and improved the code change so it will pass. Since then ds-chat tests where added to DeepSpeed repo CI and it is now passing.
Are there any other tests (full model training for example), that does not exists in the CI, which can be manually ran?

@tjruwase
Copy link
Contributor

i did offline debugging of those failure and improved the code change so it will pass

@nelyahu, it great that you narrowed this down. Do you think a unit test can be added for this case?

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

6 participants