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

Only initialize counterfitted_GLOVE_embedding when needed, massively decreasing ram usage #609

Merged
merged 2 commits into from
Mar 20, 2022

Conversation

duesenfranz
Copy link
Contributor

@duesenfranz duesenfranz commented Feb 9, 2022

What does this PR do?

Summary

By only instanciating the counterfitted_GLOVE_embedding when
necessary, the ram usage decreases by at least two gigabytes and the startup time decreases massively.

Changes

  • WordSwapEmbedding, WordEmbeddingDistance and ThoughtVector only initialize WordEmbedding.counterfitted_GLOVE_embedding upon initialization, not upon python parsing the files containing the class definitions. Initializing counterfitted_GLOVE_embedding means
    • downloading large chunks of data on initial use
    • loading a lot of data into ram, no matter whether it is ever used.

Checklist

  • [ x ] The title of your pull request should be a summary of its contribution.
  • [ x ] Please write detailed description of what parts have been newly added and what parts have been modified. Please also explain why certain changes were made.
  • [ x ] If your pull request addresses an issue, please mention the issue number in the pull request description to make sure they are linked (and people consulting the issue know you are working on it)
  • [ x ] To indicate a work in progress please mark it as a draft on Github.
  • [ x ] Make sure existing tests pass.
  • [ x ] Add relevant tests. No quality testing = no merge.
  • [ x ] All public methods must have informative docstrings that work nicely with sphinx. For new modules/files, please add/modify the appropriate .rst file in TextAttack/docs/apidoc.'

By only instanciating the `counterfitted_GLOVE_embedding` when
necessary, the startup time gets cut by two thirds, while the ram usage
decreases by at least two gigabytes.
@qiyanjun
Copy link
Member

This looks fine. @cogeid mind to help me confirm?

@cogeid
Copy link
Contributor

cogeid commented Feb 25, 2022

This looks fine. @cogeid mind to help me confirm?

yep! This can be merged once it passes all pytests.

@duesenfranz
Copy link
Contributor Author

@cogeid thanks for pushing this forward! :) Is there anything else I should do to get this merged?

@cogeid
Copy link
Contributor

cogeid commented Mar 1, 2022

@cogeid thanks for pushing this forward! :) Is there anything else I should do to get this merged?

Thank you for your contribution! It will be merged this week.

@qiyanjun
Copy link
Member

@srujanjoshi mind to help me check one more on your mac, profiling the RAM size

@qiyanjun qiyanjun merged commit 4c91157 into QData:master Mar 20, 2022
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.

3 participants