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

[FSDP][9/N] Introduce CustomPolicy #104986

Closed
wants to merge 9 commits into from
Closed

Commits on Jul 11, 2023

  1. [FSDP][9/N] Introduce LambdaWrapPolicy

    [ghstack-poisoned]
    awgu committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    f671536 View commit details
    Browse the repository at this point in the history
  2. Update on "[FSDP][9/N] Introduce LambdaWrapPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    
    
    
    [ghstack-poisoned]
    awgu committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    c384f78 View commit details
    Browse the repository at this point in the history
  3. Update on "[FSDP][9/N] Introduce LambdaWrapPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    
    
    
    [ghstack-poisoned]
    awgu committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    a8d980e View commit details
    Browse the repository at this point in the history
  4. Update on "[FSDP][9/N] Introduce LambdaWrapPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    
    
    
    [ghstack-poisoned]
    awgu committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    0dbb0c6 View commit details
    Browse the repository at this point in the history
  5. Update on "[FSDP][9/N] Introduce LambdaWrapPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    ---
    
    After this PR, the follow-up work items for auto wrapping are:
    1. Add shared parameter validation
    2. (Longer-term / exploratory) Add a policy that provides a reasonable auto wrapping with "minimal" user input
    
    
    [ghstack-poisoned]
    awgu committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    89b13a0 View commit details
    Browse the repository at this point in the history
  6. Update on "[FSDP][9/N] Introduce LambdaWrapPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    ---
    
    After this PR, the follow-up work items for auto wrapping are:
    1. Add shared parameter validation
    2. (Longer-term / exploratory) Add a policy that provides a reasonable auto wrapping with "minimal" user input
    
    
    [ghstack-poisoned]
    awgu committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    0c1c37b View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2023

  1. Update on "[FSDP][9/N] Introduce CustomPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    ---
    
    After this PR, the follow-up work items for auto wrapping are:
    1. Add shared parameter validation
    2. (Longer-term / exploratory) Add a policy that provides a reasonable auto wrapping with "minimal" user input
    
    
    [ghstack-poisoned]
    awgu committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    d0bbb31 View commit details
    Browse the repository at this point in the history
  2. Update on "[FSDP][9/N] Introduce CustomPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    ---
    
    After this PR, the follow-up work items for auto wrapping are:
    1. Add shared parameter validation
    2. (Longer-term / exploratory) Add a policy that provides a reasonable auto wrapping with "minimal" user input
    
    
    [ghstack-poisoned]
    awgu committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    c938136 View commit details
    Browse the repository at this point in the history
  3. Update on "[FSDP][9/N] Introduce CustomPolicy"

    This PR adds a new `LambdaWrapPolicy` that acts like the existing `lambda_auto_wrap_policy` except it (1) leverages the new auto wrapping infrastructure and (2) allows overriding FSDP kwargs for particular instances. (1) gives it access to the validation checks (like for frozen parameters), and (2) makes it as expressive as manual wrapping. This should allow us to effectively deprecate manual wrapping if desired.
    
    The API is as follows:
    ```
    def lambda_fn(module: nn.Module) -> Union[bool, Dict[str, Any]]:
        ...
    policy = LambdaWrapPolicy(lambda_fn)
    ```
    The `lambda_fn` can return:
    - `False` or `{}` to indicate no wrapping
    - `True` to indicate wrapping while inheriting the root's FSDP kwargs
    - Non-empty `dict` to indicate wrapping while overriding the specified FSDP kwargs and inheriting the rest from the root
    
    ---
    
    After this PR, the follow-up work items for auto wrapping are:
    1. Add shared parameter validation
    2. (Longer-term / exploratory) Add a policy that provides a reasonable auto wrapping with "minimal" user input
    
    
    [ghstack-poisoned]
    awgu committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    3fdf50f View commit details
    Browse the repository at this point in the history