Service
GitHub - deepseek-ai/DeepInfer: DeepInfer: High-performance, large-scale inference framework for DeepSeek models
deepseek-ai
2026.10.20
·GitHub·by Mineru#DeepSeek#Framework#GPU#Inference#LLM
Key Points
- 1DeepInfer is an open-source, high-performance inference framework designed to power DeepSeek's large-scale production services, currently supporting the DeepSeek-V4.1-Flash model.
- 2The framework features advanced optimizations including FlashMLA, MoE expert parallelism, and asynchronous scheduling to maximize throughput on NVIDIA SM100 GPUs and Huawei Ascend 950 NPUs.
- 3Users can leverage specialized capabilities such as batch-invariant inference, structured output generation, and confidence-scheduled verification to ensure deterministic and efficient model execution.
DeepInfer is a high-performance inference framework developed by DeepSeek-AI, designed to support the large-scale production requirements of the DeepSeek-V4.1-Flash model. The framework emphasizes performance, scalability, and deterministic behavior across heterogeneous hardware, specifically targeting NVIDIA SM100 GPUs and Huawei Ascend 950 NPUs.
Core Methodology and Technical Architecture
DeepInfer employs a modular, optimized architecture to minimize latency and maximize throughput through several key technical components:- Kernel Optimization: The framework leverages custom kernels, including FlashMLA (Multi-Head Latent Attention), DeepGEMM, DeepEP, and DeepSelect, alongside TileLang kernels. These are engineered to handle the specific memory and computational access patterns required by large MoE (Mixture-of-Experts) models.
- Asynchronous Scheduling: The framework implements a zero-overhead batch scheduler that overlaps CPU-side scheduling operations with device-side execution, ensuring the GPU or NPU remains saturated.
- Advanced Decoding and Verification:
- DSpark and Confidence-Scheduled Verification: To accelerate generation, the framework utilizes draft token verification. It schedules verification based on confidence estimates, controlled by the
DEEPINFER_USE_NEXTN_DECODEparameter (default length of 5). - Decoder SWA Bounded Replay: This technique optimizes prefill performance by replaying only a bounded suffix of the decoder, effectively reducing computation. The configuration relies on and a user-defined token retention buffer (
DEEPINFER_YOCO_PREFILL_KEEP_TOKENS), which must account for the sliding window attention (SWA) and backtracking length.
- DSpark and Confidence-Scheduled Verification: To accelerate generation, the framework utilizes draft token verification. It schedules verification based on confidence estimates, controlled by the
- Parallelism Strategies: DeepInfer supports sophisticated parallelization, including Attention DP (Data Parallelism), balanced CP (Context Parallelism), and MoE EP (Expert Parallelism) coupled with EPLB (Expert Parallelism Load Balancing).
Operational Features
- Batch-Invariant Inference: When enabled (), the framework ensures that model results remain identical regardless of the batch composition, which is critical for consistency in production environments.
- Deterministic Sampling: By setting and while providing a fixed
seq_seedtoSamplingParams, the system produces identical outputs for identical inputs and parameters, ensuring reproducibility. - Structured Outputs: The framework natively supports constrained generation, allowing users to guide model outputs according to specific regex patterns, JSON schemas, or EBNF grammars passed via
so_argsin theSamplingParams.