# SGLang

**SGLang** 是一个面向大语言模型和多模态模型的开源服务框架，最初构建时是作为一个高效执行结构化语言模型程序的系统，所谓结构化语言模型程序，即通过控制流和结构化输入输出来串联多次生成调用的应用。它于2023年12月由加州大学伯克利分校和斯坦福大学的郑连民（Lianmin Zheng）及其同事提出，发表于NeurIPS 2024，并以Apache-2.0许可证从sgl-project仓库分发。<sup>[1](https://arxiv.org/abs/2312.07104)</sup><sup> • </sup><sup>[2](https://mast.stanford.edu/pubs/sglang_efficient_execution_of_structured_language_model_programs/)</sup><sup> • </sup><sup>[3](https://github.com/sgl-project)</sup>

| 关键事实 | 详情 |
|---|---|
| 首次发布 | arXiv论文日期为2023年12月12日；NeurIPS 2024发表<sup>[1](https://arxiv.org/abs/2312.07104)</sup><sup> • </sup><sup>[2](https://mast.stanford.edu/pubs/sglang_efficient_execution_of_structured_language_model_programs/)</sup> |
| 核心设计 | 一种带有生成和并行控制原语的前端语言，外加一个运行时，包含用于KV缓存复用的RadixAttention和用于结构化输出解码的压缩有限状态机<sup>[1](https://arxiv.org/abs/2312.07104)</sup> |
| 报告吞吐量 | 在智能体控制、逻辑推理、少样本基准测试、JSON解码、RAG流水线和多轮对话上，吞吐量最高可达最先进推理系统的6.4倍<sup>[1](https://arxiv.org/abs/2312.07104)</sup> |
| 缓存层级 | RadixAttention在GPU内存中缓存前缀KV缓存；HiCache将其扩展到主机内存（L2）和分布式存储（L3），后端包括Mooncake、3FS、NIXL和AIBrix KVCache<sup>[4](https://github.com/Schilings/sglang/blob/main/docs/advanced_features/hicache_design.md)</sup> |
| 硬件 | NVIDIA和AMD GPU，并通过SGL-JAX支持TPU<sup>[5](https://mlai.qa/blog/vllm-vs-sglang-vs-tensorrt-llm/)</sup> |
| 商业化 | 于2026年1月分拆为RadixArk，在Accel领投的一轮融资中估值约4亿美元；盛颖（Ying Sheng）为联合创始人兼CEO<sup>[6](https://techcrunch.com/2026/01/21/sources-project-sglang-spins-out-as-radixark-with-400m-valuation-as-inference-market-explodes/)</sup> |
| 知名用户 | 包括xAI和Cursor在内的公司；部署于Chatbot Arena以服务开放权重模型<sup>[6](https://techcrunch.com/2026/01/21/sources-project-sglang-spins-out-as-radixark-with-400m-valuation-as-inference-market-explodes/)</sup><sup> • </sup><sup>[7](https://par.nsf.gov/servlets/purl/10524135)</sup> |

## 起源与设计

SGLang起源于2023年加州大学伯克利分校[Ion Stoica](https://www.edgepedia.org/zh/ion-stoica)的实验室，Stoica是该校教授，也是[Databricks](https://www.edgepedia.org/zh/databricks)的联合创始人。<sup>[6](https://techcrunch.com/2026/01/21/sources-project-sglang-spins-out-as-radixark-with-400m-valuation-as-inference-market-explodes/)</sup> 原始论文将问题框定为编程与执行的问题：LLM应用越来越需要多次生成调用、高级提示、控制流以及结构化输入输出，但运行此类程序的高效系统尚属缺失。因此该系统由两部分组成。前端通过生成和并行控制原语简化编程，程序可被追踪和编译以进一步优化。运行时通过RadixAttention实现KV缓存复用、通过压缩有限状态机实现更快的结构化输出解码来加速执行。<sup>[1](https://arxiv.org/abs/2312.07104)</sup><sup> • </sup><sup>[8](https://proceedings.neurips.cc/paper_files/paper/2024/file/724be4472168f31ba1c9ac630f15dec8-Paper-Conference.pdf)</sup>

据论文所述，在运行LLM和处理多种模态的模型这两类模型时，该系统的吞吐量最高可达最先进竞争推理引擎的6.4倍，测量覆盖的工作负载包括控制智能体、逻辑推理、少样本学习基准、JSON解码、RAG流水线以及多轮对话。<sup>[1](https://arxiv.org/abs/2312.07104)</sup> SGLang随后被部署于Chatbot Arena以服务开放权重模型。<sup>[7](https://par.nsf.gov/servlets/purl/10524135)</sup>

## RadixAttention与缓存层级

在LLM推理中，预填充阶段将输入序列转换为用于解码的键值（KV）缓存。当多个请求共享相同前缀时，该KV缓存是相同的，因此缓存并复用它可避免冗余计算。RadixAttention利用空闲GPU内存，在基数树中缓存和复用前缀KV缓存，其中每个节点对应一段连续词元的KV缓存，从根到叶的路径代表一个请求的前缀；共享前缀复用相同节点。<sup>[4](https://github.com/Schilings/sglang/blob/main/docs/advanced_features/hicache_design.md)</sup>

**HiCache**将此思想扩展到GPU内存之外。受CPU三级缓存设计的启发，它将GPU内存视为L1、主机内存视为L2、分布式存储视为L3。L1和L2缓存为每个推理实例私有，而L3缓存在整个集群内共享，系统集成了包括Mooncake、3FS、NIXL和AIBrix KVCache在内的分布式缓存后端。元数据组织在HiRadixTree中，记录每段词元的KV缓存存储位置，从L3预取可通过best_effort、wait_complete或timeout终止策略进行调优。<sup>[4](https://github.com/Schilings/sglang/blob/main/docs/advanced_features/hicache_design.md)</sup> 该项目博客报告，在DeepSeek-V4-Flash上使用Mooncake L3层级时，多轮前缀缓存命中率接近98%。<sup>[9](https://www.sglang.io/blog/unified-radix-cache)</sup>

## 运行时特性

当前框架自述为面向大语言模型和多模态模型的高性能服务框架，特性集包括零开销CPU调度器与连续批处理、分页注意力、分块预填充、预填充-解码分离、投机解码、结构化输出、量化（FP4/FP8/INT4/AWQ/GPTQ）、多LoRA批处理，以及张量、流水线、专家和数据并行。<sup>[10](https://docs.sglang.com.cn/)</sup><sup> • </sup><sup>[3](https://github.com/sgl-project)</sup> 它提供OpenAI兼容端点。<sup>[11](https://www.sglang.io/)</sup> 一个原生Rust服务层，带有OpenAI兼容API服务器和预填充-解码分离支持，在v0.5.19版本中发布，该版本还将统一基数树设为所有模型的默认缓存，并为AMD MI300X和MI355X GPU新增了常驻“Lean”注意力内核。<sup>[12](https://github.com/sgl-project/sglang/releases?ref=codersera.com)</sup>

## 在推理引擎中的定位

到2025年，推理软件已围绕三个开源框架整合：vLLM、SGLang和NVIDIA [TensorRT-LLM](https://www.edgepedia.org/zh/tensorrt-llm)。<sup>[13](https://artificialanalysis.ai/downloads/state-of-ai/2025/2025-Year-End-Artificial-Analysis-State-of-AI-Highlights-Report.pdf)</sup> 三者现在都提供相同的基线特性，包括连续批处理、分页KV缓存、分块预填充、前缀缓存、投机解码、结构化输出和多LoRA支持，因此实际差异在于前缀复用设计、硬件广度和治理模式。<sup>[5](https://mlai.qa/blog/vllm-vs-sglang-vs-tensorrt-llm/)</sup> SGLang被描述为在前缀密集型和智能体工作负载以及对前沿模型在发布当天即提供支持方面最强，而vLLM覆盖最广泛的硬件目标，TensorRT-LLM则仅限NVIDIA。<sup>[5](https://mlai.qa/blog/vllm-vs-sglang-vs-tensorrt-llm/)</sup> 一项对开源仓库的实证研究发现，在所研究的五个服务框架中，vLLM在受欢迎程度和采用率方面是最显眼的框架，SGLang则属于使用最广泛的框架之列。<sup>[14](https://arxiv.org/abs/2608.03036)</sup>

**基准测试解读。** 已发表的直接对比数字因模型、精度、提示长度、并发度和引擎版本而差异巨大，独立对比之间因这些变量而相差两位数百分比。<sup>[15](https://ai-solutions.wiki/comparisons/vllm-vs-tensorrt-llm-vs-sglang/)</sup> SGLang未提交至经审计的[MLPerf推理](https://www.edgepedia.org/zh/mlperf-inference)v6.0轮次，因此不存在经审计的三方对比。<sup>[5](https://mlai.qa/blog/vllm-vs-sglang-vs-tensorrt-llm/)</sup> 一个有据可查的陷阱是，基准测试的增益可能只是前缀共享的假象：一项在预发布环境中重放所记录的一整天生产运行数据的跟踪测试显示，SGLang在每秒词元数上领先vLLM 29%，但一旦用每租户提示替代数千个相同的系统提示，生产环境中的差距便缩小至约3%，因为基准测试实际上测量的是基数缓存而非引擎本身。<sup>[16](https://shirokoff.ca/blog/vllm-sglang-tensorrt-llm-compared)</sup>

## RadixArk与商业化

2026年1月，该项目分拆为RadixArk，这是一家商业公司，在Accel领投的一轮融资中估值约4亿美元，早期天使投资人包括英特尔CEO陈立武（Lip-Bu Tan）等人物。SGLang的核心贡献者、曾任职于xAI和Databricks的盛颖成为联合创始人兼CEO。RadixArk继续将SGLang作为开源引擎开发，正在构建Miles——一个专用于强化学习的框架，并已开始对托管服务收费。<sup>[6](https://techcrunch.com/2026/01/21/sources-project-sglang-spins-out-as-radixark-with-400m-valuation-as-inference-market-explodes/)</sup>

## References

1. [Lianmin Zheng et al. (2023). SGLang: Efficient Execution of Structured Language Model Programs. arXiv.](https://arxiv.org/abs/2312.07104)
2. [SGLang: Efficient Execution of Structured Language Model Programs, Stanford MAST Lab](https://mast.stanford.edu/pubs/sglang_efficient_execution_of_structured_language_model_programs/)
3. [sgl-project on GitHub](https://github.com/sgl-project)
4. [HiCache System Design and Optimization, SGLang documentation](https://github.com/Schilings/sglang/blob/main/docs/advanced_features/hicache_design.md)
5. [vLLM vs SGLang vs TensorRT-LLM 2026: Inference Engine Comparison, mlai.qa](https://mlai.qa/blog/vllm-vs-sglang-vs-tensorrt-llm/)
6. [Sources: Project SGLang spins out as RadixArk with $400M valuation as inference market explodes, TechCrunch (21 January 2026)](https://techcrunch.com/2026/01/21/sources-project-sglang-spins-out-as-radixark-with-400m-valuation-as-inference-market-explodes/)
7. [SGLang: Efficient Execution of Structured Language Model Programs (NSF PAR copy)](https://par.nsf.gov/servlets/purl/10524135)
8. [SGLang paper, NeurIPS 2024 proceedings](https://proceedings.neurips.cc/paper_files/paper/2024/file/724be4472168f31ba1c9ac630f15dec8-Paper-Conference.pdf)
9. [Unified Radix Cache in SGLang, SGLang Blog](https://www.sglang.io/blog/unified-radix-cache)
10. [SGLang documentation](https://docs.sglang.com.cn/)
11. [SGLang website](https://www.sglang.io/)
12. [Releases, sgl-project/sglang on GitHub](https://github.com/sgl-project/sglang/releases?ref=codersera.com)
13. [2025 Year-End Artificial Analysis State of AI Highlights Report](https://artificialanalysis.ai/downloads/state-of-ai/2025/2025-Year-End-Artificial-Analysis-State-of-AI-Highlights-Report.pdf)
14. [LLM Serving in the Wild: An Empirical Study of Frameworks, Methods, and System Designs. arXiv.](https://arxiv.org/abs/2608.03036)
15. [vLLM vs TensorRT-LLM vs SGLang, AI Solutions Wiki](https://ai-solutions.wiki/comparisons/vllm-vs-tensorrt-llm-vs-sglang/)
16. [vLLM vs SGLang vs TensorRT-LLM: How to Actually Choose, shirokoff.ca](https://shirokoff.ca/blog/vllm-sglang-tensorrt-llm-compared)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 11, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Foundation-model methods and training › Inference, serving, and efficiency of foundation models

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/sglang

English original: https://www.edgepedia.org/sglang
