Vibeleaderboard
← All Intel
Intel / post

Garbled tokens were a KV cache race, not a model problem

Source
x.com
Date
Z.ai@Zai_org
Thread · 6 parts

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.

Read the full thread on X

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.

Terms in this piece · Glossary
  • 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.
More from Z.ai
Recommended reads
Comments

Checking sign-in…

Loading comments…