> ## Content Index
> Fetch the complete content index at: https://ettayeb.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Hugging Face rewrites tokenizers in Rust with SIMD and encodes text up to 30× faster
- URL: https://ettayeb.fr/en/ai/tokenizers-v1-encode-decode-scaling-2026-en/
- Published: 2026-09-27T00:00:00.000Z
- Updated: 2026-11-23T15:25:44.000Z
- Description: On September 21, 2026, Hugging Face detailed version 1 of its tokenizers library: the same output as v0.23, but encoding 3 to 30 times faster single-threaded on an Apple M4 Max, thanks to SIMD bitstream splitting and a word cache.
- Author: Walid ETTAYEB
- Tags: AI, tokenizers, hugging-face, inference, rust, performance, #en, #Import 2026-11-23 14:52

**September 21, 2026.** **Hugging Face** publishes a long technical post on the upcoming version 1 of its **tokenizers** library, signed by **Arthur Zucker**, **Stas Bekman**, **Matthieu Futeral**, and **Lysandre Debut**. **v1** promises to produce exactly the same token IDs as **v0.23** while encoding text **3 to 30 times faster** single-threaded on an **Apple M4 Max**. Why it matters: the tokenizer has never been the bottleneck of a machine learning pipeline — until models got fast enough that the **CPU**, not the **GPU**, started starving them of data.

## The tokenizer, the bottleneck nobody was watching

Tokenization is light next to the heavy modeling in the rest of the pipeline. Yet as models get faster and workloads scale — training on massive datasets, serving many concurrent requests, repeatedly processing long inputs — the balance shifts. A slow tokenizer ends up starving the model of data: the **GPU** idles while the **CPU** finishes converting text.

That is the whole point of **v1**: tokenization should stay light and scale with your workflow. A tokenizer turns text into the list of integers a model reads, in four stages — normalization, pre-tokenization, the model stage, and post-processing. Eight of the ten model families measured use **byte pair encoding** (**BPE**), which starts from a pre-token’s bytes and repeatedly merges the highest-ranked adjacent pair. The merge loop is the heart of the problem, and it is where **v1** concentrates most of its work.

## Five changes that make the difference

The post documents five structural changes, each cutting work at a different point in the pipeline.

**Workspace split.** The single crate became a workspace: `tk-encode` is the required runtime, and `tk-serialize`, `tk-convert`, and `tk-train` are linked only when an application needs them. A service that only encodes no longer loads the training code.

**Bitstream splitting.** **BPE** uses a regular expression to split text into pre-tokens. That regex is a fixed parameter of the model, never changing at runtime — so there is no need for a general-purpose regex engine on every encode. **v1** replaces it with a hand-written function called **bitcannon** that uses the CPU’s **SIMD** instructions: the input’s bytes are viewed as parallel bit streams, and boundaries fall out of Boolean operations across whole registers, at **64 bytes** per operation. The same idea drives **Parabix** for text processing and **simdjson** for **JSON**.

**The word cache.** Real text contains repeated words. Because **BPE** always produces the same token IDs for a given pre-token, **v1** saves the result after processing it once, in a thread-local cache. Later occurrences skip the merge entirely — all the more profitable as repeated words take a growing share of the input.

**An allocation-free merge loop.** The previous implementation allocated memory on every call and rebuilt a priority queue for every pre-token. **v1** reuses a caller-owned scratch buffer, stores symbols in a flat array, links adjacent symbols by their positions, and processes a batch of pre-tokens in a single model call. Each candidate pair is packed into a single **64-bit** value with the merge rank in the high bits: comparing two candidates becomes a plain integer comparison, and "no merge here" is the largest possible value, removing a branch.

**Native parallelism.** A shared tokenizer encodes from many threads at once, each thread drawing its scratch buffer and word cache from its own sub-pool, so threads no longer queue on a single lock.

The four stages matter because each became a target. Normalization handles lowercasing and Unicode folding, pre-tokenization splits text into chunks, the model stage maps those chunks to vocabulary IDs, and post-processing attaches special tokens. The headline gains come almost entirely from the model stage, where BPE’s merge loop dominates — but the word cache and bitstream splitter touch the earlier stages, and the batched model call speeds the whole pipeline rather than any single step.

## The numbers: 3 to 30 times faster, 76% scaling

Across the ten model families **v1**’s encode path covers, text is encoded **3 to 30 times faster** than **v0.23** single-threaded on an **Apple M4 Max** — the low end for **t5-base**, the high end for **gpt2**. Scaling reaches **76%** of linear across eight physical cores. And throughout these changes, **v1** produces exactly the same token IDs as the released library: output parity is verified by an **FNV-1a** hash over the IDs, which must match the baseline exactly.

The methodology is as strict as the results: one timing loop for every engine, vocabulary loading excluded from the encode timing, workers pinned to eight distinct physical cores, and medians computed only over cells every engine actually ran. All of it is reproducible from the **tokbench** repository, with a command to rerun the benchmarks on your own hardware.

```bash
# Install the version 1 release candidate (crates.io)
cargo add tokenizers --pre

# Encode-only build, without the training dependency (C++):
cargo add tokenizers --pre --no-default-features --features http

```

## What it changes for teams serving models

The point that matters to integrators: **v1** keeps the same **API** and the same output. The only thing that changes is the version you install. The library thanks **IBM**, **NVIDIA**, and the **ExecuTorch** team for patches and testing across a wide range of hardware — a signal of how broad the affected base is, from workstations to mobile.

The **Python** bindings wrap the same code but add per-call overhead that none of the measurements include. For teams serving models under high concurrency, that is an important caveat: the real gain depends on the language you call, and the **Rust** version remains the reference.

## The roadmap to 1.0.0 and beyond

**v1** is not final yet: it is a release candidate on **crates.io**. The path to **1.0.0** runs through a single encoding implementation, so training and inference can never produce different tokenizations, optional offsets and masks computed only when requested, a rework of the normalizers, and simpler **Python** bindings. Inference-only **C** and **C++** bindings are planned for **ExecuTorch** and **llama.cpp**, with possible **JVM**, **Swift**, and **Go** bindings to follow.

After **1.0.0**, the project will explore **GPU**\-side encoding: the vocabulary would be uploaded once to the device, output positions computed in parallel, and the corresponding bytes gathered on the **GPU** — an optional component aimed at large batches, subject to further prototyping and measurement.

Migration is frictionless by construction: you install the candidate with `cargo add tokenizers --pre`, the **API** stays the one you already call, and encoding returns the same IDs. Only the installed build changes. For teams on a **Rust** pipeline, the switch is a single configuration line — and for the rest, the **Python** bindings wrap the same code, with only a small per-call overhead on top.

## Verdict

**If you serve LLMs in production under high concurrency or with long inputs**, benchmark your tokenizer before assuming it is innocent: a **3 to 30 times** faster encode with strictly identical output is a free latency and **CPU** win you get by changing one install line. **If you train on large datasets**, the same logic applies to your data pipeline — the **GPU** should never wait on the **CPU**. **The broader lesson** is general: as models get faster, the bottleneck migrates to the stages you dismissed as negligible, and that is where the cheapest wins hide.

## References

- [Hugging Face — tokenizers v1: encode, decode and scaling, measured (September 21, 2026)](https://huggingface.co/blog/tokenizers-v1?ref=ettayeb.fr)
- [Hugging Face — tokbench, tokenizer benchmarking suite](https://github.com/huggingface/tokbench?ref=ettayeb.fr)