Has anyone looked at Gigatoken-style tokenizer optimizations for llama.cpp? #26091
Replies: 1 comment
|
Short answer: the idea is relevant, but the existing At current master, There is also real optimization headroom in the current tokenizer path. For BPE, a single call goes through However, the headline Gigatoken numbers need careful interpretation for this use case:
A useful way to measure this today is:
The simple break-even relation is useful: for
That shows why prompt length alone does not make tokenization dominant: both costs grow with My practical conclusion would be:
So I would not rule this out as “tokenization is obviously negligible.” The current benchmark suite simply excludes the stage needed to prove that claim. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I am fairly certain we're not sleeping on this already, but just in case:
Video: https://www.youtube.com/watch?v=vFtJeZ7ifTA
Project: https://github.com/marcelroed/gigatoken
I've been following Gigatoken and was wondering whether anyone in the llama.cpp community has evaluated either the project itself or the techniques it uses.
From what I understand, Gigatoken achieves its speedups through SIMD-optimized pretokenization, cache-aware token lookup, aggressive parallelization, and minimizing overhead in the tokenization pipeline. Their benchmarks focus primarily on bulk tokenization workloads and report very large gains across tokenizers used by models we commonly run in llama.cpp (Llama, Qwen, DeepSeek, Gemma, GLM, etc.).
My assumption is that tokenization is not the primary bottleneck for most llama.cpp inference workloads. Once tokenization is complete, prompt processing/prefill and KV-cache construction are likely the dominant costs, especially for larger models and long contexts.
That said, I'm curious whether anyone has measured how much time is actually spent in tokenization versus prefill for workloads such as:
Large prompt ingestion (32K–1M contexts)
Long-context RAG
Embedding generation
Reranking
Batched inference servers
Multi-user llama-server deployments
Agent systems repeatedly tokenizing large document collections
Has anyone profiled modern llama.cpp workloads and determined what percentage of prompt-processing time is spent in tokenization?
More specifically, has there been any investigation into:
Integrating an alternative tokenizer backend
Porting similar optimization techniques into llama.cpp
Improving prompt-ingestion performance for very large contexts
Using a high-performance tokenizer as an optional component for server workloads
My suspicion is that the answer may be "tokenization is already a small fraction of total runtime, so the gains wouldn't move the needle much." If that's the case, I'd be interested to know whether there are existing benchmarks or profiling results that support that conclusion.
Mostly looking for end-to-end latency data rather than tokenizer microbenchmarks. If this has already been evaluated and ruled out, I'd love to hear the reasoning.
All reactions