Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

[bc breaking] unify filtering functions #322

Closed
wants to merge 3 commits into from

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Jul 19, 2024

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_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:

Differential Revision: D60072597

Summary:

bc breaking, but we don't have bc yet, so just mentioning this upfront

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Jul 19, 2024
Summary:

bc breaking, but we don't have bc yet, so just mentioning this upfront

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 13302bf112f901b66a8fe25fbbd0ae4fc0a6e95f
Pull Request resolved: #322
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 19, 2024
Summary:

bc breaking, but we don't have bc yet, so just mentioning this upfront

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Jul 19, 2024
Summary:

bc breaking, but we don't have bc yet, so just mentioning this upfront

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: a6664ad758ca9fa4f8a81b4d4c065c61f18cb983
Pull Request resolved: #322
@vkuzo vkuzo requested review from y-sq and drisspg July 19, 2024 22:50
@vkuzo vkuzo changed the title bc breaking - unify filtering functions [bc breaking] unify filtering functions Jul 22, 2024
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@awgu awgu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good to me!

float8_experimental/float8_linear_utils.py Outdated Show resolved Hide resolved
float8_experimental/float8_linear_utils.py Outdated Show resolved Hide resolved
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]
@vkuzo
Copy link
Contributor Author

vkuzo commented Jul 22, 2024

@vkuzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 9d5f892.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants