[KongchangAI]
· 2 min read· 1,283 words

Delta Tokenizer: How Session Deltas and Multi-Core Parallelism Speed Up Long-Prompt Tokenization by 40x

Delta Tokenizer: How Session Deltas and Multi-Core Parallelism Speed Up Long-Prompt Tokenization by 40x

Delta Tokenizer uses incremental reuse and segmented parallelism to remove the overlooked CPU tokenization bottleneck from the TTFT critical path.

The article reveals a frontend bottleneck masked by GPU-side optimizations: in multi-turn agent sessions, KV cache reuses shared prefixes to avoid redundant computation, but tokenization still converts the entire request into token IDs from scratch each time, inflating TTFT and consuming CPU. Delta Tokenizer proposes two paths: incremental tokenization of only the delta between the current and previous request, and segmented parallel encoding for long requests. It speeds up tokenization by ~40x, cuts median TTFT by 59% at 100K tokens in SGLang, and reduces P99 TTFT by 9.5x under load (23x when the frontend is saturated), with consistency verified on 41.8 billion documents.

The Overlooked Frontend Bottleneck: Why KV Cache Can't Save Tokenization

In agent-driven LLM applications, the same session is sent to the model repeatedly, with only a small amount of text appended each turn. Inference engines reuse shared prefixes through KV cache, letting new tokens skip redundant computation. The problem is that tokenization has no such shortcut.

The serving engine's CPU frontend has to start from the very first character every time, converting the entire request into token IDs from scratch. The longer the multi-turn conversation, the more expensive this redundant work becomes — it simultaneously inflates time-to-first-token (TTFT) and keeps consuming CPU. According to the rss source, Delta Tokenizer is a CPU tokenization solution designed specifically for this frontend bottleneck.

Delta Tokenizer paper source page

TTFT (Time To First Token) refers to the time from when a request is issued to when the model returns the first generated token, and it is one of the most sensitive user experience metrics for interactive LLM applications. It consists of two segments: frontend request preprocessing (tokenization, prompt assembly) and backend prefill computation (attention forward pass over the input sequence). KV cache only optimizes the latter — by reusing the key/value tensors of historical tokens to skip redundant prefill. But if frontend tokenization itself takes tens to hundreds of milliseconds, especially when requests have hundreds of thousands of tokens and the CPU frontend is saturated by multiple long requests queued up, this time cannot be masked by GPU-side optimizations. This is exactly why the article emphasizes that "the optimization space is not limited to the GPU side": TTFT is a serial pipeline, and any stage becoming a bottleneck directly manifests as end-to-end latency.

The Incremental Path: Encoding Only the "Changing Tail"

The core idea of Delta Tokenizer is straightforward — tokenize only the delta between the current request and the previous request in the same session.

It retains the previous token sequence, re-encodes only the appended text plus a "short tail" that might be affected by the append, and then stitches the two segments together at a position where the tokenizer's own splitting rules cannot move. The choice of this stitching position is the key to guaranteeing exactness: as long as the junction falls on a boundary that tokenization rules will not cross, the incremental output is byte-for-byte identical to encoding from scratch.

This design directly addresses a property of tokenizers: the splitting decisions of most practical tokenizers are localized, and natural independent boundaries exist between adjacent segments. Finding and exploiting these boundaries enables incrementality without disabling the reference implementation.

Tokenization locality is an underlying property of modern BPE/Unigram-style tokenizers: a single splitting decision typically depends only on a limited context window, and merge rules do not cross arbitrarily distant character boundaries. Because of this, when a long text is cut apart, encoded separately, and then concatenated, the result is often identical to encoding it as a whole — provided the cut point falls where "merge rules will not cross." Delta Tokenizer's incremental stitching exploits exactly this: it retains the old token sequence, re-encodes only the appended text, and seams the old and new segments together at a rule-stable boundary. The "short tail" here refers to the fact that appended text may change how the final few characters of the original sequence are split, so that must be recomputed as well, until an anchor is reached that no regex or merge rule can touch.

Segmented Parallelism for Long Requests: Spreading Four Million Characters Across 16 Cores

For long requests with no reusable state, Delta Tokenizer takes a different path — segmented parallel encoding.

It splits text at positions where practical tokenizers already keep adjacent segments independent, distributes the segments across multiple cores for simultaneous encoding, and then concatenates the outputs into a result fully consistent with the reference encoding. In a 16-core environment, encoding a 4-million-character request is 8.2x faster than serial encoding and 1.6 to 2.1x faster than LoPT.

Worth noting is its scheduling design: a shared CPU pool manages both the chunking of long requests and short incremental updates, so an incremental update can be executed between two chunks rather than queued behind an entire long task. This fine-grained scheduling is especially critical for tail latency under mixed workloads.

Measured Gains: TTFT Reduction and Correctness Verification

Performance data comes from multiple dimensions:

  • The incremental path reduces single-turn session tokenization time by about 40x relative to the Hugging Face reference tokenizer
  • Inside SGLang, median TTFT for the chat interface drops by 59% at 100K tokens
  • Under load, P99 TTFT for agent sessions falls by 9.5x; when the frontend is saturated by long requests, this figure reaches 23x

On correctness, the authors state that every checked output matched the reference implementation, including 41.8 billion documents processed by its fast encoder. Consistency verification at this scale indicates that the incremental stitching and segmented stitching strategies introduce no bias across real-world corpus distributions.

Implications for Inference Serving

Delta Tokenizer reveals an easily overlooked fact: after KV cache, attention optimization, quantization, and other stages have been repeatedly polished, tokenization — this "preprocessing step" — can still be a significant contributor to TTFT, especially in long-prompt and multi-turn agent scenarios.

For inference engine developers, this means the optimization space is not limited to the GPU side. Bringing incremental reuse and segmented parallelism into the CPU frontend, combined with CPU pool scheduling, can yield substantial latency gains without changing the model or output semantics. For products that rely on agent sessions, a large drop in P99 latency often matters more than the median in determining whether user experience is stable.

P99 tail latency refers to the value at the 99th percentile after sorting all request response times from smallest to largest, representing how slow the slowest 1% of requests are. In multi-turn agent session scenarios, users often initiate the next turn before the previous response finishes, forming a continuous interaction stream, and any stall in any turn breaks the perceived continuity. A drop in median TTFT shows the typical case improved, but a drop in P99 shows that "the worst batch of requests" has also been pulled back into an acceptable range — this is exactly the significance of Delta Tokenizer's 23x improvement when long requests saturate the CPU frontend. For high-concurrency inference services, tail latency is often dominated by queuing and resource contention, so mechanisms like the shared CPU pool and fine-grained priority scheduling mentioned in the article often determine whether the overall SLA is met more than single-request acceleration.

One-line Summary

Delta Tokenizer removes the overlooked CPU tokenization bottleneck from the TTFT critical path through incremental reuse and segmented parallelism.

Paragraph Summary

The article reveals a frontend bottleneck masked by GPU-side optimizations: in multi-turn agent sessions, KV cache can reuse shared prefixes to avoid redundant computation, but tokenization still has to convert the entire request into token IDs from scratch each time, continuously inflating time-to-first-token and consuming CPU. Delta Tokenizer proposes two paths: the incremental path tokenizes only the delta between the current request and the previous request, retains the old token sequence and re-encodes the appended text plus the affected short tail, stitching at a boundary that splitting rules cannot cross to guarantee byte-for-byte consistency with the reference implementation; for long requests, it encodes segments in parallel at natural segment boundaries, making a 4-million-character request 8.2x faster than serial on 16 cores. In measurements, the incremental path speeds up tokenization by about 40x, median TTFT at 100K tokens in SGLang drops by 59%, and under load P99 TTFT for agent sessions falls by 9.5x, reaching 23x when long requests saturate the frontend, with consistency verified on 41.8 billion documents.

#Delta Tokenizer#tokenization#TTFT#LLM inference#KV cache#SGLang#CPU frontend#incremental encoding#segmented parallelism
Share:

Related articles