Garbled tokens were a KV cache race, not a model problem
- Source
- x.com
- Date
Scaling laws push model capability forward. But whether that capability becomes reliable in production depends on how we handle Scaling Pain. https://t.co/81QCQw941P In our latest blog, we share how we debugged GLM-5 serving at scale: reproducing rare garbled outputs, repetition, and rare-character generation; tracing and eliminating KV Cache race conditions; fixing HiCache synchronization issues; and introducing LayerSplit for up to 132% throughput improvement. We hope these lessons help the community avoid similar pitfalls and build more robust inference infrastructure.
The first challenge: rare garbled outputs, repetition, and rare-character generation were hard to reproduce. They only appeared under high-concurrency, long-context Coding Agent workloads. Speculative decoding metrics became the signal: low spec_accept_length flagged garbled and rare-character outputs; high spec_accept_rate flagged repetition.

One root cause was a KV Cache reuse race under PD disaggregation. Decode could abort a timed-out request and reuse its KV Cache while Prefill was still writing old KV data. The fix was to reclaim KV Cache only after Prefill confirms the writes are safe or complete.

Another root cause was a read-before-ready issue in HiCache. Async cache loading improved efficiency, but the Forward Stream could start before the required cache was fully loaded. We fixed it by adding explicit synchronization before the Indexer kernel, and submitted the fix to the SGLang community as PR #22811.

Context
Z.ai traced one cause of garbled GLM-5 output to two requests interfering with the same cached model state. In its serving setup, prompt processing and text generation ran separately. A timed-out request could release its cache allocation for reuse while the prompt-processing machine was still writing into it. Those late writes could overwrite state belonging to a new request. The company's debugging account describes delaying reuse until the writer confirms that its writes are safe or complete.
This explains why an apparent generation failure can originate in request coordination: the model can receive corrupted working state even when its learned parameters have not changed.
- KV cache — The memory a model keeps about text it has already read, so generating each new token doesn't require reprocessing the whole conversation.
postWe’re sharing how GLM-5.3 helped build and optimize the inference infrastructure serving GLM-5.3-Flash.- postGLM-5 lands in Zhipu's Coding Plan Pro as pricing shifts
articleZ.ai details GLM-5.3's leap in exploit analysis and staged release
postGLM-5.3 API launches for coding and cybersecurity agentic tasks
- postHow an Infra Agent Cut GLM-5.3-Flash Serving Time to Two Weeksjietang
videoKV Cache-Aware Routing and P/D Disaggregation on Kubernetes — Yuchen Fama & Ashish Kamra, Red HatAI Engineer
postWe’re sharing how GLM-5.3 helped build and optimize the inference infrastructure serving GLM-5.3-Flash.Zai_org
Checking sign-in…
Loading comments…