r/mlscaling • u/Naukastrasse • 6h ago
I built a Rust BPE tokenizer that hits 4.5 GB/s cold (9.0 GB/s on Llama-4-Scout) — 2.5–10x faster than gigatoken, 13–24x faster startup, drop-in for AutoTokenizer
Every time tokenization speed comes up, people point to tiktoken or gigatoken. So I benchmarked tuetoken 0.1.10 against gigatoken 0.11.0, fastokens 0.3.7, tiktoken 0.12.0, and Hugging Face’s tokenizers and transformers. I checked that the token IDs matched exactly on the inputs tested, then ran the cold 1 GB tests in fresh OS processes.
GitHub: https://github.com/tuetoken-org/tuetoken
Install with pip install tuetoken. MIT licensed.
Results on an Apple M4 Max (14 cores):
• Cold 1 GB with o200k_base: tuetoken hit 4.50 GB/s. That’s 2.5× gigatoken (1.79 GB/s), 7.7× fastokens (584 MB/s), 71× tiktoken (63 MB/s), and 474× Hugging Face (9.5 MB/s).
• Model tokenizers on 25 MB of text: Llama 4 Scout hit 9.00 GB/s (3.8× gigatoken), Qwen3-8B 6.77 GB/s (4.1×), Gemma 3 4B 5.07 GB/s (10.2×), Mistral 7B 4.93 GB/s (9.2×), and DeepSeek V3 3.77 GB/s (2.1×). Seed-Coder-8B (6.83 GB/s) and Falcon-H1-7B (2.76 GB/s) also worked out of the box. Neither was supported in gigatoken 0.11.0.
• Startup: Loading tokenizer.json took 7–20 ms, compared with 139–282 ms for gigatoken (13–24× faster) and 84–348 ms for Hugging Face (12–29× faster).
• Padding and truncation: Padding 10,000 docs to 512 tokens hit 6.81 GB/s (10.4× gigatoken). Truncating 50 MB of input to a maximum of 512 tokens took 2.4–2.6 ms for either truncation direction (5.9× faster than gigatoken and 4,381× faster than Hugging Face).
• Whisper: Batch decode_with_timestamps for whisper-large-v3 took 0.098 ms vs. 31.7 ms with transformers (323× faster).
I also tested on Ubuntu with AMD Zen 4, 4 vCPUs, and AVX-512. Tuetoken hit 1.56 GB/s cold and 1.68 GB/s warm, compared with 0.44 and 1.16 GB/s for gigatoken. That’s 3.6× the cold throughput. Startup was 13.1× faster, and tokenizing 100 KB of random hex was 4.7× faster.
To try it, swap your Hugging Face AutoTokenizer import for:
= \_pretrained("Qwen/Qwen3-8B")
If you try it on your hardware or with a different model, I’d love to hear what numbers you get.



