---
title: "tokenizers v1: encode, decode and scaling, measured"
description: "tokenizers v1 encodes text 3 to 30 times faster than v0.23 single-threaded on an Apple M4 Max and scales at 76% of linear across eight cores, while producing identical token IDs and keeping the same API."
url: "https://swe.quest/articles/tokenizers-v1-encode-decode-and-scaling-measured-49d0c7f94c7739e1"
canonical: "https://huggingface.co/blog/tokenizers-v1"
source: "Hugging Face"
published: "2026-09-21"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 10
tags: ["performance","rust","llms","algorithms"]
---

# tokenizers v1: encode, decode and scaling, measured

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-09-21, 10 min read, Deep dive. Original: [https://huggingface.co/blog/tokenizers-v1](https://huggingface.co/blog/tokenizers-v1)

## Summary

tokenizers v1 encodes text 3 to 30 times faster than v0.23 single-threaded on an Apple M4 Max and scales at 76% of linear across eight cores, while producing identical token IDs and keeping the same API. The gains come from replacing regex pre-tokenization with SIMD bitstream operations (bitcannon) for common BPE patterns, a thread-local word cache for repeated pre-tokens, an allocation-free merge loop using an intrusive linked list in a scratch buffer with ranks packed into 64-bit integers, batched model calls, and per-thread sub-pools for parallel encoding. The benchmark methodology separates load time, verifies output by hashing IDs, pins to physical cores, and warns that 'warm' benchmarks on repeated versus distinct documents measure very different workloads.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)

## Prerequisites

- byte pair encoding ([easy posts on Video & media](https://swe.quest/tags/video-media.md?difficulty=easy))
- SIMD basics
- Rust crates ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))

## Keywords

Hugging Face tokenizers, BPE, bitcannon, tokbench, SIMD, WordPiece, Unigram

## Related posts

- [Announcing pg\_tiktoken: A Postgres Extension for Fast BPE Tokenization](https://swe.quest/articles/announcing-pg-tiktoken-a-postgres-extension-for-fast-bpe-tokenization-f53006f2756f2730.md): Neon · 2023-03-14 · Medium · 5 min read · PostgreSQL, LLMs, SQL
  pg\_tiktoken is a Postgres extension on Neon that wraps OpenAI's tiktoken BPE tokenizer, exposing tiktoken\_encode (returns token IDs) and tiktoken\_count (returns token counts) for encodings such as cl100k\_base, p50k\_base, p50k\_edit and r50k\_base or their model names.
- [Tokenization in Transformers v5: Simpler, Clearer, and More Modular](https://swe.quest/articles/tokenization-in-transformers-v5-simpler-clearer-and-more-modular-71df3b1e7d817d35.md): Hugging Face · 2025-12-18 · Medium · 14 min read · LLMs, Python, Open source
  Transformers v5 redesigns tokenizers so that tokenizer architecture (normalizer, pre-tokenizer, model, post-processor, decoder) is separated from the trained vocabulary, much as PyTorch separates model architecture from weights.
- [Assisted Generation: a new direction toward low-latency text generation](https://swe.quest/articles/assisted-generation-a-new-direction-toward-low-latency-text-generation-46c4fea13508392f.md): Hugging Face · 2023-05-11 · Medium · 12 min read · Inference & serving, LLMs, Performance engineering, Python
  Assisted generation cuts autoregressive LLM latency by letting a much smaller assistant model with the same tokenizer greedily draft candidate tokens, then verifying them all in a single forward pass of the large model.
- [Prefill and Decode for Concurrent Requests - Optimizing LLM Performance](https://swe.quest/articles/prefill-and-decode-for-concurrent-requests-optimizing-llm-performance-66a6db57e54903ca.md): Hugging Face · 2025-04-16 · Medium · 10 min read · Inference & serving, LLMs, Performance engineering, Hardware
  LLM token generation splits into a compute-bound prefill phase, which processes all prompt tokens in parallel to produce the first token, and a memory-bandwidth-bound decode phase, which produces later tokens one at a time.
- [Speculative Decoding for 2x Faster Whisper Inference](https://swe.quest/articles/speculative-decoding-for-2x-faster-whisper-inference-c8681e4ac958e48b.md): Hugging Face · 2023-12-20 · Medium · 12 min read · Speech & audio, Inference & serving, Performance engineering, Python
  Speculative decoding speeds up Whisper transcription by about 2x while producing mathematically identical outputs.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
