TokTier

Serving stacks cache prompt KV state while the front end still re-tokenizes the full request text on every call, and coding agents pay the most because each call resubmits a long transcript after a small append that can move token boundaries near the tail. Across 153,951 real agent calls at a 94.1% prompt-cache hit rate, tokenization grows from 10% to 64% of time to first token. TokTier is a stateful CPU and GPU tokenization service with one contract, namely that emitted token IDs always match full reference tokenization. For session continuations it re-tokenizes a small window around the append and splices only when a stable-boundary check passes, otherwise widening or falling back, and for calls without a reusable prefix it runs exact pre-tokenization and BPE on a GPU. Differential campaigns across 17 production tokenizer families covering 1.5e10 split checks show zero divergence, incremental repair takes 0.5 to 1.1 ms from 100K to 3M characters (up to 437x faster than HuggingFace), and median time to first token drops 16 to 34% under vLLM.
Ask this paper
Abstract
LLM serving caches prompt KV state, yet most front ends still re-tokenize the full request on every call. Coding agents pay most: sessions repeatedly submit a long transcript after a small append, which can shift token boundaries near the end of the prior sequence. Across 153,951 calls the median append is ~1.4K characters; only 1.0-3.6% of calls start or rebuild a session, yet those carrymulti-million-character contexts. Fleet prompt-cache hit rate is 94.1%, and as it approaches 0.99, tokenization grows from 10% to 64% of time to first token (TTFT) in component measurements. TokTier is a stateful CPU+GPU tokenization service for this two-mode workload, under one contract: emitted token IDs are always identical to full reference tokenization. For session continuations it re-tokenizes a small window around the append and splices only when a per-request check finds a stable pre-tokenization boundary; failed checks widen the window or fall back to full reference tokenization. For calls without a reusable prefix it runs exact GPT-family regex pre-tokenization and BPE on a GPU. A sampled shadow verifier re-checks live traffic. Across 17 production tokenizer families, differential campaigns cover 1.5x10^10 split checks, a 12.4 TB real-text corpus, and 93,000+ replayed agent steps, with zero divergence. Incremental repair takes 0.5-1.1 ms from 100K to 3M characters, up to 437x faster than HF tokenization and 2.1x faster at 1M characters than the strongest cache-based baseline (Gigatoken) fully prewarmed. GPU tokenization encodes a 1M-character request in 0.87 ms, up to 491x below HF and 23.4x below the fastest published CPU method on the same protocol. With vLLM, median TTFT drops 16-34% and P99 TTFT 23% under recorded bursts. Under a 50 ms P99 objective, a four-core repair pool plus one GPU sustains 1,821 requests/s, where a 16-core stateless front end saturates at 40 requests/s.