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

Release optimizer memory and fix legacy tokenization #3043

Merged

Conversation

helpmefindaname
Copy link
Collaborator

@helpmefindaname helpmefindaname commented Jan 4, 2023

This PR does 2 little things:

  • it makes it easier to clean up the gpu memory, by cleaning gradients and deleting the reference of the optimzier. Hence torch.cuda.empty_cache() will be able to clean up more parameters.
  • some (slow) tokenizers like RobertaTokenizer seem to add a [SEP] token at the end, breaking the legacy subword token mapping, which is fixed by allowing that specific token

@helpmefindaname
Copy link
Collaborator Author

With those changes, I managed to train XLM-Roberta-Large (>2GB model) with adam and full precision (4x the memory requirement) on my 6GB laptop graphic card, using transformer-smaller-training-vocab

@alanakbik alanakbik merged commit fa9b104 into master Jan 16, 2023
@alanakbik alanakbik deleted the release_optimizer_memory_and_fix_legacy_tokenization branch January 16, 2023 14:53
@alanakbik
Copy link
Collaborator

@helpmefindaname thanks for improving this!

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