GitHub - deepseek-ai/DeepInfer: DeepInfer: High-performance, large-scale inference framework for DeepSeek models
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_DECODE parameter (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 DEEPINFERYOCOPREFILLTRUNCATIONMODE=compactDEEPINFER_YOCO_PREFILL_TRUNCATION_MODE=compact and a user-defined token retention buffer (DEEPINFER_YOCO_PREFILL_KEEP_TOKENS), which must account for the sliding window attention (SWA) and backtracking length.
  • 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 (DEEPINFERBATCHINVARIANT=1DEEPINFER_BATCH_INVARIANT=1), 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 DEEPINFERBATCHINVARIANT=1DEEPINFER_BATCH_INVARIANT=1 and DEEPINFERENABLEMTPVARLEN=0DEEPINFER_ENABLE_MTP_VARLEN=0 while providing a fixed seq_seed to SamplingParams, 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_args in the SamplingParams.

System Requirements and Integration

DeepInfer is built for large-scale deployment, though it assumes the availability of an external KV cache system and disaggregated VE/Prefill/Decode infrastructure. It requires Python 3.12 and specific hardware toolkits: CUDA 13 for NVIDIA environments or CANN 9.2 for Ascend environments. The framework is licensed under the Apache License 2.0 and serves as a highly optimized, production-grade alternative to standard inference engines, drawing conceptual inspiration from vLLM, SGLang, and TensorRT-LLM.