0. Why a Standalone Post
The first four posts (overview → Kimi K3 → MiniMax M3 → DeepSeek V4) covered how to reshape attention so it holds 1M context without blowing up KV and compute. But from fa3 and fa4 a second thread is visible: attention is being partly replaced by “non-attention” — MiniMax’s MSA sparsifies it, DeepSeek’s CSA/HCA compress it, and the more radical step is to swap some layers for Mamba-style state-space models (SSM).
That yields a class of “hybrid architectures”: Attention layers interleaved with Mamba layers (classically Jamba, one Attention layer per eight Mamba layers). When the architecture changes, the “state” you must maintain at serving / inference time changes too — and that is exactly where engineering footguns hide and get ignored. This post takes it apart.
1. What “Mamba Hybrid State” Means
In a hybrid model, the “memory” needed to advance the sequence comes from two streams:
- Attention layers → KV cache: grows with sequence length, stored in token-sized blocks, with the token sequence as a natural “addressing key.”
- Mamba layers → SSM recurrent state (hidden state h): fixed-size, independent of sequence length, updated recursively as
hₜ = Ā·hₜ₋₁ + B·xₜ,yₜ = C·hₜ.
The “hybrid state” is the whole bundle — KV cache + Mamba SSM state — that PD (Prefill-Decode) disaggregation must carry across nodes from Prefill to Decode. It is called “hybrid,” not “Mamba state,” because both kinds of state must be managed correctly; neither alone is enough.
2. PD Disaggregation: Pure-Attention vs Hybrid Carry Different Things
Pure-attention model (e.g. Llama)
Prefill output ──cross-node──▶ Decode carries only: KV cache (token-id hashed)
wrong blocks surface as obvious degradation / miss → not "silent"
Mamba hybrid model (e.g. Jamba)
Prefill output ──cross-node──▶ Decode must carry BOTH:
A. KV cache (Attention layers, grows with seq, token-id addressed)
B. Mamba SSM state (Mamba layers, fixed-size, position-dependent, no token-id key)
A pure-attention model carries only KV across the boundary; a hybrid model must carry both, and stream B has no “natural key” like Attention does.
3. Why Hybrids Are More Prone to “Silent Hit Misplacement”
The key difference is the addressing key:
- KV cache has a natural key: the token sequence itself is the key, and prefix caches like vLLM’s use block hashes to verify. A wrong block usually shows up as obvious degradation or a miss — easy to catch.
- Mamba SSM state has no token-id key: it is a fixed-size contiguous tensor, addressable only by “position / request context.” Once it is misrouted, mis-numbered, or read stale during transport, the Decode side “thinks it hit” the correct state but actually got another prefix’s / another request’s state — the model keeps generating, but the content is already wrong, and throws no error.
That is “silent hit misplacement”: unlike a wrong KV block that is “loud,” it emits errors silently. Even a pure-attention model’s wrong KV tends to surface; a Mamba state misplacement is stealthier, which is why “cache correctness” targets it specifically.
4. KV Offload + Multi-Connector Amplify the Risk
The phrase “KV offload + Mamba hybrid state + multi-connector PD disaggregation” stacks three amplifiers:
- KV offload (to CPU / NVMe): state no longer lives only in GPU memory; it moves in and out of storage tiers, adding a serialization / deserialization and addressing step.
- Multi-connector: state may flow between Prefill and Decode over different channels; routing gets more complex and block-misplacement probability rises.
- Hybrid state: the two factors above hit both KV and SSM, and the SSM stream has no token-id check.
Together, without forced verification on SSM blocks, the chance that the Decode side “hits” a wrong / stale state without error rises markedly.
5. How to Fix Cache Correctness: Fingerprint the Hybrid State
The answer is not “no offload” or “no multi-connector,” but to give the hybrid state (KV + SSM together) a verifiable identity:
- Fingerprint: derive a unique fingerprint per state block from
layer id + request id + step id + prefix hash, and compare on transfer and on load. - Version / sequence number: Prefill-tagged state carries a version; Decode verifies version match before loading and rejects stale blocks.
- Connector-level state-id: in multi-connector routing, bind each state block to a globally unique state-id and route by id rather than by “position,” avoiding mis-numbering.
One sentence: give the SSM state an identity that, like KV, can be verified — turning misplacement from “silent” into “error, therefore discoverable.”
6. Engineering View: Why This Keeps Getting More Important
- Hybrid architectures are multiplying: Jamba, Zamba, Griffon and others interleave Mamba / SSM with Attention and have become a mainstream frontier route.
- PD disaggregation + offload are cost-cutting defaults: long-context, large-model inference needs cost cuts, so PD split and KV offload are nearly mandatory, and multi-connector is common.
- Correctness at their intersection is the “safe to ship” baseline: a silently misplaced SSM state can quietly degrade an entire service’s output without alerting — a hidden incident in production.
Extension: if you run a hybrid model on vLLM / SGLang with PD disaggregation, check whether the SSM state goes through the same “prefix hash / block check” as KV; many implementations still verify only KV and “bare-copy” the SSM state — exactly the breeding ground for silent hit misplacement.
💬 留言
NaphJohn/LLM-blog尚未启用 Discussions:请在 GitHub 仓库 Settings → General → Features 勾选 Discussions 后刷新本页,评论区即自动显示。