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

Perf improvement 16% by removing offsets. #1587

Merged
merged 9 commits into from
Aug 8, 2024
Merged

Perf improvement 16% by removing offsets. #1587

merged 9 commits into from
Aug 8, 2024

Conversation

Narsil
Copy link
Collaborator

@Narsil Narsil commented Aug 2, 2024

Offsets calculation are always calculated in Python land. By changing it to not being calculated, we win 16% of the runtime.

This is not the total extent of it because offsets are still calculated in bytes.

On M3.
Before:

==============
num_threads: 8, data size: 24.04 MB, documents: 10000 Avg Length: 1659
tiktoken 	59.51 MB  / s
huggingface 	25.36 MB / s
==============
num_threads: 8, data size: 1.11 MB, documents: 10000 Avg Length: 116
tiktoken 	7.48 MB  / s
huggingface 	20.93 MB / s

After:

==============
num_threads: 8, data size: 24.04 MB, documents: 10000 Avg Length: 1659
tiktoken 	60.38 MB  / s
huggingface 	30.31 MB / s
==============
num_threads: 8, data size: 1.11 MB, documents: 10000 Avg Length: 116
tiktoken 	5.94 MB  / s
huggingface 	24.78 MB / s
==============

On AMD EPYC 7R13 Processor:

Before:

num_threads: 32, data size: 24.04 MB, documents: 10000 Avg Length: 1659
tiktoken        29.88 MB  / s
huggingface     28.14 MB / s
==============
num_threads: 32, data size: 1.11 MB, documents: 10000 Avg Length: 116
tiktoken        2.85 MB  / s
huggingface     22.27 MB / s

After:

==============
num_threads: 32, data size: 24.59 KB, documents: 10 Avg Length: 1662
tiktoken        4.97 MB  / s
huggingface     4.73 MB / s
==============
num_threads: 32, data size: 24.04 MB, documents: 10000 Avg Length: 1659
tiktoken        29.78 MB  / s
huggingface     49.95 MB / s
==============
num_threads: 32, data size: 1.11 MB, documents: 10000 Avg Length: 116
tiktoken        2.85 MB  / s
huggingface     29.28 MB / s

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Narsil added 3 commits August 8, 2024 10:09
Offsets calculation are always calculated in Python land.
By changing it to not being calculated, we win 16% of the runtime.

This is not the total extent of it because offsets are
still calculated in bytes.
@Narsil Narsil force-pushed the ignore_char_offsets branch from c8d4a75 to 913c389 Compare August 8, 2024 08:09
@Narsil Narsil changed the title [Breaking Change] Perf improvement 16% by removing offsets. Perf improvement 16% by removing offsets. Aug 8, 2024
tokenizers/src/tokenizer/pre_tokenizer.rs Outdated Show resolved Hide resolved
tokenizers/src/tokenizer/mod.rs Outdated Show resolved Hide resolved
Narsil and others added 2 commits August 8, 2024 14:47
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
@Narsil Narsil merged commit bfd9cde into main Aug 8, 2024
13 checks passed
@Narsil Narsil deleted the ignore_char_offsets branch August 8, 2024 12:56
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