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

unscale_and_clip_grads: use clamp on device instead of on host #5547

Closed
wants to merge 4 commits into from

Conversation

nelyahu
Copy link
Contributor

@nelyahu nelyahu commented May 20, 2024

if statement causes device-host synhcornization.
clamp operation allows doing the same on the device in more efficient way

if statement causes device-host synhcornization.
clamp operation allows doing the same on the device
in more efficient way
@nelyahu
Copy link
Contributor Author

nelyahu commented May 27, 2024

closed - merged this PR into #5504

@nelyahu nelyahu deleted the clip_using_clamp branch June 9, 2024 10:06
github-merge-queue bot pushed a commit that referenced this pull request Aug 15, 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)

---------

Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
Co-authored-by: Logan Adams <114770087+loadams@users.noreply.github.com>
Co-authored-by: Lev Kurilenko <113481193+lekurile@users.noreply.github.com>
Co-authored-by: Liran Bachar <lbachar@habana.ai>
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.

3 participants