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

Make TiktokenTokenizerWrapper picklable #700

Merged
merged 12 commits into from
Oct 31, 2023

Conversation

irenedea
Copy link
Contributor

@irenedea irenedea commented Oct 27, 2023

Makes TiktokenTokenizerWrapper serializable so we can use it with multi-processing.

Tests

  1. Finetune run with tiktoken tokenizer: test-pickle-tiktoken-ohOd0p
  2. Works with packing
  3. pickle code:
from llmfoundry.tokenizers import TiktokenTokenizerWrapper
t = TiktokenTokenizerWrapper('gpt2')
import pickle
pickle.dumps(t) # works

(Previously, the above code would raise an error: TypeError: cannot pickle 'builtins.CoreBPE' object)

@irenedea irenedea changed the title Make tiktoken wrapper picklable Make TiktokenTokenizerWrapper picklable Oct 27, 2023
@irenedea irenedea marked this pull request as ready for review October 27, 2023 01:52
@samhavens
Copy link
Contributor

Do you know why we are getting /home/runner/work/llm-foundry/llm-foundry/build/lib/llmfoundry/tokenizers/tiktoken.py:59:43 - error: "Encoding" is not a known member of module (reportGeneralTypeIssues) in the Code Quality checks? I was getting this too. Is the CI environment not getting a full install of the tokenizer or something?

@irenedea
Copy link
Contributor Author

@samhavens I think we might need to add the openai deps to the .github workflow file. Will try it!

@irenedea irenedea enabled auto-merge (squash) October 31, 2023 14:45
@irenedea irenedea merged commit 51a174f into mosaicml:main Oct 31, 2023
12 checks passed
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