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

int8 support #488

Merged
merged 2 commits into from
Apr 16, 2023
Merged

int8 support #488

merged 2 commits into from
Apr 16, 2023

Conversation

mitchellnw
Copy link
Contributor

@mitchellnw mitchellnw commented Apr 14, 2023

This PR introduces beta support for int8 training and inference. You can enable int8 training with --use-bnb-linear SwitchBackLinearGlobal or --use-bnb-linear SwitchBackLinearGlobalMemEfficient. For CLIP VIT-Huge this should currently correspond to a 10% training speedup with negligable accuracy difference.

More speedups coming when the attention layer is refactored so that linear layers may be replaced there, too. However, that will require more changes so best to get this merged first.

@rwightman
Copy link
Collaborator

@mitchellnw looks low risk, ready to merge?

@mitchellnw
Copy link
Contributor Author

@rwightman yep, ready to merge!

@@ -277,6 +287,8 @@ def main(args):
if args.ddp_static_graph:
# this doesn't exist in older PyTorch, arg only added if enabled
ddp_args['static_graph'] = True
if args.use_bnb_linear is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

couldn't this be put right after replace_linear() in the previous if use_bnb_linear block?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mitchellnw one q here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep good point that simplifies -- i'll make the change and run a quick test to make sure all good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks @rwightman!

@rwightman rwightman merged commit c48111d into mlfoundations:main Apr 16, 2023
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.

None yet

2 participants