Vault

Series · 10 of 10 published

LLM Tokenization

A progressive study of BPE from the training contract through tokenshop’s fast engine and into gigatoken’s cache and encode optimizations.

  1. Unit 1 The BPE Contract Part I: Revising tokenshop Published

    What BPE training and encoding actually guarantee: frequency vs rank, merge DAGs, self-overlap, and the freedoms every later optimization exploits.

  2. Unit 2 Your Fast Engine Part I: Revising tokenshop Published

    How tokenshop's linked-list encoder and reverse-index trainer work — and why the trainer's linear argmax is the wrong structure at real vocab sizes.

  3. Unit 3 The Pipeline Layer Part I: Revising tokenshop Published

    Pretokenization, special tokens, and the persistence gap — how the GPT-4 regex pattern reshapes BPE, and why the bottleneck moves after a tiny pretoken cache.

  4. Unit 4 Zipf Part II: gigatoken Published

    Why Zipf's law makes most tokenizer work disappear: cache repeated pretokens and run BPE only for the rare misses.

  5. Unit 5 When O(n²) wins Part II: gigatoken Published

    Why a linear O(n²) scan beats a heap for short pretokens: operating points, dual thresholds, Python vs Rust, and when NEON helps.

  6. Unit 6 The regex is the tokenizer now Part II: gigatoken Published

    Why the pretoken boundary scanner becomes the bottleneck after caching, and how SWAR turns a fixed regex into an eight-byte-at-a-time integer scan.

  7. Unit 7 Give the CPU a second path to follow Part II: gigatoken Published

    Why two independent cursors can hide dependency latency in a pretokenizer, why the historical 25% win was narrower than full encoding, and why later production dropped it.

  8. Unit 8 Count cache lines, not operations Part II: gigatoken Published

    Why a warm pretoken-cache hit is a random memory-access problem, and how cache-line-aware entries, prefetching, and huge pages reduce its cost.

  9. Unit 9 The last 100× is a multiplier, not an algorithm Part II: gigatoken Published

    Why the last 100× is core count times a fast single core, and how pretoken-safe chunks plus Amdahl bookkeeping make near-linear scaling real.

  10. Unit 10 Auditing the number Part II: gigatoken Published

    How to audit gigatoken's ~1000× claim: what the ratio is made of, when it shrinks, and which row is the honest one.

← Back to the library