TL;DR
在 DeepInfer 自有的基准测试中,表现持平或领先。在 4x GB300 和 4x B300 上预填充吞吐量最高提升 1.04 倍,在 64x GB300 上解码步骤缩短高达 7.4%,其余各项指标差距在 1% 以内。
DeepInfer 的优化措施已整合至 SGLang。DeepSeek 的内核(包括 Mega 系列)、DSpark 推测解码、SWA 有界重放以及两种 Engram 放置方式均在 SGLang 主分支中运行。
这是一个完整的服务系统。SGLang 是一个 API 服务器,它拥有 KV 缓存系统、预填充/解码分离功能以及在副本间负载均衡的能力,而 DeepInfer 的 README 中列出的这些功能在其发布版本中并未包含。
DeepSeek 开源了 DeepInfer(其自有服务背后的推理引擎)及其运行的内核。这为 DeepSeek-V4.1-Flash 的运行速度树立了标杆,因此我们使用 DeepInfer 自有的基准测试,在同一硬件上对 SGLang 进行了对比测量。
已整合的功能
自 V4.1 支持首日,SGLang 就已运行 SWA 有界重放和主机内存 Engram 表。此后,它又增加了 DeepSeek 的 Mega 内核、针对跨 GPU 分割的 Engram 表的直接对等读取,以及进一步的执行优化。
DeepSeek 的内核。SGLang 集成了 FlashMLA、DeepGEMM、DeepEP、DeepSelect 和 TileLang 内核,以及 Mega 系列:MegaAttention、MegaMoE、MegaGate 和 Mega-mHC。MegaMoE 将 token 分发、专家 GEMM 和合并操作融合为一个内核。MegaAttention 是 B300 和 GB300 上的默认注意力路径,适用于单机服务器以及预填充和解码服务器。
图 1:SGLang 中集成的内核。
并行计算。SGLang 对预填充和解码均使用 DP 注意力加上专家并行(DEP)。下方的基准测试在 64 块 GB300 GPU 上,预填充使用 DEP4,解码使用 DEP64。SGLang 还支持 EPLB 以平衡宽 EP 部署中的专家负载,详见我们的 MoE 负载均衡博客文章。
DSpark 推测解码。SGLang 运行检查点中的 DSpark 草稿模型,以提出一组 token,由目标模型共同验证,从而减少生成响应所需的目标模型前向传播次数。
SWA 有界重放。解码器重放仅在最后 128 个提示 token 上运行晚期解码器层,而早期的源层仍处理完整提示。在键值缓存命中时,编码器重放会从最后 128 个缓存的 token 中重建缺失的滑动窗口 KV。
图 2:SWA 有界重放:解码器重放和编码器重放。
Engram 放置。DeepInfer 允许您将 Engram 表保留在主机内存或设备内存中,SGLang 支持这两种方式。通过设置 SGLANG_ENABLE_DSV41_ENGRAM_HOST_TABLE=1,每个节点在主机内存中保存一份表的副本,从而为 KV 缓存留出最多的 HBM 空间。通过设置 SGLANG_OPT_DSV41_ENGRAM_PEER_SHARDS=1,表被分割到各 GPU 上,每块 GPU 直接通过 NVLink 从其对等节点读取所需的行,在查找过程中无需进行全收集或归约散射操作。
图 3:主机内存中的 Engram 表,或跨 GPU 分割并通过直接对等读取。
零开销调度。自 v0.4(2024 年 12 月)起,SGLang 的调度器在 GPU 运行步骤 N 的同时,在 CPU 上准备步骤 N+1,从而实现调度与 GPU 执行的并行重叠。DeepInfer 的文档将此设计归功于 SGLang。
图 4:零开销调度:CPU 准备下一步,同时 GPU 运行当前步。
DeepSeek 的聊天格式。提示词渲染和输出解析使用 DeepSeek 自己的 deepseek-recipe 包(#45315、#45907、#46219),因此 SGLang API 中的推理和工具调用遵循 DeepSeek 的格式。语法约束解码支持 JSON 模式、正则表达式和 EBNF。
结果
图 5:在 4x GB300 和 4x B300 上进行预填充,在 64x GB300(EP64)上进行解码。
测量值(实线)显示了我们运行的 SGLang 和 DeepInfer 基准测试。发布值(虚线)显示了 DeepInfer 最初发布的预填充和解码结果,数值从这些图表中读取。文本中的预填充比较使用了测量的 DeepInfer 曲线,取每个点处测试最快的配置。
附录中的设置。简而言之:
预填充,4x GB300。SGLang 的预填充吞吐量最高可达基准的 1.04 倍:在每 GPU 每步生成 4K、32K 和 64K 新 token 时领先,在 8K 和 16K 时持平。
预填充,4x B300。预填充吞吐量最高可达基准的 1.04 倍:在 4K、8K 和 32K 时领先,在 16K 和 64K 时持平。
解码,64x GB300 (EP64)。SGLang 的单步时间比基准短 1.1% 到 7.4%(每 GPU 请求数从 16 增加到 256),在 8 个请求时持平。
速度从何而来
Mega-mHC 直接喂给 MegaMoE,注意力机制产生用于输出投影的 MXFP8 输出,预填充压缩器和请求窗口 KV 副本使用融合内核。这些更改减少了中间内存流量和内核启动次数。
可中断的 CUDA 图覆盖每 GPU 多达 8K token 的预填充步骤,包括长上下文和数据并行注意力。解码重放使用与有界后缀大小相匹配的独立图,因此当大型预填充步骤的其余部分以急切模式运行时,这些层仍从 CUDA 图中重放。
SGLang 增加了什么
DeepInfer 的 README 列出了完整推理服务所需的三个组件,但其发布版并未包含这些。SGLang 提供了全部三个组件。
图 6:Linker 将本地 L1 GPU 缓存直接连接到共享 L3 存储。
KV 缓存系统。SGLang 的统一基数缓存跨请求和对话轮次重用 KV,包括针对此类混合模型。上述配置使用 Linker 将 L1 GPU 缓存直接连接到共享 L3 存储(如 3FS 或 Mooncake)。HiCache 还支持主机内存 L2 层级,供使用该层级的部署使用。
预填充/解码分离。SGLang 在单独的服务器上运行预填充和解码,并提供您选择的 KV 传输后端:Mooncake、NIXL 或 MORI。
跨副本的负载均衡。SGLang 的模型网关将请求分发到各个副本,并支持基于缓存前缀的路由。
在此基础上,SGLang 是一个 API 服务器,具备推理和工具调用解析功能,支持 NVIDIA GB300、B300、B200 和 H200 以及 AMD MI355X。
致谢
感谢 DeepSeek 开源 DeepInfer、FlashMLA、DeepGEMM 和 DeepEP,并如此详细地记录其推理系统。
附录:基准测试设置
两个引擎都在相同硬件上运行 DeepIner 自己的基准测试。SGLang 的预填充版本为 7d996300b9,解码版本为 3b95120f00;DeepInfer 的版本为 774ce24。两者的启动命令和基准测试客户端均在此 gist 中。若要实际部署模型服务,请参阅食谱页面;以下设置(如平衡专家路由)仅用于比较。
预填充
工作负载和机器。我们使用 DeepInfer 的预填充基准测试:每个请求具有 128K token 的上下文和 4K 新 token,每 GPU 每步预填充 B 个新 token,范围从 4K 到 64K。两个引擎均在相同的 4-GPU 节点上运行,权重相同,采用 DP4/EP4、平衡专家路由、关闭 EPLB 以及 32 个冗余专家。对于 DeepInfer,我们在每个点取其两种 Engram 放置方式(主机或 GPU 内存)中速度最快的一种,每种均使用其默认设置及 64K 设置。SGLang 将 Engram 表跨 GPU 拆分,均匀分布冗余专家,并启用了一些尚未默认开启的优化。
差异。DeepInfer 测量 GPU 0 上约 9 个批次的预填充耗时。我们的 SGLang 结果计算了每个 GPU 上所有完整批次的平均值,时间点位于 20% 到 90% 的请求完成之间。DeepInfer 在每个 GPU 的跨请求中重复使用相同的提示词,而 SGLang 对每个请求使用不同的新 token。
解码
工作负载和机器。我们在 64 块 GB300 GPU(16 个节点,DP64/EP64)上匹配 DeepInfer 的解码基准测试工作负载:具有共享缓存前缀的 128K token 上下文、每 GPU 固定数量的请求、每步 3 个草稿 token 以及静态验证(每个请求都验证完整的草稿块)、平衡专家路由,以及 384 个路由专家和 64 个冗余专家。图表将单步时间转换为每步接受 3.25 个 token 的速率。
差异。SGLang将Engram表保留在设备上,而DeepInfer则将其保存在主机内存中;此外,DeepInfer的草稿模型包含64个冗余专家,而SGLang的草稿模型则没有任何冗余专家。
TL;DR
On par or ahead on DeepInfer’s own benchmarks. Up to 1.04x prefill throughput on 4x GB300 and 4x B300, up to 7.4% shorter decode steps on 64x GB300, and within 1% at the remaining points.
DeepInfer’s optimizations, in SGLang. DeepSeek’s kernels including the Mega series, DSpark speculative decoding, SWA bounded replay and both Engram placements run in SGLang main.
A full serving system. SGLang is an API server, and it has the KV cache system, prefill/decode disaggregation and load balancing across replicas that DeepInfer’s README lists as not included in its release.
DeepSeek open-sourced DeepInfer, the inference engine behind its own service, together with the kernels it runs on. It sets the bar for how fast DeepSeek-V4.1-Flash can run, so we measured SGLang against it with DeepInfer’s own benchmarks on the same hardware.
What is integrated
SGLang has run SWA bounded replay and host-memory Engram tables since its first day of V4.1 support. Since then it has added DeepSeek’s Mega kernels, direct peer reads for Engram tables split across GPUs, and further execution optimizations.
DeepSeek’s kernels. SGLang integrates FlashMLA, DeepGEMM, DeepEP, DeepSelect and the TileLang kernels, together with the Mega series: MegaAttention, MegaMoE, MegaGate and Mega-mHC. MegaMoE fuses token dispatch, expert GEMMs and the combine into one kernel. MegaAttention is the default attention path on B300 and GB300, on single servers and on both prefill and decode servers.
Figure 1: Kernels integrated in SGLang.
Parallelism. SGLang uses DP attention plus expert parallelism (DEP) for both prefill and decode. The benchmarks below use DEP4 for prefill and DEP64 for decode across 64 GB300 GPUs. SGLang also supports EPLB to balance expert load in wide-EP deployments, as described in our MoE load-balancing blog .
DSpark speculative decoding. SGLang runs the checkpoint’s DSpark draft model to propose a block of tokens that the target model verifies together, reducing the number of target-model forward passes needed to generate a response.
SWA bounded replay. Decoder replay runs the late decoder layers on only the last 128 prompt tokens, while earlier source layers still process the full prompt. On a prefix-cache hit, encoder replay rebuilds missing sliding-window KV from the last 128 cached tokens.
Figure 2: SWA bounded replay: decoder replay and encoder replay.
Engram placement. DeepInfer lets you keep the Engram tables in host memory or in device memory, and SGLang supports both. With SGLANG_ENABLE_DSV41_ENGRAM_HOST_TABLE=1 , each node holds one copy of the tables in host memory, which leaves the most HBM for the KV cache. With SGLANG_OPT_DSV41_ENGRAM_PEER_SHARDS=1 , the tables are split across the GPUs, and each GPU reads the rows it needs straight from its peers over NVLink, with no all-gather or reduce-scatter around the lookup.
Figure 3: Engram tables in host memory, or split across GPUs with direct peer reads.
Zero-overhead scheduling. Since v0.4 (December 2024), SGLang’s scheduler prepares step N+1 on the CPU while the GPU runs step N, overlapping scheduling with GPU execution. DeepInfer’s documentation credits this design to SGLang.
Figure 4: Zero-overhead scheduling: the CPU prepares the next step while the GPU runs the current one.
DeepSeek’s chat format. Prompts are rendered and outputs parsed with DeepSeek’s own deepseek-recipe package ( #45315 , #45907 , #46219 ), so reasoning and tool calls in SGLang’s API follow DeepSeek’s format. Grammar-constrained decoding supports JSON schema, regex and EBNF.
Results
Figure 5: Prefill on 4x GB300 and 4x B300, decode on 64x GB300 (EP64).
Measured (solid lines) shows our benchmark runs of SGLang and DeepInfer. Published (dashed lines) shows DeepInfer’s originally published prefill and decode results, with values read from those figures. The prefill comparison in the text uses the measured DeepInfer curve, taking its fastest tested configuration at each point.
Setup in the appendix . The short version:
Prefill, 4x GB300. SGLang reaches up to 1.04x the prefill throughput: ahead at 4K, 32K and 64K new tokens per GPU per step, on par at 8K and 16K.
Prefill, 4x B300. Up to 1.04x the prefill throughput: ahead at 4K, 8K and 32K, on par at 16K and 64K.
Decode, 64x GB300 (EP64). SGLang’s step is 1.1% to 7.4% shorter from 16 to 256 requests per GPU, and on par at 8.
Where the speed comes from
Mega-mHC feeds MegaMoE directly, attention produces MXFP8 output for the output projection, and the prefill compressor and request-window KV copies use fused kernels. These changes reduce intermediate memory traffic and the number of kernel launches.
Breakable CUDA graphs cover prefill steps of up to 8K tokens per GPU, including long contexts and data-parallel attention. Decoder replay uses separate graphs sized to the bounded suffix, so those layers still replay from CUDA graphs when the rest of a large prefill step runs eagerly.
What SGLang adds
DeepInfer’s README lists three components a complete inference service needs that its release does not include. SGLang ships all three.
Figure 6: Linker connects local L1 GPU caches directly to shared L3 storage.
A KV cache system. SGLang’s unified radix cache reuses KV across requests and conversation turns, including for hybrid models like this one. The configuration shown above uses Linker to connect L1 GPU caches directly to shared L3 storage, such as 3FS or Mooncake. HiCache also supports a host-memory L2 tier for deployments that use it.
Prefill/decode disaggregation. SGLang runs prefill and decode on separate servers, with the KV transfer backend of your choice: Mooncake, NIXL or MORI.
Load balancing across replicas. SGLang’s model gateway distributes requests across replicas and supports routing based on cached prefixes.
On top of these, SGLang is an API server, with reasoning and tool-call parsing, on NVIDIA GB300, B300, B200 and H200 and AMD MI355X.
Acknowledgments
Thanks to DeepSeek for open-sourcing DeepInfer, FlashMLA, DeepGEMM and DeepEP, and for documenting their inference system in such detail.
Appendix: benchmark setup
Both engines run DeepInfer’s own benchmarks on the same hardware. SGLang is at 7d996300b9 for prefill and 3b95120f00 for decode, DeepInfer at 774ce24 . The launch commands and benchmark clients for both are in this gist . To serve the model for real, follow the cookbook page ; the settings below, such as balanced expert routing, exist for the comparison only.
Prefill
Workload and machines. We use DeepInfer’s prefill benchmark: every request has a 128K-token context with 4K new tokens, and each GPU prefills B new tokens per step, from 4K to 64K. Both engines run on the same 4-GPU node with the same weights, DP4/EP4, balanced expert routing, EPLB off, and 32 redundant experts. For DeepInfer we take, at each point, the fastest of its two Engram placements (host or GPU memory), each with its defaults and with its 64K settings. SGLang splits the Engram tables across GPUs, spreads the redundant experts evenly, and enables a few optimizations that are not on by default yet.
Differences. DeepInfer measures how long prefill takes for about 9 batches on GPU 0. Our SGLang results average every complete batch on every GPU between the points where 20% and 90% of the requests have finished. DeepInfer repeats the same prompt across requests on each GPU, while SGLang uses different new tokens per request.
Decode
Workload and machines. We match DeepInfer’s decode benchmark workload on 64 GB300 GPUs (16 nodes, DP64/EP64): 128K-token contexts with a shared cached prefix, a fixed number of requests per GPU, 3 draft tokens per step with static verification (the full drafted block is verified for every request), balanced expert routing, and 384 routed plus 64 redundant experts. The chart converts step time to tokens at 3.25 accepted per step.
Differences. SGLang keeps the Engram tables on device and DeepInfer in host memory, and DeepInfer’s draft model carries 64 redundant experts while SGLang’s draft has none.
首次收录 · 2026-10-25 · 7.94 分