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

[dtensor] enable foreach operators for adam optimizer #112108

Closed
wants to merge 4 commits into from

Commits on Oct 26, 2023

  1. [dtensor] enable foreach operators for adam optimizer

    This PR enables basic foreach ops in DTensor for adam optimizer, to improve performance
    compare to optimizer using torch.Tensor. Currently by default optimizer
    won't do this for tensor subclass, we will need to enable this by
    default in DTensor when all ops are covered, or early enable this when
    exploring new FSDP, we just need to append DTensor to the optimizer
    allow list.
    
    cc @awgu
    
    [ghstack-poisoned]
    wanchaol committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    18d204c View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2023

  1. Update on "[dtensor] enable foreach operators for adam optimizer"

    This PR enables basic foreach ops in DTensor for adam optimizer, to improve performance
    compare to optimizer using torch.Tensor. Currently by default optimizer
    won't do this for tensor subclass, we will need to enable this by
    default in DTensor when all ops are covered, or early enable this when
    exploring new FSDP, we just need to append DTensor to the optimizer
    allow list.
    
    cc awgu
    
    [ghstack-poisoned]
    wanchaol committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    4983408 View commit details
    Browse the repository at this point in the history
  2. Update on "[dtensor] enable foreach operators for adam optimizer"

    This PR enables basic foreach ops in DTensor for adam optimizer, to improve performance
    compare to optimizer using torch.Tensor. Currently by default optimizer
    won't do this for tensor subclass, we will need to enable this by
    default in DTensor when all ops are covered, or early enable this when
    exploring new FSDP, we just need to append DTensor to the optimizer
    allow list.
    
    Some latency measurement, on a 5-layer MLP model:
    single tensor adam: 17ms
    ![Screenshot 2023-10-29 at 10 48 22 PM](https://github.com/pytorch/pytorch/assets/9443650/8937d786-b863-4318-88c2-12e43180ce8d)
    foreach multitensor adam: 4ms
    ![Screenshot 2023-10-29 at 10 50 58 PM](https://github.com/pytorch/pytorch/assets/9443650/de105cc3-8e12-4765-938a-763d8e958194)
    
    so around 4.25x improvement
    
    cc awgu
    
    [ghstack-poisoned]
    wanchaol committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    34ed934 View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2023

  1. Update on "[dtensor] enable foreach operators for adam optimizer"

    This PR enables basic foreach ops in DTensor for adam optimizer, to improve performance
    compare to optimizer using torch.Tensor. Currently by default optimizer
    won't do this for tensor subclass, we will need to enable this by
    default in DTensor when all ops are covered, or early enable this when
    exploring new FSDP, we just need to append DTensor to the optimizer
    allow list.
    
    Some latency measurement, on a 5-layer MLP model:
    single tensor adam: 17ms
    ![Screenshot 2023-10-29 at 10 48 22 PM](https://github.com/pytorch/pytorch/assets/9443650/8937d786-b863-4318-88c2-12e43180ce8d)
    foreach multitensor adam: 4ms
    ![Screenshot 2023-10-29 at 10 50 58 PM](https://github.com/pytorch/pytorch/assets/9443650/de105cc3-8e12-4765-938a-763d8e958194)
    
    so around 4.25x improvement
    
    cc awgu
    
    [ghstack-poisoned]
    wanchaol committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    e17ac89 View commit details
    Browse the repository at this point in the history