DeepInfer: DeepSeek Opens the Engine That Serves Its Models
Weights Are Only Half the Recipe
Since V3, DeepSeek has published the weights of its models. Anyone can download them. But anyone who has tried to run them at scale knows the gap: having a model's weights is like having the recipe for a dish; serving it to thousands of customers per second, at DeepSeek's prices, takes a whole kitchen. That kitchen is the inference engine: the software that receives requests, groups them into batches, manages cache memory, spreads the model over dozens of chips and produces the tokens (the general role of this software is covered in Inference servers).
On October 20, 2026, DeepSeek opened its kitchen. DeepInfer, published on GitHub under the Apache 2.0 license, is described as "the high-performance inference framework that powers DeepSeek's large-scale production services". It comes with a second library, deepseek-recipe (MIT license), which translates between API formats and the model.
A Change of Mind
The release has a backstory. In April 2025, after its February "open source week" (which released FlashMLA, DeepEP, DeepGEMM, the EPLB load balancer and its 3FS file system), DeepSeek explained in a post why it would not publish its engine: it was an early fork of vLLM more than a year old, it was tightly coupled to internal infrastructure, and a small research team lacked the bandwidth to maintain a large open project. The promise was instead to contribute standalone pieces to existing projects (vLLM, SGLang).
Eighteen months later, the engine ships anyway, in a shape that answers those objections: one model (DeepSeek-V4.1-Flash, see its lesson), two chip families, and offline inference only, meaning a Python script that processes a batch of requests, with no web server in front. The README says it plainly: DeepInfer "was originally built primarily on vLLM", with ideas borrowed from SGLang and TensorRT-LLM.
What's in the Box
| Announced feature | What it does, in plain words | Learn more |
|---|---|---|
| Optimized kernels | The small programs that run the computations on the chip, hand-written for this model | Flash Attention |
| Attention DP, balanced CP, EP + EPLB | Spread a mixture-of-experts model over dozens of GPUs without any of them becoming the bottleneck | Advanced parallelism |
| DSpark and confidence-scheduled verification | Guess several tokens at once, and only have the ones likely to be accepted checked | Speculative decoding |
| Sliding-window bounded replay | When reading, recompute only the end of the text for the local-window layers | Sliding Window Attention |
| Asynchronous scheduling | Prepare the next batch while the chip computes the current one | Batching |
| Batch-invariant inference, deterministic sampling | The same question gets exactly the same answer, whatever the traffic | Deterministic inference |
| Structured outputs | Force the answer to match a regular expression, a JSON schema or a grammar | JSON mode |
Let's take these ideas one at a time.
Kernels: The Most "Home-Made" Part
A kernel is a small program that performs one specific operation on the chip: a matrix multiplication, an attention computation, a data exchange between GPUs. The same operation can run two or three times faster depending on how the kernel splits the work and uses memory. DeepInfer relies on the libraries DeepSeek has been publishing since 2025: FlashMLA (latent attention, see MLA), DeepGEMM (low-precision matrix multiplications), DeepEP (GPU-to-GPU exchanges for mixture-of-experts models), TileKernels and DeepSelect, plus kernels written in TileLang, a language for writing such programs without going down to the details of each chip. That last point matters for portability to Huawei chips.
Spreading a Mixture of Experts: Data-Parallel Attention, Expert-Parallel Experts
V4.1-Flash has 552 billion parameters spread over 384 experts per layer, only six of which work on any given token (the principle is in MoE principles). No single chip holds everything. The approach DeepSeek has described since V3 combines two splits:
- Data-parallel attention (Attention DP): each GPU has its own copy of the attention part and handles its own requests, like independent checkout lanes in a supermarket.
- Expert-parallel experts (MoE EP): the experts are distributed across GPUs, a few per chip. When a token needs expert 217, it is sent to the GPU that hosts it, then comes back. That "all-to-all" exchange is what DeepEP speeds up.
The trap is balance. Some experts are in much higher demand than others, depending on what users are asking about. The GPU hosting a popular expert drowns in tokens while the others wait, and everyone moves at the pace of the busiest one. EPLB (Expert Parallelism Load Balancer) fixes this by duplicating the most requested experts ("redundant experts") and placing the copies so as to even out the load, while trying to keep experts that often work together on the same server.
In its March 2025 overview of how it served V3 and R1, DeepSeek already described this layout: for prefill, units of 4 servers with experts spread over 32 GPUs; for decode, units of 18 servers with experts spread over 144 GPUs, each GPU handling only 2 routed experts. In both cases, 32 redundant experts are used for load balancing. The two phases run on different machines: that is prefill/decode disaggregation.
The README also mentions balanced context parallelism (balanced CP): a very long text is split across several GPUs to be read faster. "Balanced" points at a known difficulty: in causal attention, the end of a text costs more than the beginning (each token looks at everything before it), so equal-sized chunks would overload the last GPU. The README does not detail the method used.
DSpark: Guess, Then Only Check What's Worth Checking
Speculative decoding has a fast mechanism propose several tokens at once, then has the large model check them in a single pass. At DeepSeek, the proposals come from multi-token prediction heads built into the model.
DSpark, published by DeepSeek in July 2026, tackles two weaknesses. First, proposals made all at once degrade quickly: the fifth guessed token ignores what became of the first four. DSpark adds a small sequential module that accounts for these dependencies (hence "semi-autoregressive"). Second, verifying a long draft whose tail is unlikely to be accepted wastes compute, which is expensive when the server is full. A confidence head estimates, for each position, the probability that the draft "survives" up to that point, and the scheduler picks for each request how many tokens to verify, taking the engine's load into account. Deployed on DeepSeek-V4's service, the paper reports per-user generation speed 60 to 85% higher than the previous baseline (a single guessed token), at equal total throughput. Verification stays exact: the generated text follows the same distribution as without speculation.
DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive GenerationIn DeepInfer, it is an option: the maximum draft length defaults to 5 tokens.
Bounded Replay: A Setting That Only Exists for This Model
V4.1-Flash is a causal encoder-decoder: the decoder gets its global keys and values from the encoder, but each layer also keeps a small sliding-window attention of 128 tokens computed locally. Recomputing it over a million-token text would cancel part of the savings. So the engine replays only the end of the text: 140 tokens by default, enough to cover the window plus a margin for the backtracking the engine may need (the README speaks of a "maximum backtracking length" without going into detail). It is the clearest example of a general point: the model's architecture and the engine are designed together, and some savings promised by the technical report only exist if the engine knows how to exploit them.
Asynchronous Scheduling: Never Let the Chip Wait
At every generation step, the central processor (CPU) decides which requests go into the batch, prepares the data, then launches the computation on the GPU. Done naively, the GPU sits idle while the CPU thinks. With steps lasting a few milliseconds, that idle time adds up. DeepInfer prepares the next step while the chip computes the current one (an idea popularized by SGLang as its "zero-overhead" scheduler). It is on by default.
Batch Invariance: The Same Answer, Whatever the Traffic
Even at temperature zero, a model served in production does not always give the same answer to the same question: the computations change subtly depending on how many requests are processed together, hence on other users' traffic. DeepInfer offers a batch-invariant mode and deterministic sampling (same input, same settings, same seed, same output), at some cost in speed and with variable-length speculative decoding turned off. Both work on NVIDIA GPUs only in this release. The phenomenon and its fix are explained in Deterministic inference.
What's Missing: An Engine, Not a Service
The README is candid about what it leaves out. A complete service would still need:
- a KV cache system (storing and retrieving the caches of conversations already read, in memory or on disk, see KV Cache);
- separation of the stages (vision encoder, prefill and decode) onto different machines ("most required engine functionality is already implemented");
- load balancing across model replicas, for both prefill and decode.
Then come the scope limits: one model, no HTTP server, and two chip families. On the NVIDIA side, SM100 chips, i.e. the Blackwell generation (B200, GB200). On the Huawei side, the Ascend 950, with the CANN software stack. The published performance curves were measured on NVIDIA only: 4 GPUs for prefill and 64 for decode, each time within a single "scale-up domain" (a group of chips joined by fast links, such as an NVL72 rack). No figures are given for Ascend.
In practice, DeepInfer replaces neither vLLM nor SGLang for anyone serving several models. It is a reference: a demonstration of what an engine tailored to one model achieves, and a goldmine for those who want to port these optimizations elsewhere.
deepseek-recipe: Translating Between the API and the Model
A model never sees a "message" or a "tool call": it sees a single sequence of tokens, with special markers flagging turns, reasoning and tools. Turning a conversation into that sequence means applying the model's chat template (see Instruction tuning). The reverse path reads the raw output back to extract reasoning, answer and tool calls.
deepseek-recipe (Rust, with a Python interface) handles both translations for DeepSeek V4 and V4.1, starting from the three major API formats on the market: Chat Completions and Responses (popularized by OpenAI) and Messages (Anthropic's). It also sets defaults that say a lot about the era: an output limit of 8,192 tokens without reasoning, 65,536 in thinking mode, and 131,072 in thinking mode at maximum effort. This split (engine on one side, protocol translation on the other) shows how a service is assembled: the engine only knows tokens, everything else is a separate layer.
Why It Matters
A model's cost is decided as much in the engine as in the weights. Bounded replay shows it: DeepSeek designs architecture and engine together. Some commentators see this as the main explanation for DeepSeek's prices; that is an interpretation, but it is consistent with what the code shows.
Huawei becomes a first-class target. An official engine that treats the Ascend 950 on a par with Blackwell, on release day, is a strong signal for the Chinese chip ecosystem. But the determinism features and the published measurements remain NVIDIA-only, which suggests the gap is not fully closed.
Infrastructure building blocks become course material. Expert load balancing, confidence-scheduled speculation, batch invariance: these ideas used to belong to infrastructure teams. Now they sit in a public repository, documented, and switched on by an environment variable.
DeepSeek-AI, DeepInfer: High-performance, large-scale inference framework for DeepSeek models, GitHub, October 20, 2026 (github.com/deepseek-ai/DeepInfer), and the deepseek-recipe library (github.com/deepseek-ai/deepseek-recipe). DeepSeek, The Path to Open-Sourcing the DeepSeek Inference Engine, April 2025, and DeepSeek-V3/R1 Inference System Overview, March 2025 (open-infra-index repository). The technical report of the model being served:
DeepSeek-V4.1-Flash: Pushing the Limits of KV Cache CompressionKey takeaways
- DeepInfer is DeepSeek's production engine, released October 20, 2026 under Apache 2.0, derived from vLLM, limited to DeepSeek-V4.1-Flash, offline inference only, on NVIDIA Blackwell and Huawei Ascend 950.
- It bundles techniques that used to be internal: data-parallel attention and experts spread across GPUs with duplication of popular experts (EPLB), DSpark speculation, bounded replay, asynchronous scheduling, batch invariance, structured outputs.
- It is not a complete service: the KV cache system, prefill/decode separation and load balancing across model replicas are missing.
- Model and engine are designed together: some of V4.1-Flash's savings, such as bounded replay, only exist because the engine knows how to exploit them.
- A reference more than a competitor to vLLM or SGLang, and a signal for Huawei chips, which still lag on determinism and published measurements.
1. In April 2025, DeepSeek explained why it would not publish its inference engine. How does the October 2026 release answer those objections?
2. What is EPLB (Expert Parallelism Load Balancer) for, when a model's experts are spread across dozens of GPUs?
3. What is the idea behind DSpark's 'confidence-scheduled' verification?
4. Why does 'bounded replay' illustrate the link between model architecture and inference engine?