Repository navigation
Conversation
lapp0
force-pushed
the
parallel-model-tokenizer-index-load
branch
from
July 29, 2024 01:29
1bf8c30 to
4058ce0
Compare
rlouf
reviewed
Jul 29, 2024
|
|
||
| from .common import ensure_numba_compiled | ||
|
|
||
| tokenizer_uris = { |
Member
There was a problem hiding this comment.
Can we create synthetic datasets instead of pulling external data?
Contributor
Author
There was a problem hiding this comment.
Done!
The benchmarks show a 95% reduction in runtime, but this is misleading. With the real tokenizers it was ~90% reduction. The difference is that convert_token_to_string is much simpler in this new benchmark AND if "\ufffd" in token_str and not re_replacement_seq.match(token): is never True
lapp0
force-pushed
the
parallel-model-tokenizer-index-load
branch
from
July 29, 2024 20:35
4058ce0 to
144b97a
Compare
lapp0
force-pushed
the
parallel-model-tokenizer-index-load
branch
from
July 29, 2024 20:38
144b97a to
f2abefe
Compare
This file contains hidden or 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
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.
Maybe? fixes #768 (discuss)
Original Issue
The suggestion to execute
reduced_vocabularyand model loading in parallel presents challenges:models.llamacpp, the model must be loaded before accessing the tokenizer, preventing any benefits.models.transformers_visionwould require complex changes.So I looked at
reduced_vocabularyand saw a performance issue similar to one I've seen previously. I applied a similar fix from before (described below) and it works well.Problem
In
main,reduced_vocabularyconstructs a numba List in pure-python mode. There is a serious performance issue fornumba.typed.List.append()calls in pure-python mode.reduced_vocabularyis run once per model load. It is more annoying now that models are starting to have 100,000 - 200,000 token vocabularies.Solution
@njit, convert the dictionary to a list of tuples, where each tuple contains (normalized_token: unicode_type,token_ids: int64[:]).Benchmarks
New benchmarks
Old benchmarks
Open Questions
Why is the benchmark for compiling numba faster? This raises an eyebrow.