-
Notifications
You must be signed in to change notification settings - Fork 840
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
Add FxHash and ShortStringOptimization. #1733
Open
MeetThePatel
wants to merge
12
commits into
huggingface:main
Choose a base branch
from
MeetThePatel:feature-sso
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sounds good! Node bidings are really not necessary! |
Do you want this to be reviewed now? |
Not yet. I'm still working on a few things:
|
I think this is ready for review. Also, these are the distributions for the benchmark runs (blue is this PR, red is HEAD). Besides the speed being a bit faster, it seems to be more consistent as well (as least on my machine). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains performance optimizations (spreadsheet of benchmark comparisons linked below). The two main optimizations are:
Switching to FxHash instead of standard library default hasher. This is provided by the
rustc_hash
crate, which the compiler uses internally.Switch from
String
toCompactString
, provided by thecompact_str
crate, which has short-string-optimization for up to 24 bytes, which many tokens can fit inside of.Progress:
This PR is not fully complete. At this point in time, the following tasks have been completed:
benches/test_tiktoken.py
are basically the same (within a margin of error) of HEAD. I think it is caused by unnecessary type conversions.Benchmarks:
The benchmarks are at the following link: Tokenizer Benchmarks. All benchmarks were run on a Macbook Pro with the M2 Pro chip and 16GB memory.
Additionally, the
BPE Train vocabulary (huge)
benchmark is one that I added (not committed, as that would warrant its own PR). This benchmark is using the dataset: One Billion Word Challenge, which clocks in at 4.15GB.