This repository was archived by the owner on Aug 7, 2024. It is now read-only.
[bc breaking] unify filtering functions#322
Closed
vkuzo wants to merge 3 commits intogh/vkuzo/33/basefrom
Closed
Conversation
Summary: bc breaking, but we don't have bc yet, so just mentioning this upfront Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: bc breaking, but we don't have bc yet, so just mentioning this upfront Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
awgu
reviewed
Jul 22, 2024
Summary:
Before this PR, we had two top level filtering affordances on `swap_linear_with_float8_linear`: `skip_fqn_list` and `linear_layer_filter`:
```
def swap_linear_with_float8_linear(
...,
skip_fqn_list: Optional[List[str]] = None,
linear_layer_filter: Optional[Callable[[nn.Linear], bool]] = None,
)
```
This PR unifies them into a single filtering method which is aware of both the FQN as well as the module instance. This should be more future proof and allow for more fine grained filtering.
```
def swap_linear_with_float8_linear(
...,
layer_filter_fn: Optional[Callable[[str, nn.Module], bool]] = None,
)
```
Note that the `filter_out_small_unaligned_layers` function is removed from the public API, and users are encouraged to write their own, again to make this more future proof. I'm not opposed to adding good utility functions back at some point, but IMO we should finalize the main UX first.
Note that in the future (as outlined in the Meta-only UX discussion doc), we may change this function from being just a filter to also providing the float8 per-module config. I'm saving that for a separate PR, which will also be BC breaking (but we don't have BC yet).
Test Plan:
```
./test/test_everything.sh
```
Reviewers:
Subscribers:
Tasks:
Tags:
[ghstack-poisoned]
y-sq
approved these changes
Jul 22, 2024
Contributor
Author
|
@vkuzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
This pull request has been merged in 9d5f892. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Summary:
Before this PR, we had two top level filtering affordances on
swap_linear_with_float8_linear:skip_fqn_listandlinear_layer_filter:This PR unifies them into a single filtering method which is aware of both the FQN as well as the module instance. This should be more future proof and allow for more fine grained filtering.
Note that the
filter_out_small_unaligned_layersfunction is removed from the public API, and users are encouraged to write their own, again to make this more future proof. I'm not opposed to adding good utility functions back at some point, but IMO we should finalize the main UX first.Note that in the future (as outlined in the Meta-only UX discussion doc), we may change this function from being just a filter to also providing the float8 per-module config. I'm saving that for a separate PR, which will also be BC breaking (but we don't have BC yet).
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D60072597