Skip to main content
DeepSeek is a series of advanced reasoning-optimized models featuring Multi-head Latent Attention (MLA) and Mixture-of-Experts (MoE) architectures. SGLang provides extensive optimizations specifically designed for DeepSeek models.
SGLang is the official recommended inference engine by the DeepSeek team for DeepSeek-V3/R1.

Overview

Supported DeepSeek Models

  • DeepSeek R1 (0528, 0730) - Latest reasoning models with RL
  • DeepSeek V3.1/V3 - 671B MoE (37B active) with MLA
  • DeepSeek V2 - Previous generation MLA+MoE
  • DeepSeek-VL2 - Vision-language model
  • DeepSeek-OCR / OCR-2 - Document understanding
  • DeepSeek-Janus-Pro - Image understanding & generation

Key Features

  • Multi-head Latent Attention (MLA): Compressed KV cache for efficiency
  • Mixture-of-Experts (MoE): 671B total, 37B active parameters
  • FP8 Native: Official models already in FP8 format
  • Advanced Reasoning: Trained with reinforcement learning

Quick Start

Single Node (8×H200)

Multi-Node Example (2×8 H100)

Hardware Requirements

Recommended configurations for DeepSeek V3/R1:
The official DeepSeek V3/R1 models are already in FP8 format. Do NOT use --quantization fp8 when loading them.

SGLang Optimizations for DeepSeek

SGLang provides several model-specific optimizations:

1. Multi-head Latent Attention (MLA)

Description: MLA compresses KV cache for improved efficiency. SGLang implements:
  • Weight Absorption: Reordered computation for balanced memory access
  • Multiple MLA Backends: FlashAttention3, Flashinfer, FlashMLA, CutlassMLA, TRTLLM MLA (Blackwell), Triton
  • FP8 Quantization: W8A8 FP8 and KV Cache FP8
  • CUDA Graph & Torch.compile: Reduced latency for small batches
  • Chunked Prefix Cache: Long sequence optimization (FlashAttention3 only)
Achieved up to 7× acceleration in output throughput. Usage: MLA optimization is enabled by default.

2. Data Parallelism Attention (DP Attention)

Description: Reduces KV cache size by distributing attention across DP workers, enabling larger batch sizes. KV cache is stored per DP rank instead of duplicating across all TP ranks. Performance: Up to 1.9× throughput improvement in high batch size scenarios. Usage:
DP attention is optimized for high-throughput scenarios with large batch sizes. Not recommended for low-latency, small-batch use cases.

3. Block-wise FP8 Quantization

Description: Optimized FP8 quantization with:
  • Activation: E4M3 format with per-token-per-128-channel sub-vector scales
  • Weight: Per-128×128-block quantization for numerical stability
  • DeepGEMM: Kernel library optimized for FP8 matrix multiplications
Usage: Enabled by default on Hopper/Blackwell GPUs. To precompile DeepGEMM kernels (recommended, ~10 minutes):
To disable DeepGEMM:

4. Multi-token Prediction (MTP)

Description: EAGLE-based speculative decoding for DeepSeek models. Performance:
  • 1.8× speedup for batch size 1
  • 1.5× speedup for batch size 32
Usage:
Optional parameters (defaults shown):
For large batch sizes (>48), adjust:
Enable experimental overlap scheduler with SGLANG_ENABLE_SPEC_V2=1 for improved performance.

5. Multi-Node Tensor Parallelism

Deploy DeepSeek across multiple nodes for models that don’t fit in single-node memory. Examples:

Reasoning Content (DeepSeek R1 & V3.1)

DeepSeek R1 and V3.1 models can separate reasoning tokens from final answers.

Enable Reasoning Parser

Using Reasoning in Requests

Thinking Budget

Control reasoning token budget with custom logit processors:

Function Calling

Enable tool calling for DeepSeek models:

Example Request

Multimodal DeepSeek Models

DeepSeek-VL2

Vision-language model for image understanding:

DeepSeek-OCR / OCR-2

Document understanding and text extraction:
Example request:

DeepSeek-Janus-Pro

Image understanding & generation:

Platform-Specific Deployment

AMD GPUs (MI300X)

See: AMD GPU Guide

CPU (Xeon 6980P)

Ascend NPU (Atlas 800I A3)

See: Ascend NPU Guide

Quantization Options

INT8 Quantization

AWQ Quantization

W4A8 Quantization

Performance Tips

Download Weights First

Ensure weights are fully downloaded before starting:

Increase Timeout for Large Models

Parallel Weight Loading

Memory Optimization

Resources

Troubleshooting

NCCL Timeout During Loading

Increase distributed timeout:

Out of Memory

Reduce memory fraction:
Or use quantized models (INT8/AWQ/W4A8).

Slow First Request

Precompile DeepGEMM kernels: