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

Refactor tiktoken import bare except #1024

Merged

Conversation

ringohoffman
Copy link
Contributor

We shouldn't suppress the import error if tiktoken is not installed. Also do the same thing for sentencepiece.

Instead of importing them at the top of the file, we can import them inside the only functions that use them; we can consider a different import structure if we end up needing to access them elsewhere.

This lazy importing should also decrease the load time of these modules.

cc: @msaroufim

We shouldn't suppress the import error if tiktoken is not installed

Instead of importing it at the top of the file, we can import it inside the only functions that use these imports; we can consider a different import structure if we end up needing to access these modules in more places

This lazy importing should also decrease the load time of these modules

Also do the same thing for sentencepiece
Copy link

pytorch-bot bot commented Oct 7, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1024

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit a1e9b2c with merge base c187f87 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 7, 2024
msaroufim
msaroufim previously approved these changes Oct 7, 2024
@msaroufim msaroufim merged commit e7331ab into pytorch:main Oct 7, 2024
17 checks passed
@ringohoffman ringohoffman deleted the remove-tiktoken-import-bare-except branch October 9, 2024 05:17
jainapurva pushed a commit that referenced this pull request Oct 15, 2024
* Refactor tiktoken import bare except

We shouldn't suppress the import error if tiktoken is not installed

Instead of importing it at the top of the file, we can import it inside the only functions that use these imports; we can consider a different import structure if we end up needing to access these modules in more places

This lazy importing should also decrease the load time of these modules

Also do the same thing for sentencepiece

* Remove __future__.annotations import
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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants