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

[Example] Use .fuse() primitive when possible #42

Merged
merged 36 commits into from
Feb 10, 2023

Conversation

chhzh123
Copy link
Contributor

@chhzh123 chhzh123 commented Feb 7, 2023

Description

This PR fixes some issues for the example models:

  • Use .fuse() to fuse the bias+GeLU in the MLP module. Since TorchScript module cannot be hooked and cannot properly work with DeepSpeed ZeRO-3, this feature is unset by default.
  • Use subgraph matching to only optimize a small part of the Albert model instead of replacing a whole layer
  • Fix Albert attention mask shape
  • Remove useless functions in the schedule
  • Fix an argument issue in .replace() and support bias+layernorm fusion

Checklist

  • PR's title starts with a category (e.g. [Bugfix], [Model], [Tutorial], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

@chhzh123
Copy link
Contributor Author

chhzh123 commented Feb 7, 2023

I didn't change the GPT example to avoid conflicts. You can merge #41 first, and I will update other models correspondingly. @comaniac

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

examples/albert/model.py Outdated Show resolved Hide resolved
examples/opt/schedule.py Outdated Show resolved Hide resolved
tests/test_fusion.py Outdated Show resolved Hide resolved
Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM

examples/albert/model.py Outdated Show resolved Hide resolved
@chhzh123
Copy link
Contributor Author

chhzh123 commented Feb 8, 2023

Please do not merge first. I'll also remove the epoi dependency.

@chhzh123
Copy link
Contributor Author

chhzh123 commented Feb 8, 2023

Or do you think it is better to create a separate PR? @comaniac

@comaniac
Copy link
Contributor

comaniac commented Feb 8, 2023

I'm fine with both, so just for your convenience.

@chhzh123
Copy link
Contributor Author

I've changed all the epoi.attention to slapo.op.attention (except for the T5 one). This PR is ready to review and merge @comaniac.

@comaniac comaniac merged commit 6c2e235 into awslabs:main Feb 10, 2023
@comaniac
Copy link
Contributor

Thanks @chhzh123

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.

2 participants