Skip to content

[BE] Delay imports #377

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

Merged
merged 1 commit into from
Apr 22, 2024
Merged

[BE] Delay imports #377

merged 1 commit into from
Apr 22, 2024

Conversation

malfet
Copy link
Contributor

@malfet malfet commented Apr 22, 2024

Do not import neither sentencepiece nor tiktoken until it is requested
Same with importing HTTPError from requests

This reduces time to run python3 torchchat.py --help from 2.29 to 1.58 sec

Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
@malfet malfet requested a review from mikekgfb April 22, 2024 16:47
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 22, 2024
Copy link
Contributor

@orionr orionr left a comment

Choose a reason for hiding this comment

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

Yup - strictly better. We might want to have some try ... except around these if we don't have them included in requirements.txt, but this is good

@orionr orionr merged commit f090514 into main Apr 22, 2024
@malfet malfet deleted the malfet/delay-imports branch April 23, 2024 14:36
malfet added a commit that referenced this pull request Jul 17, 2024
Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
malfet added a commit that referenced this pull request Jul 17, 2024
Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
malfet added a commit that referenced this pull request Jul 17, 2024
Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
malfet added a commit that referenced this pull request Jul 17, 2024
Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
malfet added a commit that referenced this pull request Jul 17, 2024
Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
malfet added a commit that referenced this pull request Jul 17, 2024
Do not import neither sentencepiece nor tiktoken until it is requested

Same with HF hub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants