DeepInfer: 155 Trillion Tokens a Day, $38 a GPU-Hour, and a KV Cache on the Filesystem — aniketkarneai.com | aniketkarneai.com
Wednesday, November 11, 2026 Field notes on autonomous systems ● Amsterdam, NL
daily

DeepInfer: 155 Trillion Tokens a Day, $38 a GPU-Hour, and a KV Cache on the Filesystem

DeepSeek open-sourced DeepInfer, the inference framework behind 155 trillion tokens a day of production traffic, under Apache-2.0. The interesting part is not the kernels — it's that the block KV cache lives on an erasure-coded distributed filesystem, and that batch-invariant inference is a runtime flag.

I went looking for the numbers in DeepInfer’s doc/inference_deployment_qa.md first, then went back to the charts to check them. That order was backwards, but it took me a while to notice.

The file is 28 KB of deployment Q&A that DeepInfer ships alongside the engine, and it’s the densest primary source any inference repo has published this year. Every answer has real measured values in it — moe_lb = 1.090 at EP64, state_size_to_disk = 1,415,040 bytes per sequence, a TTL comparison that costs chatbot traffic 0.5%–1% of its hit rate. It’s the kind of document that makes an engineering post easy to write and a review of the system hard, because you can’t summarize it without flattening it.

So I read the charts. doc/images/wide_ep_decode_pareto.png is two curves — EP64DP64 with 384+64 experts, EP8DP8 with 384+32 — plotting output throughput per GPU against per-user speed, both at context 131,072 with nextn=3 fixed and 75% per-token acceptance. The point labels are decode_num_requests, requests per DP rank.

Reading the blue curve left to right from the high-concurrency end: 256 requests per rank lands at roughly 26,300 tokens/s/GPU with users still getting ~106 tokens/s each. Drop to 128 requests and throughput falls to ~22,700 while per-user speed rises to ~178. At 64 it’s ~15,700 and ~247. At 32, ~9,500 and ~298. At 16, ~5,050 and ~312. At 8 requests per rank — eight users on the entire rank — ~2,600 tokens/s/GPU and ~325 tokens/s/user.

The orange EP8 curve tracks below it and the gap narrows as you go right. At 8 requests per rank it’s around 228 tokens/s/user against EP64’s 325. That’s the number I kept looking at: a 42% per-user-speed difference between a 64-GPU expert-parallel decode instance and an 8-GPU one, at the low-concurrency end of the curve.

That’s the chart. The rest of the post is what I found trying to explain where the 42% comes from.

What DeepInfer actually is

DeepSeek pushed the repository on 2026-10-16. Four days later it had 9,447 stars and 819 forks, Apache-2.0, primary language Python with a csrc/ tree in C++. The repo description is flat — “High-performance, large-scale inference framework for DeepSeek models” — and the README is 4.6 KB.

The numbers that matter are in doc/inference_deployment_qa.md, in the preamble: a single cluster currently serves 155 trillion tokens per day, with overall revenue of US$38 per GPU-hour at valley pricing.

Nine thousand stars in four days is the boring part. Somebody published a vendor’s production serving stack, the documentation for the cluster it runs on, the measured load-balancer imbalance, and the honest statement of what’s missing — in the same commit. The $38 figure is the one I keep coming back to, and I’ll get to why.

Supported hardware is two lines: NVIDIA SM100 GPUs and Huawei Ascend 950 NPUs. Prerequisites are Linux, GCC 13 or newer, Python 3.12, and either CUDA 13 or CANN 9.2. Acknowledgments credit vLLM as the original base with SGLang and TensorRT-LLM as inspiration, which is the ordinary disclosure and matches what the code structure suggests.

Only one model is supported: DeepSeek-V4.1-Flash, defaulting to the deepseek-ai/DeepSeek-V4.1-Flash-1017 checkpoint on Hugging Face.

The three goals, and what they rule out

The Q&A opens with three design goals, and they’re worth reading as constraints rather than aspirations:

  1. Support accelerators from multiple vendors — NVIDIA and Ascend, each used to its own characteristics.
  2. Organize prefill and decode around commodity hardware — “ordinary 8-GPU machines for prefill, ordinary 64–128-GPU supernodes for decode.”
  3. Retain KV cache for more than 72 hours.

Goal 2 is what produces the asymmetry everyone copying this stack will inherit. Prefill runs EP2–8 / DP2–8, “use the smallest EP/DP that HBM allows.” Decode runs EP64–128 / DP64–128, “use the largest EP/DP that the available GPUs allow.” TP and CP are not used at all. Wide-EP cuts per-step memory traffic in the MoE expert part, and with working EPLB it raises TPS — that’s the chart above.

The unit of deployment is where that bites. The document says 1P + 1D is deployable, then immediately says the smallest efficient deployment unit is 64 GPUs of prefill plus 64 of decode. Both statements are in the same answer. That’s not a contradiction, it’s a warning: the configuration that technically boots and the configuration that makes economic sense differ by two orders of magnitude in hardware.

The KV cache lives on a filesystem

This is the decision I don’t remember seeing anyone else make.

Most serving stacks keep prefix cache in local host RAM, sometimes tiered to a faster-but-smaller tier. DeepInfer puts the paged block KV cache on a dedicated 3FS storage cluster. Not a tier. A dedicated cluster, with its own nodes, autoscaled separately from compute.

The reasoning is given directly: a dedicated storage cluster “lets every prefill machine hit any prefix, avoiding a conflict between prefix affinity and the load-balancing routing policy.” That’s the whole argument. A local prefix cache creates an affinity constraint — this prefix belongs to this engine — and affinity fights load balancing, because the load balancer wants to send work where the capacity is and the cache wants work to come back where the data is. Moving the KV to a shared cluster dissolves the conflict.

The cluster numbers:

  • 20 × 30.73 TB SSDs per storage server, at least 40 GB/s read and 5 GB/s write per server
  • About 14.4 TB of logical KV cache per GPU, physical capacity higher
  • 3FS with 10+2 erasure coding — a read issues to all 11 nodes, any 10 responses decode
  • Roughly 100 PiB of SSD provisioned for KV cache
  • 400 Gbps of interconnect budget per 8 GPUs

Fault tolerance comes from the filesystem, not the compute nodes. The document notes compute nodes fail at more than an order of magnitude higher rate than storage nodes, and 10+2 EC tolerates two simultaneous node failures. A GC Worker per storage node evicts expired cache under LRU against a watermark.

TTL is 3 days for agent traffic and 7 days for chatbot traffic, chosen empirically — chatbot traffic has a much heavier long-tail of hits, so a small amount of KV read very many times, and losing it costs more overall. A 3-day TTL costs chatbot traffic 0.5%–1% of its hit rate.

The retrieval path has an honest limitation in it: matching is a hash-chain prefix match over metadata only, done by the Entrypoint against the local kvcache-store in CHECK role, but the hit length has to be computed before routing, so that part cannot be hidden. KV fetching is asynchronous in a separate process. Swap-in from shared memory to HBM runs in a thread inside the engine, overlapping per-layer host-to-device transfers with forward computation — and because the CUDA copy engine does badly on the fine-grained copies that KV blocks need, swap-in is implemented over GDR so an RDMA NIC saturates PCIe without consuming SMs.

The SWA KV cache is the exception. It doesn’t enter the persistent cache at all — it stays in the memory of the machine that produced it, tracked by an in-memory directory partitioned by key across the Entrypoint machines, with cross-machine hits pulled over a 400G VLAN. Per sequence only 20 layers × 134 tokens × 528 B = 1,415,040 B goes to the store, in an MXFP8 SWA KV format, and for V4.1 the stored layers are the first 20.

The 128-token constant

SWA bounded replay is the mechanism that makes that SWA cache survivable.

Replaying from position s, the query at position i is computed only against keys in the range max(s, i − 127) to i. That yields an approximate SWA KV cache. The property that matters: the cost of recomputation is constant, independent of context length and layer count. Not proportional — constant.

The hit policy is a two-step fallback. The block KV cache decides the hit length L1 (a multiple of the 128-token block size). Then the SWA KV cache is queried over the range L1 − 128 to L1. If a SWA entry exists there, the hit length is L1. Otherwise it’s L1 − 128 and you recompute. Under the YOCO truncation requirement the maximum hit length for an input of length L is at most L − 134 — 128 for the window plus 6 tokens of speculative backtracking.

Used in two places. In the encoder path, when the SWA cache misses, the last 128 tokens of the hit prefix are recomputed together with the non-cached suffix, rebuilding only the SWA KV while the block KV is reused as-is. In the decoder path it does something larger: prefill computation happens only in the encoder layers, because in the CED architecture the decoder layers’ block KV cache is projected from the last encoder layer’s hidden state. Reconstructing the decoder SWA KV exactly would require pushing the last 2,560 tokens through 20 decoder layers. Instead it recomputes 128 — and “nearly halves total prefill computation.”

Halving prefill by throwing away 96% of the context you might have needed is a bet on the approximation. It works because SWA means the attention window was already bounded; replaying a bounded window from a bounded suffix reproduces a bounded window. That reasoning doesn’t transfer to a full-attention model, and the document doesn’t pretend it does — it’s specific to SWA plus YOCO.

Four load balancers, one of which is an afterthought

DeepSeek built four separate load balancers — Prefill, Decode, Vision Encoder, Expert-Parallel. The Prefill one is the most interesting because of how the chunk size is chosen.

Requests are bucketed by total context length into four tiers: under 16K, 16–64K, 64–256K, and 256K and above. The number of engines assigned to each tier is redistributed dynamically by that tier’s share of compute-quota demand in the previous round, with a per-batch compute-quota cap per tier.

Within a single GPU, requests dequeue FIFO and the chunk size is solved, not fixed. Each prefill step gets a time budget — compute_quota_limit, in nanoseconds — and a fitted quadratic cost model cost(q, c) predicts step duration, where q is the number of sequence tokens and c is the prefix length already computed for that sequence. The scheduler solves that quadratic for q, taking the largest q that stays inside the 32,768-token budget while exactly consuming the remaining time budget. The budget itself gets reduced by an all-reduce MIN across the DP group.

That’s the mechanism behind the 42%. You don’t get it from a better GEMM; you get it from never making a GPU wait for work that doesn’t fit the time it has.

EPLB works the same way in both stages — each GPU holds redundant replicas of hot experts, expert load over the last N steps is collected, and every M steps experts are reassigned, shuffling weights within the group over NVLink symm_mem. Prefill starts from 4 redundant experts per GPU, a 100-step window, reassignment every 1,000 steps: moe_lb of 1.074 at EP4DP4 and 1.045 at EP2DP2. Decode starts from 1 redundant expert per GPU, a 1,000-step window, reassignment every 10,000 steps: moe_lb of 1.090.

moe_lb is slowest rank over mean. 1.090 means the worst-scheduled GPU in a 64-way expert-parallel decode instance runs 9% slower than the average one, so every step is gated by that straggler. Overall the system reaches roughly 80% of a perfectly balanced offline benchmark.

The Decode Load Balancer balances two dimensions at once — request count, which sets per-step batch size, and total KV cache length, which sets the cost of the attention part. Short requests go to GPUs with low concurrency but large total KV; long requests go to GPUs with small total KV. Fine, until you read the next one: the Vision Encoder Load Balancer routes images at machine granularity, picks a machine hosting one vision encoder per GPU at random, then hands the image to whichever GPU is processing the fewest image patches, computed directly as (width/patch_size) × (height/patch_size). One sentence. The Decode balancer gets a paragraph and credits DualPath’s intra-group scheduling algorithm. That’s a decent tell about where the traffic is.

DSpark, and the +5.4% that only shows up at production concurrency

Speculative decoding here is confidence-scheduled. Fixed-length verification wastes work because draft acceptance probability varies by request and position, so DSpark predicts each draft token’s acceptance rate with a Confidence Head and, at scheduling time, allocates verification compute to the highest marginal-return tokens. In production the draft model generates 5 tokens at a time, and the drafts get sorted by expected acceptance rate with a prefix subset selected for verification.

The measured table, from EP64/DP64 at ~60 concurrent sequences per rank:

conc (seqs/rank)fixed-5 verifieddynamic verifiedfixed-5 accepteddynamic acceptedfixed-5 tok/s/rankdynamic tok/s/rankgain
1654.443.323.2448914816−1.5%
3253.653.253.1789649111+1.6%
4853.943.33.261203212467+3.6%
6053.583.33.211373014466+5.4%
7253.243.293.121496215961+6.7%
9653.243.33.151681718660+11.0%

Dynamic-length verification cuts the draft tokens actually verified per step by about 30% — 5.00 down to 3.2–4.4 — while the average accepted length is essentially unchanged (3.29 vs 3.20). Accepted length not moving is the point: you’re spending less compute to arrive at the same place.

Read the first two rows. At 16 sequences per rank dynamic-length verification is a 1.5% loss. At 32 it’s break-even-ish. The gain only turns positive past that and only reaches the cited +4–7% at the production operating point. If you benchmark speculative decoding at low batch size, this optimization looks broken, and it isn’t — it’s operating at a concurrency where confidence estimates aren’t worth the sort.

The interaction with asynchronous scheduling is the part I found genuinely surprising. When schedule(N+1) runs, the confidence from step N hasn’t come back yet, so the CPU can only fix the total budget. Per-request draft lengths are recomputed on the GPU by a TileLang kernel — cumulative product, global sort for top-k, fused remap scatter — and written back to a pinned buffer. The scheduling decision the CPU normally makes gets redone on the device one step later, because the information it needs hasn’t been produced yet.

The flag nobody else ships

The README lists batch-invariant inference as a supported feature, enabled with DEEPINFER_BATCH_INVARIANT=1, and marks it NVIDIA only.

Batch-invariant means model results stay identical across different batch compositions. This matters more than it sounds: in most stacks, the same prompt sampled twice with a different set of neighbors in the batch can produce different logits, because the reduction order inside the kernels changes with the shape. Non-determinism there breaks anything you want to cache, replay, or debug — and it means your eval numbers move when your traffic does.

Deterministic sampling is a separate line with a stricter recipe: DEEPINFER_BATCH_INVARIANT=1 plus DEEPINFER_ENABLE_MTP_VARLEN=0, then a fixed seq_seed passed to SamplingParams. Speculative decoding has to be off, which makes sense — MTP verification depends on which tokens the draft produced, and you can’t hold the output fixed while letting the number of verified tokens float.

Also worth knowing: the engine reports being 5%–10% slower on the decoding kernel than DeepSeek’s internal FlashMLA, which has one hand-tuned SASS optimization the open version lacks. End-to-end that’s at most 5%.

What this is not

It’s not a serving system. The README is explicit that a complete inference service needs a KV cache system, VE/Prefill/Decode disaggregation (with the caveat that most required engine functionality is already implemented), and load balancing across data-parallel replicas for both stages. The KV cache management and load-balancing components are “tightly coupled to our internal infrastructure, so that code is not yet fully open-sourced” — which is also, not coincidentally, the part containing the 14.4 TB-per-GPU cluster design and the quadratic chunk-size solver.

So the filesystem architecture I spent the most time on is the part you get the description of and none of the code. Fine, mostly — the Q&A is detailed enough to reimplement against. But if your goal was to run this on hardware you control, the open artifact is the engine, and the cluster around it is a design document.

Three more limits, briefly. The 128-GPU minimum efficient deployment unit rules out most self-hosting regardless of what’s in the repo. Two of the most interesting flags are NVIDIA-gated and silently absent on Ascend, which sits awkwardly against the multi-vendor goal. And the Ascend 950 support is a claim, not a number — every benchmark in the repository is SM100, with prefill measured on 4 GPUs and decode on 64, each within one scale-up domain.

The autoscaling and fault-tolerance section is where the honest engineering shows up in a different direction. Restarts are on the order of minutes, and DeepSeek doesn’t try to make them fast — fault tolerance comes from PE/CE quota redundancy plus request-level rerouting. Scale-in is forbidden whenever quota utilization is above 0.8. A decode engine gets a one-minute grace period after a shutdown notice, then forwards any unfinished requests and their KV cache to other engines in one shot. For EP failover: all GPUs of an instance are one communication domain, so a single failed GPU makes the instance unusable — on restart the platform re-determines EP size from the healthy GPUs and the instance takes whatever count it actually gets. That’s a deployment where the design assumption is that hardware will fail constantly, and none of it is elegant. It works.

Where I’d want to look next

The thing I couldn’t resolve is what happens when the block KV cache path meets ordinary hardware. The whole design assumes a 3FS-class filesystem delivering 40 GB/s per storage server and 400 Gbps per 8 GPUs, provisioned at ~100 PiB. Whether the paged KV path degrades gracefully onto a single NVMe box with no dedicated storage cluster — or just falls off a cliff in throughput — isn’t in the Q&A, and it isn’t something I can test without a cluster.

deepseek-recipe went out alongside this — the Rust tokenizer/detokenizer and API-protocol layer, with Python bindings, handling Chat Completions / Responses / Messages conversion and a segmented parallel encoding path that skips special-token matching inside ordinary text. It has the same anti-injection design as the SWA cache: a literal <|User|> in user text encodes as ordinary tokens and cannot inject a control token. Worth its own look, and the reason I’d expect the two repos to end up with very different adoption curves despite shipping on the same day.

Links: DeepInfer · inference deployment Q&A · DeepSeek-V4.1-Flash model card · deepseek-recipe · DeepEP · FlashMLA · DeepGEMM · vLLM · SGLang

Aniket Karne
DevOps & AI Engineer · Amsterdam
Back to all posts
Reader correspondence

Comments

Powered by GitHub Discussions via Giscus. Sign in with GitHub to leave a comment.