How DeepSeek V4’s CSA+HCA Architecture Turns Million‑Token Context into a Cheap Feature

DeepSeek V4 introduces a hybrid CSA/HCA attention mechanism and a Mixture‑of‑Experts design that reduces inference cost to 27% of its predecessor, enables a 1‑million‑token context as a standard feature, and runs efficiently on both NVIDIA GPUs and Huawei Ascend NPU, dramatically lowering the barrier for Java developers to integrate large‑scale AI.

Architecture Digest
Architecture Digest
Architecture Digest
How DeepSeek V4’s CSA+HCA Architecture Turns Million‑Token Context into a Cheap Feature

Introduction

In mid‑July DeepSeek released V4, a model that does not merely iterate on V3.2 but reshapes the industry by making a million‑token context a default capability and cutting inference cost to 27% of the previous generation. The API supports OpenAI and Anthropic formats, and the official technical report lists both Huawei Ascend NPU and NVIDIA GPU as validated hardware.

1. The Quadratic Curse of Traditional Attention

Transformer self‑attention requires each token to compare with every other token, resulting in O(N²) computation. For 10 000 tokens this means 10⁸ operations, 100 000 tokens require 10¹⁰ operations, and 1 000 000 tokens explode to 10¹² operations, quickly exhausting GPU memory. Consequently, long‑context capabilities have been premium features in models such as Claude (200 k tokens) and GPT‑4 (128 k tokens).

2. V4’s Solution: Dual‑Lens Attention (CSA + HCA)

The core innovation is a hybrid of Compressed Sparse Attention (CSA) and Heavy Compression Attention (HCA). HCA acts as a “wide‑angle lens” with a 128:1 compression ratio, reducing one million tokens to fewer than 8 000 representative tokens to capture global context. CSA provides a “macro‑telephoto lens” with a 4:1 compression, preserving fine‑grained details within the HCA‑selected region.

Performance numbers (measured, not theoretical) show:

Single‑token inference compute: V3.2 baseline 100%, V4‑Pro 27%, V4‑Flash 10%.

KV‑cache memory usage: V3.2 baseline 100%, V4‑Pro 10%, V4‑Flash 7%.

Maximum context length: V3.2 64 k, V4‑Pro 1 M, V4‑Flash 1 M.

The 27% figure indicates that V4‑Pro processes one million tokens with less computation than V3.2 processes 64 k tokens.

3. MoE Architecture: 1.6 Trillion Parameters on Demand

V4‑Pro’s total parameter count is 1.6 trillion, but only 490 billion are activated per inference thanks to a Mixture‑of‑Experts (MoE) design. Notable engineering details include:

Fine‑grained Expert Parallelism (EP) verified on both NVIDIA GPUs and Huawei Ascend 950 NPU, marking the first cross‑platform compatibility for a Chinese large model.

FP4 precision format, natively supported by Ascend 950, enabling tighter hardware‑model co‑design.

For Java developers, this means the model can run with substantially lower GPU memory—over 60% less than comparable dense models—making local deployment feasible.

4. Domestic Compute Adaptation

The report confirms that the fine‑grained EP scheme performs reliably on both GPU and NPU platforms, addressing historical concerns about stability and ecosystem compatibility of domestic chips. Successful trillion‑parameter training on Ascend clusters (e.g., Meituan’s “Longcat 2.0”) demonstrates that Chinese hardware now meets the accuracy and correctness requirements of frontier LLM training.

Pricing is also dramatically reduced: the Flash‑tier API costs 0.02 CNY per million tokens (cache‑hit), roughly 1/100 of GPT‑4o’s price.

5. Implications for Java Developers

Long‑context scenarios become practical: a full Spring Boot codebase (≈1 M tokens) can be fed to the model for analysis, refactoring, or documentation generation.

Zero‑cost integration: switching from GPT‑4 to DeepSeek V4 only requires changing the model identifier in existing OpenAI‑compatible client code; Java AI frameworks such as Spring AI and LangChain4j need no code changes.

Agentic coding: V4 achieves top performance among open‑source models on Agentic Coding benchmarks, enabling AI agents for code review, API documentation, and test case generation.

Conclusion

DeepSeek V4’s significance lies in three breakthroughs: million‑token context as a default, inference cost reduced to floor‑level pricing, and deep integration with domestic compute. Together they lower AI application development from a specialized team effort to something a single Java backend engineer can accomplish. Limitations remain—pure text modality and peak‑time price spikes—but the overall impact on the Java AI ecosystem is profound.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mixture of expertslarge language modelDeepSeek V4attention compressionCSAHCA
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.