logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·02.11.26
← Back to news

GigaToken: ~1000x faster Language model tokenization

Original article
github.com|34 points|2 comments|by syrusakbary|Jul 22, 2026

GigaToken: Achieving ≈1000×\approx 1000\times≈1000× Acceleration in LM Tokenization

GigaToken is a high-performance, drop-in replacement for standard language model tokenizers, designed to push tokenization speeds into the GB/s range.

Important Context: It is worth noting that both tiktoken and HuggingFace (HF) tokenizers are already implemented in multithreaded Rust. GigaToken manages to significantly outperform them regardless.

The library is compatible with a vast array of CPU architectures and supports nearly every widely-used tokenizer currently in existence.


🚀 Getting Started

Installation

To integrate GigaToken into your environment, simply run: pip install gigatoken

Setup Checklist

  • Install Python 3.x
  • Run pip install gigatoken
  • Identify your target model (e.g., Llama 3, GPT-2, Qwen)

🛠 Usage Patterns

GigaToken offers two distinct ways to operate: a Compatibility Mode for ease of integration and a Native API for maximum throughput.

1. Compatibility Mode (The "Easy" Path)

This mode allows you to swap your existing tokenizer with GigaToken with minimal code changes.

import gigatoken as gt

# For HuggingFace users
hf_tokenizer = ... 
tokenizer = hf_tokenizer.as_hf() 
tokens = tokenizer.encode_batch(["This is a test string", "And here is another"])

# For tiktoken users
tiktokenizer = ...
tokenizer = tiktokenizer.as_tiktoken()
tokens = tokenizer.encode_batch(["This is a test string", "And here is another"])

Nuance Note: While GigaToken strives for exact output parity with HF tokenizers in this mode, achieving this precision comes at a zero non-negligible performance cost. You will still see massive gains, but you won't hit the peak 1000×1000\times1000× speedup.

2. GigaToken Native API (The "Fastest" Path)

To unlock the full potential of the Rust backend, use the native API. This allows the system to read data directly from disk, bypassing Python's overhead and maximizing parallelism.

import gigatoken as gt

# Initialize using an HF model identifier
tokenizer = gt.Tokenizer("Qwen/Qwen3-8B")

# Define a file source with a specific separator
file_source = gt.TextFileSource(["owt_train.txt"], separator=b"|endoftext|")

# Execute high-speed encoding
tokens = tokenizer.encode_files(file_source)

Data Flow Comparison


📊 Performance Benchmarks

The following tests were conducted using the owt_train.txt dataset (size: 11.9 GB11.9\text{ GB}11.9 GB).

Hardware: AMD EPYC 9565 (144 Cores)

TokenizerGigaTokenHF Tokenizerstiktokenvs HFvs tiktoken
GPT-224.53 GB/s24.53\text{ GB/s}24.53 GB/s24.8 MB/s24.8\text{ MB/s}24.8 MB/s36.0 MB/s36.0\text{ MB/s}36.0 MB/s989×989\times989×681×681\times681×
Phi-424.00 GB/s24.00\text{ GB/s}24.00 GB/s29.9 MB/s29.9\text{ MB/s}29.9 MB/s—801×801\times801×—
GPT-OSS23.96 GB/s23.96\text{ GB/s}23.96 GB/s49.7 MB/s49.7\text{ MB/s}49.7 MB/s42.8 MB/s42.8\text{ MB/s}42.8 MB/s482×482\times482×560×560\times560×
OLMo 2/323.06 GB/s23.06\text{ GB/s}23.06 GB/s27.7 MB/s27.7\text{ MB/s}27.7 MB/s—833×833\times833×—
Nemotron 322.79 GB/s22.79\text{ GB/s}22.79 GB/s49.4 MB/s49.4\text{ MB/s}49.4 MB/s—462×462\times462×—
Qwen 322.16 GB/s22.16\text{ GB/s}22.16 GB/s34.2 MB/s34.2\text{ MB/s}34.2 MB/s—648×648\times648×—
Llama 3/3.1/3.222.15 GB/s22.15\text{ GB/s}22.15 GB/s48.5 MB/s48.5\text{ MB/s}48.5 MB/s—457×457\times457×—
GLM 520.97 GB/s20.97\text{ GB/s}20.97 GB/s74.8 MB/s74.8\text{ MB/s}74.8 MB/s—280×280\times280×—
Llama 3.320.82 GB/s20.82\text{ GB/s}20.82 GB/s48.3 MB/s48.3\text{ MB/s}48.3 MB/s—431×431\times431×—
Llama 420.77 GB/s20.77\text{ GB/s}20.77 GB/s72.7 MB/s72.7\text{ MB/s}72.7 MB/s—286×286\times286×—
GLM 420.61 GB/s20.61\text{ GB/s}20.61 GB/s72.3 MB/s72.3\text{ MB/s}72.3 MB/s—285×285\times285×—
Phi-4-mini20.05 GB/s20.05\text{ GB/s}20.05 GB/s27.6 MB/s27.6\text{ MB/s}27.6 MB/s—726×726\times726×—
DeepSeek V3/R1/V419.69 GB/s19.69\text{ GB/s}19.69 GB/s26.2 MB/s26.2\text{ MB/s}26.2 MB/s—750×750\times750×—
Qwen 2/2.519.12 GB/s19.12\text{ GB/s}19.12 GB/s27.7 MB/s27.7\text{ MB/s}27.7 MB/s—691×691\times691×—
Kimi K218.85 GB/s18.85\text{ GB/s}18.85 GB/s————
Qwen 3.5/3.615.49 GB/s15.49\text{ GB/s}15.49 GB/s27.7 MB/s27.7\text{ MB/s}27.7 MB/s—558×558\times558×—
Gemma 44.82 GB/s4.82\text{ GB/s}4.82 GB/s334.1 MB/s334.1\text{ MB/s}334.1 MB/s—14×14\times14×—
ModernBERT4.18 GB/s4.18\text{ GB/s}4.18 GB/s26.9 MB/s26.9\text{ MB/s}26.9 MB/s—155×155\times155×—
Mistral 7B v0.33.57 GB/s3.57\text{ GB/s}3.57 GB/s354.7 MB/s354.7\text{ MB/s}354.7 MB/s—10×10\times10×—
TinyLlama/Phi-33.48 GB/s3.48\text{ GB/s}3.48 GB/s323.6 MB/s323.6\text{ MB/s}323.6 MB/s—11×11\times11×—
CodeLlama3.47 GB/s3.47\text{ GB/s}3.47 GB/s347.4 MB/s347.4\text{ MB/s}347.4 MB/s—10.0×10.0\times10.0×—
Gemma 33.43 GB/s3.43\text{ GB/s}3.43 GB/s357.2 MB/s357.2\text{ MB/s}357.2 MB/s—9.6×9.6\times9.6×—
Gemma 12.51 GB/s2.51\text{ GB/s}2.51 GB/s342.2 MB/s342.2\text{ MB/s}342.2 MB/s—7.3×7.3\times7.3×—

Hardware: Apple M4 Max (16 Cores)

TokenizerGigaTokenHF Tokenizerstiktokenvs HFvs tiktoken
GPT-28.79 GB/s8.79\text{ GB/s}8.79 GB/s6.9 MB/s6.9\text{ MB/s}6.9 MB/s62.8 MB/s62.8\text{ MB/s}62.8 MB/s1,268×1,268\times1,268×140×140\times140×
Nemotron 37.82 GB/s7.82\text{ GB/s}7.82 GB/s10.9 MB/s10.9\text{ MB/s}10.9 MB/s—715×715\times715×—
Phi-47.76 GB/s7.76\text{ GB/s}7.76 GB/s7.7 MB/s7.7\text{ MB/s}7.7 MB/s—1,012×1,012\times1,012×—
Llama 3/3.1/3.27.60 GB/s7.60\text{ GB/s}7.60 GB/s11.2 MB/s11.2\text{ MB/s}11.2 MB/s—676×676\times676×—
OLMo 2/37.56 GB/s7.56\text{ GB/s}7.56 GB/s5.8 MB/s5.8\text{ MB/s}5.8 MB/s—1,299×1,299\times1,299×—
Llama 3.37.50 GB/s7.50\text{ GB/s}7.50 GB/s15.7 MB/s15.7\text{ MB/s}15.7 MB/s—479×479\times479×—
Phi-4-mini6.97 GB/s6.97\text{ GB/s}6.97 GB/s7.2 MB/s7.2\text{ MB/s}7.2 MB/s—964×964\times964×—
Kimi K26.88 GB/s6.88\text{ GB/s}6.88 GB/s————
Llama 46.81 GB/s6.81\text{ GB/s}6.81 GB/s11.6 MB/s11.6\text{ MB/s}11.6 MB/s—590×590\times590×—
Qwen 2/2.56.37 GB/s6.37\text{ GB/s}6.37 GB/s5.8 MB/s5.8\text{ MB/s}5.8 MB/s—1,105×1,105\times1,105×—
Qwen 36.36 GB/s6.36\text{ GB/s}6.36 GB/s6.9 MB/s6.9\text{ MB/s}6.9 MB/s—918×918\times918×—
Qwen 3.5/3.66.31 GB/s6.31\text{ GB/s}6.31 GB/s6.3 MB/s6.3\text{ MB/s}6.3 MB/s—994×994\times994×—
GPT-OSS6.20 GB/s6.20\text{ GB/s}6.20 GB/s20.2 MB/s20.2\text{ MB/s}20.2 MB/s87.2 MB/s87.2\text{ MB/s}87.2 MB/s306×306\times306×71×71\times71×
GLM 46.17 GB/s6.17\text{ GB/s}6.17 GB/s15.8 MB/s15.8\text{ MB/s}15.8 MB/s—392×392\times392×—
DeepSeek V3/R1/V45.68 GB/s5.68\text{ GB/s}5.68 GB/s7.2 MB/s7.2\text{ MB/s}7.2 MB/s—788×788\times788×—
GLM 55.55 GB/s5.55\text{ GB/s}5.55 GB/s12.2 MB/s12.2\text{ MB/s}12.2 MB/s—456×456\times456×—
ModernBERT2.64 GB/s2.64\text{ GB/s}2.64 GB/s5.8 MB/s5.8\text{ MB/s}5.8 MB/s—452×452\times452×—
Mistral 7B v0.31.99 GB/s1.99\text{ GB/s}1.99 GB/s95.1 MB/s95.1\text{ MB/s}95.1 MB/s—21×21\times21×—
Gemma 41.82 GB/s1.82\text{ GB/s}1.82 GB/s85.2 MB/s85.2\text{ MB/s}85.2 MB/s—21×21\times21×—
CodeLlama1.73 GB/s1.73\text{ GB/s}1.73 GB/s80.2 MB/s80.2\text{ MB/s}80.2 MB/s—22×22\times22×—
TinyLlama/Phi-31.69 GB/s1.69\text{ GB/s}1.69 GB/s80.1 MB/s80.1\text{ MB/s}80.1 MB/s—21×21\times21×—
Gemma 11.42 GB/s1.42\text{ GB/s}1.42 GB/s85.7 MB/s85.7\text{ MB/s}85.7 MB/s—17×17\times17×—
Gemma 31.38 GB/s1.38\text{ GB/s}1.38 GB/s82.2 MB/s82.2\text{ MB/s}82.2 MB/s—17×17\times17×—

Hardware: AMD Ryzen 7 9800X3D (16 Cores)

| Tokenizer | GigaToken |