---
title: "Serving DeepSeek-V4: why million-token context is an inference systems problem"
description: "DeepSeek-V4's 1M-token context comes from compressing the token axis of the KV cache: Compressed Sparse Attention (stride 4, top-k selection), Heavily Compressed Attention (stride 128, dense over ~8K entries) and a 128-token Sliding Window Attention path."
url: "https://swe.quest/articles/serving-deepseek-v4-why-million-token-context-is-an-inference-systems-problem-bfb1067f4f733f69"
canonical: "https://www.together.ai/blog/serving-deepseek-v4-why-million-token-context-is-an-inference-systems-problem"
source: "Together AI"
published: "2026-05-11"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 11
tags: ["inference","llms","caching","performance","hardware"]
---

# Serving DeepSeek-V4: why million-token context is an inference systems problem

A post on [Together AI](https://swe.quest/sources/together.md), published 2026-05-11, 11 min read, Deep dive. Original: [https://www.together.ai/blog/serving-deepseek-v4-why-million-token-context-is-an-inference-systems-problem](https://www.together.ai/blog/serving-deepseek-v4-why-million-token-context-is-an-inference-systems-problem)

## Summary

DeepSeek-V4's 1M-token context comes from compressing the token axis of the KV cache: Compressed Sparse Attention (stride 4, top-k selection), Heavily Compressed Attention (stride 128, dense over ~8K entries) and a 128-token Sliding Window Attention path. The model leaves the serving engine to juggle multiple cache layouts with different sizes and lifetimes. In Together's bring-up on NVIDIA HGX B200, SWA state handling dominated capacity, and keeping only SWA states likely to be reused raised per-node KV capacity from ~1.2M to ~3.7M tokens. Prefix caching becomes a per-cache-type storage policy (full SWA store, checkpoints, or recompute-on-hit). Gains appear first in long-context decode-heavy workloads, while short-context prefill depends on kernel maturity, so teams should benchmark in their own regime and use workload-specific endpoint profiles.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)

## Prerequisites

- transformer attention
- KV cache ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- LLM prefill and decode ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- prefix caching ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))

## Keywords

DeepSeek-V4, Compressed Sparse Attention, Heavily Compressed Attention, Sliding Window Attention, NVIDIA HGX B200, MXFP4, Multi-Head Latent Attention, Together AI

## Related posts

- [DeepSeek-V4: a million-token context that agents can actually use](https://swe.quest/articles/deepseek-v4-a-million-token-context-that-agents-can-actually-use-4aebeb5a933f7a88.md): Hugging Face · 2026-04-24 · Hard · 7 min read · LLMs, Inference & serving, AI agents, Model training
  DeepSeek-V4 (Pro: 1.6T total/49B active; Flash: 284B/13B active) is a MoE model family whose 1M-token context is made practical by a hybrid attention design that interleaves Compressed Sparse Attention (4x KV compression plus an FP4 lightning indexer selecting top-k blocks) with Heavily Compressed Attention (128x compression with dense attention), plus FP8 KV storage.
- [Mastering Long Contexts in LLMs with KVPress](https://swe.quest/articles/mastering-long-contexts-in-llms-with-kvpress-778c6dc9287ed60d.md): Hugging Face · 2025-01-23 · Medium · 7 min read · Inference & serving, LLMs, Python, Performance engineering
  KV cache memory grows linearly with context length: Llama 3-70B at 1M tokens in bfloat16 needs about 330GB of KV cache, roughly 70% of total memory.
- [Unlocking Longer Generation with Key-Value Cache Quantization](https://swe.quest/articles/unlocking-longer-generation-with-key-value-cache-quantization-c7f36c464d98f5fa.md): Hugging Face · 2024-05-16 · Medium · 11 min read · Inference & serving, LLMs, Python
  Hugging Face Transformers adds KV cache quantization, inspired by the KIVI paper, that stores keys and values per-token in int2/int4/int8 via quanto or HQQ backends.
- [Cache-aware prefill–decode disaggregation (CPD) for up to 40% faster long-context LLM serving](https://swe.quest/articles/cache-aware-prefill-decode-disaggregation-cpd-for-up-to-40-faster-long-context-7f727a0ea889f194.md): Together AI · 2026-03-04 · Hard · 9 min read · Inference & serving, Caching, LLMs, Performance engineering, Scheduling
  Cache-aware prefill–decode disaggregation (CPD) extends standard PD serving with a dedicated pre-prefill tier for low-reuse (cold) long prompts, a router that estimates prefix-cache reuse per request, and a three-level KV cache hierarchy (GPU memory, host DRAM, RDMA-connected distributed cache).
- [How Specializing the Vocabulary of SLMs Can Cut Inference Cost by 77% in Real Applications](https://swe.quest/articles/how-specializing-the-vocabulary-of-slms-can-cut-inference-cost-by-77-in-real-c0f4e920b37cfe6d.md): Hugging Face · 2026-10-21 · Hard · 11 min read · Inference & serving, LLMs, Cost optimization, Model training
  VocabX rebuilds a fine-tuned small model's tokenizer by choosing tokens for the cost they save rather than how often they appear.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
