Hacker News ★ 103 4 min

DeepSeek-v4.1 Flash: Pushing the Limits of KV Cache Compression

🔗 https://zartbot.github.io/blog/model_arch/dsv41flash_arch/en.html

📌 DeepSeek-V4.1 Flash:把 KV Cache 壓到極限的架構

TL;DR:技術報告顯示,DeepSeek-V4.1 Flash 靠 Encoder-Decoder 分離與跨層 KV 壓縮,把長上下文推理成本大幅壓低。

一款號稱「後訓練迭代版」的模型,跑起來卻接近 420 Tokens/s,還伴隨舊版模型陸續下線的消息——這篇部落格作者的觀察,揭開了 DeepSeek-V4.1 Flash 背後其實是一次架構級的重新設計。

🤔 長程 Agent 把 KV Cache 逼到牆角

技術報告指出,近年 Long-horizon Agent 讓超長上下文處理成為越來越重要的工作負載,這類任務不只需要高效處理長序列,還需要 KV Cache 的持久化儲存、複用與傳輸。DeepSeek-V4 原本結合能覆蓋全上下文的 Sparse Attention 與覆蓋局部視窗的 Sliding Window Attention(SWA),雖然降低了計算成本,但持久化儲存與資料搬移逐漸成為更突出的瓶頸:長上下文下 Global KV Cache 的用量會主導記憶體與 SSD 佔用,也對 KV Cache 搬移的互連頻寬提出很高要求,最終限制服務吞吐、推高部署成本。

🧩 Causal Encoder-Decoder 架構:Prefill 只走一半的層

DeepSeek-V4.1-Flash 是一個多模態 MoE 模型,參數規模 552B,原生支援多模態輸入,最長支援 1M token 上下文。核心設計是 Causal Encoder-Decoder(CED)架構:Decoder 的 Global KV Cache 由 Encoder 最終隱藏狀態投影而來,這意味著長 prompt 的大部分位置只需經過模型 40 層中的前 20 層。這一設計借鑑了 YOCO 的思路,使模型在 Prefill 階段每 token 只啟用 8B 參數,Decode 階段啟用 16B 參數,作者認為這種設計對「輸入主導」的 Agent 場景特別划算。

在 KV Cache 壓縮上,報告描述的是名為 CSA2 的跨層壓縮方案,從三個維度同時下手:通道維度上,用一個 512 維的潛在向量共享每個 attention head 所需的 key 與 value 表示;序列維度上,Encoder 透過通道級學習權重把相鄰 2 個位置合併為 1 個快取條目,Decoder 則保留逐位置的快取;層維度上,多層共享同一份 Global KV,整個網路僅保留 3 份 Encoder 快取與 1 份 Decoder 快取。搭配 FP4 量化後,Global 主 KV 與 Indexer 的儲存增長約為每 token 890 位元組。作者將這種設計類比為一種「遞迴 Transformer」架構——透過修改 Q 並在遞迴過程中重複使用 KV,並引用了另一篇論文〈On the Future Transformer: Loops Are Not What You Need〉作為相關參照。

💡 這其實該叫 V5,而不是 V4.1

作者在文中直言,起初以為 V4.1 Flash 只是一次後訓練迭代,直到看完完整技術報告才意識到「應該被稱為 DeepSeek-V5 Flash」。報告給出的比較數據顯示:在相同序列長度下,DeepSeek-V4.1-Flash 所需的運行時 KV Cache 儲存僅約 DeepSeek-V4-Flash 的四分之一,持久化 KV Cache 儲存僅約其八分之一,同時整體效能優於 DeepSeek-V4-Flash——儘管前者的參數規模明顯更大。作者也提到,原始論文對 CED 的敘述較為複雜,但若改以「圍繞 KV Cache、結合電腦架構視角」重新繪圖,設計脈絡會清晰許多。

🎯 實務啟示

對於正在做長上下文 Agent 部署的工程師,這篇分析點出一個值得關注的方向:與其單純堆疊 Sparse Attention 降計算量,不如同時從通道、序列、層三個維度壓縮 KV Cache 本身,才能真正緩解長上下文服務的儲存與頻寬瓶頸。Prefill/Decode 分離啟用參數的設計,也提示了「輸入密集型 Agent 工作負載」在架構層面仍有專門最佳化的空間。

🔗 來源

#DeepSeek #KVCache #LLMInference #ModelArchitecture #LongContext #TransformerArchitecture #MoE #AIInfrastructure #EfficientInference #AgenticAI

原始資料 Hacker News · 收集於 2026-09-17
來源原標題
DeepSeek-v4.1 Flash: Pushing the Limits of KV Cache Compression
作者
mfiguiere
原始標籤
hackernews
來源訊號
HN points 125 HN 留言 10
原始連結
https://zartbot.github.io/blog/model_arch/dsv41flash_arch/en.html

摘要原文

TL;DR When DeepSeek-V4.1 Flash was released, I thought it might just be a post-training iteration version... but after using it for a while, I found it reached nearly 420 Tokens/s in speed, and then Cui said all DeepSeek-V4 Pro models would be taken offline... suddenly I felt this was no small matter... until the Technical Report 《DeepSeek-V4.1-Flash: Pushing the Limits of KV Cache Compression》 [1] was fully released, only then did I realize it should be called DeepSeek-V5 Flash... As the paper title states, the purpose of DeepSeek-V4.1 Flash is to push KVCache compression to the extreme. The main reason is that Long-horizon Agent Workflows cause the Context to grow longer and longer, while various tool calls bring heavy prefill computation pressure. The storage pressure of KVCache in HBM and external SSD is very high, all of which are reasons that make Scaling impossible. Therefore, a series of optimizations were made on the model architecture, especially in the compression of KVCache and the computation optimization of Prefill. Prefill computation optimization : Drawing on YOCO, the entire model has 40 layers, and only 20 layers are needed during Prefill. Therefore, the Prefill activated parameters are only 8B, and the Decode activated parameters are 16B KVCache compression : Engineering-wise, KVCache compression is divided into several dimensions: head count compression similar to GQA, then block-based compression like CSA, and the cross-layer compression of CSA2 in this paper. At the same time, the indexer computation of Sparse Attention is also optimized. Finally, there are some numerical precision optimizations, for example DS41F adopts FP4 KVCache. Finally, under the premise of maintaining high-quality task completion by the model, KVCache is further compressed by 4x: In addition, the original writing of the paper is somewhat complex, especially the description of CED. In fact, if we redraw a diagram centered on KVCache and combined with the perspective of computer architecture, it seems to become clear all at once. It can be seen as a kind of Recursive Transformer architecture, a way of modifying Q and reusing KV during the recursive process. Regarding the Recursive Transformer architecture, you can refer to 《On the Future Transformer: Loops Are Not What You Need》 . Next, we will conduct a detailed interpretation and analysis according to the chapter structure of the technical report. This article is the first in this series, analyzing the model architecture in detail, and the more critical content is in Chapter 3. 1. Overview 1.1 Why KVCache compression is needed First, the report states that in recent years Long-horizon Agents have made ultra-long-context processing an increasingly important model workload. Supporting this type of workload not only requires efficient processing of long sequences, but also requires persistent storage, reuse, and transfer of large KVCache. Therefore, KVCache management has become a fundamental capability of model deployment, while also bringing significant challenges in computation, storage, and communication. Then it goes on to introduce the DeepSeek-V4 architecture, which processes by combining a Sparse Attention that fully covers the context with a Sliding Window Attention (SWA) that covers the local window. Although advances related to Sparse Attention have significantly reduced the computational cost of long sequence processing, persistent storage and data movement have gradually become more prominent bottlenecks. In long contexts, the usage of the Global KV Cache will dominate, and being persisted for prefix reuse, it will heavily occupy Host memory capacity and SSD capacity, and will also place high demands on the interconnect bandwidth for KVCache movement. These limit service throughput, increase deployment cost, and ultimately hinder the deployment and promotion of agents toward longer task spans and broader application scenarios. Therefore, further reducing the key-value cache footprint is crucial for alleviating storage and communication bottlenecks and reducing long-context serving costs. DeepSeek-V4.1-Flash is a multimodal mixture-of-experts model designed for more aggressive KVCache compression. DeepSeek-V4.1-Flash has a parameter scale of 552B, natively supports multimodal input, and supports contexts of up to 1 million tokens. It adopts a Causal Encoder-Decoder (CED) architecture, in which the Decoder's Global KVCache is obtained by projecting the Encoder's final hidden states. This design makes the model activate 8B parameters per token during the Prefill stage and 16B parameters during the Decoding stage, which is especially cost-effective for input-dominated Agent scenarios . Although DeepSeek-V4.1-Flash is significantly larger than DeepSeek-V4-Flash, at the same sequence length, its required runtime KVCache storage is only about 1/4 of the latter, and its persistent KVCache storage is only about 1/8 of the latter. In addition, the overall performance of DeepSeek-V4.1-Flash is superior to DeepSeek-V4-Flash. These compressions for KVCache mainly come from the joint optimization of model architecture, cache precision, and deployment strategy. For DSv4, it is a model with SWA as the backbone and enhanced by global compressed attention (CSA/HCA). Based on this perspective, the DeepSeek team carried out a series of optimizations. First, it is worth noting that they abandoned the block-based high-compression-ratio structure like HCA, and instead carried out more optimizations on CSA, forming CSA2. The main optimizations compress the KV Cache from three dimensions: In the channel dimension, a 512-dimensional latent vector is used to share the representation of the keys and values required by each attention head; In the sequence dimension, the Encoder merges 2 adjacent positions into 1 cache entry through channel-wise learned weights, while the Decoder retains per-position entries; In the layer dimension, multiple layers share the same global KV, and the whole network retains only 3 copies of Encoder cache and 1 copy of Decoder cache. Combined with FP4 quantization, the storage growth of the global main KV and the Indexer is about 890 bytes per token. 1.2 Overview of model architecture The overall model architecture is as follows: The paper reports that the backbone parameters are about , the Engram parameters are about , and the activated parameters per token for prefill and decode are about and respectively. The core is to use CED to reduce long-context Prefill computation, use CSA2 to reduce attention and KV cache overhead, and then combine Engram conditional memory with DSpark speculative decoding. The model has layers in total, hidden dimension , and vocabulary size . Each layer contains attention and MoE, organized through mHC residual connections. The entire attention mechanism is divided into two modules, Encoder and Decoder, forming a Causal Encoder-Decoder (CED) architecture. The key of CED is that the Decoder's global KV comes from the Encoder's end representation , and subsequent Decoder layers share these KVs. Therefore, most positions of a long prompt only need to pass through the first 20 layers, The key CSA2 among them adopts a mechanism of local sliding window + global sparse retrieval + cross-layer KVCache reuse . The sliding window size is 128, attention uses Q heads, sharing a -dimensional KV latent, of which RoPE is -dimensional and NoPE is -dimensional. Q uses a low-rank projection of rank , and the output projection is divided into groups, each of rank . (125 points, 10 comments on Hacker News)

由 claude-code/sonnet 自動生成