SGLang: An Efficient Open-Source Framework for Large-Scale LLM Serving - Liangsheng Yin

PyTorch · Beginner ·🧠 Large Language Models ·1y ago
Skills: LLMOps80%

Key Takeaways

Introduces SGLang, an efficient open-source framework for large-scale LLM serving with features like PD disagg and prefix caching

Full Transcript

Hi everyone. Uh today I will uh present a talk at an efficient open source framework for large scale serving and I'm leing I come from Shan University as a student and I also a member of the uh organization LMC's. Yeah. So uh yeah so uh let's introduce what is achil. I believe that most of you uh today may heard may hear uh heard of that our open source project. Yeah. uh we are fastest serving engine for and uh we are uh we are currently one of the state-of-the-art uh performance uh open source engine and we are the first open source implementation to nearly match the throughput reported in the official DeepS blog at large scale and meanwhile I want to stress that uh our elegant lightweight and customizable design has attracted a wide adoption uh from academics and big tech tech uh companies u such as XAI, Nvidia, AMD, based on Microsoft and linking and we also uh scale as a high performance solution uh in the RL side. Yeah. So today's talk I will today's talk I will part uh the outlines into four parts. The first part is u milestones and uh overall features overview and the second part is our efficient design of implementation of PDD aggregation. Uh the third part is large scale EP support and the deepseek blog reproduction and the last part is our ecosystem of the a strong community and the future development. Yeah. So uh let's uh let's take in the first part. Yeah. Uh this is our milestones and overall uh key features. uh uh on 2023 uh we released our initi in initial release uh with the structure LM programming and the prefix caching uh and also as well as constraint decoding. In this version we introduce uh the first open source and efficient prefix caching to reuse KV cache and to reduce the redundant commutation and u uh uh last year summer we introduced our 0.2 2 version uh we uh we we achieved the leading performance in among all the uh open source informance with deploy of the llama 3 and and uh with 0.3 release we uh we release our seven time faster deep MLA and uh faster with torch compile and uh uh we also support multi-image and and video uh uh video models and uh the the last year we released our 0.4 release. This is a this release contains zero overhead batch scheduler uh cache aware DP router and X grammar integration and we are um meanwhile we are the first to serve DeepSync W3 and uh just uh oh uh just uh last month uh we first open sourced implementation of large scale expert parism with pre and decode disagregation. uh we achieved like five time faster than Manila DP and we matched the performance uh uh mentioned in deepseek blog and we matched the API cost uh like 0.2 uh dollars uh 1 million token. Yeah. So uh the second part is uh uh is the efficient design and implementation of PD disagregation. Yeah. uh let's talk about the issue with nonPD disagregation non-disaggregation scheduling mode as as as we all know that uh uh without disagregation scheduling uh the decoding batches will always be preempted by uh prefilling uh this will introduce uh extra uh latency to the token generation and um the second problem is uh uh DP attention with non-disagation mode u it brings uh uh the computation and communication imbalance uh uh within the same DP DP attention group uh uh decoding and prefilling batches they may mix uh with each other and uh uh being executed simultaneously. This uh will increase the latency for decoded tokens and cause uh the load imbalance. Uh the third one is encounter with DP and this part I will also introduce later. uh prefill and decode uh they they they usually use a different dispatch mode uh without disagregation. DPB cannot support both in a same communication group. Uh so uh and we uh and we implement the PD disagregation and this is overview of our architecture. Uh uh for example the uh the purple uh ones is the preview instances or clusters and the orange ones is decoder instances. uh we use the load balancer as a request entry point and uh uh this this load balancer is uh for both preview and the decode path. So uh in in our design LB is decoupled from computational logic and only uh responsible for select PD pair and routes to this uh and return request is it's is it's is it's decoupled and uh we also support uh non-blocking and RDMA based KB transfer and uh uh also we we are we offers flexible API integration of the transfer engine uh for example like Nixo and Monake uh Just as uh uh Dr. John just uh mentioned in last talk. Yeah. Uh here is a demonstration of uh the PDD saggression timeline uh time time step. Yeah. Uh first we uh suppose that we have a preview instance and we have a decode instance. Uh the first thing is the load balancer they should to send a request. uh they they they should choose a PD pair and send the request uh to both prefer instance and decoder instance and uh there the first there is a handshake handshake process. The handshake exchange the metadata uh of like KV uh KV index and addresses and uh the sender the KV cache sender and the KV cache receivers they they are initialized during this phase. And the second thing is uh uh when you want to transfer the KV cache to the decoder engine, the decoder they must have enough memory to to to to to pull this KV cache. So the second uh the second event is the pre-allocation. uh uh after the decoder instance they have enough uh uh memory for uh the KV cache they they they pre-allocate the KV cache in the memory pool and then notify the prefill instance that yes uh we have enough memory so you can start the preing you you can start the prefilling phase and and send a KV cache to us and uh then the prefill they begin the prefill forward and uh after the prefilling uh they send a KV cache to the decoder instance Uh the last part is the decode instance to to to to do the decode. After the decode uh the result is returned to the load balancer and the load balancer return the result to to the user site and this is a PD disagregation time stamp is also a demonstration. Yeah. So uh the next part is uh the large scale expert par support and deepse block reproduction. Yeah. uh uh there even there is only like three layers of uh dense layers in deepse models uh we still need to figure out how to efficiently serve these layers with dense ffm uh we choose to use pure pure data parallel instead of tensor parallel or mixed uh of them uh this is for we we can avoid the TP fragmentation uh on large hidden sides uh we we don't need to cut the tensor uh into uh into different TP ranks and and uh the uh the the second advantage is uh we can uh optimize the memory efficiency. Uh for both preill and decode uh low TP degrees they can benefit from uh only DP uh equals one. Uh this can reduce per device memory. And uh the biggest and the third uh uh uh optimization is uh they can bring is to minimize the communication overhead uh by using purely uh uh purely data parallel we can avoid all the communication within the tensor paris group. Uh then for all layer for every layer is only one scatter and one or gather. uh the scatter is before the attention part and the all together is after the the uh the the attention part only twice communication uh and also for thee layers is sparse FFN uh we use the uh uh par strategy in deep block uh is it's a DP attention with sparse FFN with expert parism uh the reason is we can scale the model capacity different experts can be partitioned in different uh devices. So uh this can uh this can support more experts numbers and removing the memory bottleneck. And the the se uh the second uh uh advantage is uh we can uh uh no this is not advant this is the challenges uh brought by uh thee uh strategy uh by the expert par strategy uh uh when you deploy the uh uh layers with uh uh one DP attention uh dispatch uh EP sparse FFN and then combine they based pattern of uh dispatch expert combin uh combination. Uh this brings some uh communication overhead and underutilization of GPU resources. Uh luckily this can be optimized by DPP and the two batch overlap which I will also introduce later. And also this uh this also brings uh the load imbalance problem and this can be uh addressed by the EPLB. Yeah. So uh the first the the first problem is to uh solve the compat compatibility issue with DPP. Uh DPP they hold two dispatch mode for uh uh for for normal mode and the low latency mode. The normal mode uh they are pre uh they are profile friendly but uh they use uh symbolic tensor shape. Uh this this this doesn't support the CUDA graph and the loading mode they use static data uh tensor shape. is decode friendly uh and both of them they can support DP attention and there is uh auto mode to to automatically handle uh both input and output but uh as just just as I mentioned in uh in in in several slides before uh when you use uh preview and decode uh within the same uh communication group uh in DPP uh they are incompatible because they are uh you cannot put two dispatch mode in within the same communication group. So uh this is the reason uh this is solution how we solve the compatibility issue with DPB and this is also uh one of the reasons that we should use uh PD disagregation instead of unified scheduling. uh uh this part I will introduce the implementation details of uh two batch overlap uh for short tbo. Uh this is a example of uh uh improper launch order of TPO. uh you can notice that uh we want to implement TBO with communication and uh computation are execute uh at the same time uh simultaneously and if we dispatch the uh if we launch the dispatch kernel before the MLP kernel uh for example the uh the yellow ones dispatch kernel is launched before the the green batch uh MLP kernel. So uh the dispatch they will bring synchronization which means uh the CPU will be blocked until the GPU receive all the metadata from all other EP ranks then they can allocate the uh right shape tensored uh the the correctly sized tensors. So uh you cannot uh launch uh two kernel uh yeah so the dispatch kernel launch will block the MLP kernel launch which brings uh the waste of uh uh uh computation resources and so we need to solve this uh by by placing the computation kernel always before the communication kernel. So uh there is a slight difference is we put the green MLP before the yellow dispatch kernel. This is a launch order and for the execution side they are executed simultaneously. Yeah. So uh so in each round uh uh follow the pattern of computation and communication. Yeah. This is a launch uh order. then uh GPU can uh remain active uh during the communication. Uh so how to implement this uh in a clean manner? So uh we use the abstraction uh operation list and the y points. This uh enable cooperative scheduling and uh this uh eliminates code duplication and avoid um some possibly uh uh variable post fixes and this can um this can also manage the partial completion or between different uh attention layers uh decoder layers. Yeah. So uh this is our throughput performance and this this this benchmark uh result is also posted in our uh LMC's blog. You can just search at Google LMC.org and you can find the blog. Yeah. Uh this benchmark is uh uh evaluate on preview and decode uh uh independently assuming that unlimited resources for the other side. So uh and we can notice that uh for the preview mode we achieve uh three times uh faster throughput uh than vanilla tensorm of 16 uh TP uh ranks and we for the decode part we uh successfully enlarge the batch size uh from around uh maybe uh 15 to more than more than 200 uh 200. Yeah. And we also improved the throughput of decoder uh by 5.1 times and this can uh roughly match the uh blog uh posted by deepseek uh in this February. Uh also we we also implement expert parism uh load balancer. Uh in real world serving challenges uh uh the imbalance worsen at scale with uh some some node they will uh accept so many uh routed experts and uh some node they are they they are staying idle uh without uh routing expert to them. So uh two strategy to improve balance is uh we can improve the batch size uh and uh imp uh improve the uh clusters. Uh we can improve this while cluster scaling and uh uh speculative decoding like MTP. Uh with MTP we can forward like one or two three four tokens at the same decode time and then the batch size they can be multipled like three or four times. uh uh also SLAS implementation uh implement a uh a a re rebalance uh uh for for just the exchange expert ways with torch P2P uh operations and then this is ablation study of uh effects of uh scale and EPLB uh uh to balancedness. The balancedness is defined as the ratio between mean computation time as a maximum computation time fore layer among GPUs. Uh the balancedness uh decreases when the system scales uh with the number of nodes. Uh and uh we can uh we can find that uh enabling EPB significantly improves the balancedness. Yeah. And this is all part of uh our uh reproduction of deepseek blog. Yeah. So the last part is our ecosystem and astron community and future development. Uh also we we are the first we are the first one to open source uh the deepseek uh large scale EPU deploy and there are some future work we need to solve. uh is the first one is the latency optimization. uh uh we the the the first token latency and the inter token latency is is still too large and we need uh tuning for real-time use cases and the sequence length is constrained by uh uh by limited uh uh 96 GPU setup and MTP and the data parallel attention is not fully integrated uh together and the EPB is only uh evaluated in uh in simulated the workload and uh and uh the dense layers of FFN they can be benefit from small uh TPIS and we only support tensor parism full tensor parism and or full data parallel and uh we also plan to uh support black well architecture and uh uh if anyone here want to join the community to uh contribute to the blackwell support you can just uh join our slack Uh yeah so this is our team. Yeah we our team is incubated by LMS is uh is a corporation as non-benefit uh and the uh the there is a list of the uh major maintainers and we have uh contributors over 400. Yeah. Uh the last page is our community adoption. So we have uh yeah the our biggest uh client is XAI and Nvidia and AMD and also thanks to PyTorch to give me this chance to give this talk. Yeah, thank you. [Applause]

Original Description

SGLang: An Efficient Open-Source Framework for Large-Scale LLM Serving - Liangsheng Yin, Shanghai Jiao Tong University / LMSYS SGLang is an open-source Large Language Model (LLM) inference system that is highly efficient and widely adopted by many companies like xAI, Nvidia and AMD. In this session, I will introduce some key features of SGLang, including the design and implementation of PD disaggregation, large-scale expert parallelism and data parallelism for DeepSeek models, hierarchical KV cache offloading, and highly efficient speculative decoding. I will also share some insights into the future development of the SGLang community.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from PyTorch · PyTorch · 0 of 60

← Previous Next →
1 What is PyTorch?
What is PyTorch?
PyTorch
2 PyTorch Tutorial: A Quick Preview
PyTorch Tutorial: A Quick Preview
PyTorch
3 PyTorch Summer Hackathon 2019
PyTorch Summer Hackathon 2019
PyTorch
4 Tips and Tricks on Hacking with PyTorch: A Quick Tutorial by Brad Heintz
Tips and Tricks on Hacking with PyTorch: A Quick Tutorial by Brad Heintz
PyTorch
5 PyTorch 1.2 and PyTorch Hub: A Quick Introduction by Soumith Chintala and Ailing Zhang
PyTorch 1.2 and PyTorch Hub: A Quick Introduction by Soumith Chintala and Ailing Zhang
PyTorch
6 Torchtext 0.4 with Supervised Learning Datasets: A Quick Introduction by George Zhang
Torchtext 0.4 with Supervised Learning Datasets: A Quick Introduction by George Zhang
PyTorch
7 Torchaudio 0.3 with Kaldi Compatibility, New Transforms: A Quick Introduction by Jason Lian
Torchaudio 0.3 with Kaldi Compatibility, New Transforms: A Quick Introduction by Jason Lian
PyTorch
8 Torchvision 0.4 with Support for Video: A Quick Introduction by Francisco Massa
Torchvision 0.4 with Support for Video: A Quick Introduction by Francisco Massa
PyTorch
9 Introduction to Machine Learning for Developers at F8 2019
Introduction to Machine Learning for Developers at F8 2019
PyTorch
10 Powered by PyTorch at F8 2019
Powered by PyTorch at F8 2019
PyTorch
11 Developing and Scaling AI Experiences at Facebook with PyTorch at F8 2019
Developing and Scaling AI Experiences at Facebook with PyTorch at F8 2019
PyTorch
12 New Approaches to Image and Video Reconstruction Using Deep Learning at Facebook at F8 2019
New Approaches to Image and Video Reconstruction Using Deep Learning at Facebook at F8 2019
PyTorch
13 PyTorch Developer Conference 2018: Recap
PyTorch Developer Conference 2018: Recap
PyTorch
14 PyTorch Developer Conference 2018: Keynote & Deep Dive
PyTorch Developer Conference 2018: Keynote & Deep Dive
PyTorch
15 PyTorch Developer Conference 2018: Production & Research Sessions
PyTorch Developer Conference 2018: Production & Research Sessions
PyTorch
16 PyTorch Developer Conference 2018: Cloud & Academia Sessions
PyTorch Developer Conference 2018: Cloud & Academia Sessions
PyTorch
17 PyTorch Developer Conference 2018: Enterprise, Education, & Future of AI Panel
PyTorch Developer Conference 2018: Enterprise, Education, & Future of AI Panel
PyTorch
18 PyTorch Developer Conference 2019 | Full Livestream
PyTorch Developer Conference 2019 | Full Livestream
PyTorch
19 PyTorch Developer Conference 2019: Recap
PyTorch Developer Conference 2019: Recap
PyTorch
20 PyTorch Developer Conference Keynote - Mike Schroepfer
PyTorch Developer Conference Keynote - Mike Schroepfer
PyTorch
21 What’s new in PyTorch 1.3 - Lin Qiao
What’s new in PyTorch 1.3 - Lin Qiao
PyTorch
22 PyTorch Front-End Features: Named Tensors and Type Promotion - Gregory Chanan
PyTorch Front-End Features: Named Tensors and Type Promotion - Gregory Chanan
PyTorch
23 Research to Production: PyTorch JIT/TorchScript Updates - Michael Suo
Research to Production: PyTorch JIT/TorchScript Updates - Michael Suo
PyTorch
24 Quantization - Dmytro Dzhulgakov
Quantization - Dmytro Dzhulgakov
PyTorch
25 PyTorch ONNX Export Support - Lara Haidar, Microsoft
PyTorch ONNX Export Support - Lara Haidar, Microsoft
PyTorch
26 Apex -  Michael Carilli, NVIDIA
Apex - Michael Carilli, NVIDIA
PyTorch
27 Dataloader Design for PyTorch - Tongzhou Wang, MIT
Dataloader Design for PyTorch - Tongzhou Wang, MIT
PyTorch
28 Linear Algebra in PyTorch - Vishwak Srinivasan, CMU
Linear Algebra in PyTorch - Vishwak Srinivasan, CMU
PyTorch
29 PyTorch Mobile - David Reiss
PyTorch Mobile - David Reiss
PyTorch
30 Model Interpretability with Captum - Narine Kokhilkyan
Model Interpretability with Captum - Narine Kokhilkyan
PyTorch
31 Detectron2 - Next Gen Object Detection Library - Yuxin Wu
Detectron2 - Next Gen Object Detection Library - Yuxin Wu
PyTorch
32 Speech Extensions to Fairseq - Dmytro Okhonko
Speech Extensions to Fairseq - Dmytro Okhonko
PyTorch
33 PyTorch on Google Cloud TPUs - Google, Salesforce, Facebook
PyTorch on Google Cloud TPUs - Google, Salesforce, Facebook
PyTorch
34 PyTorch Summer Hackathon Winners - Joe Spisak, Sebastien Arnold, Tristan Deleu
PyTorch Summer Hackathon Winners - Joe Spisak, Sebastien Arnold, Tristan Deleu
PyTorch
35 PyTorch in Robotics - Yisong Yue, Caltech
PyTorch in Robotics - Yisong Yue, Caltech
PyTorch
36 StanfordNLP - Yuhao Zhang, Stanford
StanfordNLP - Yuhao Zhang, Stanford
PyTorch
37 Sotabench for Reproducible Research - Robert Stojnic, Papers with Code
Sotabench for Reproducible Research - Robert Stojnic, Papers with Code
PyTorch
38 Collaborative Natural Language Inference - Sasha Rush, Cornell
Collaborative Natural Language Inference - Sasha Rush, Cornell
PyTorch
39 Privacy Preserving AI - Andrew Trask, OpenMined
Privacy Preserving AI - Andrew Trask, OpenMined
PyTorch
40 CrypTen - Laurens van der Maaten
CrypTen - Laurens van der Maaten
PyTorch
41 PyTorch at Uber - Sidney Zhang, Uber
PyTorch at Uber - Sidney Zhang, Uber
PyTorch
42 PyTorch at Tesla - Andrej Karpathy, Tesla
PyTorch at Tesla - Andrej Karpathy, Tesla
PyTorch
43 PyTorch at Microsoft - Saurabh Tiwary, Microsoft
PyTorch at Microsoft - Saurabh Tiwary, Microsoft
PyTorch
44 PyTorch at Dolby Labs - Vivek Kumar, Dolby Labs
PyTorch at Dolby Labs - Vivek Kumar, Dolby Labs
PyTorch
45 PyTorch Developer Conference 2019 - Panel Discussion
PyTorch Developer Conference 2019 - Panel Discussion
PyTorch
46 Using deep learning and PyTorch to power next gen aircraft at Caltech
Using deep learning and PyTorch to power next gen aircraft at Caltech
PyTorch
47 Named Tensors, Model Quantization, and the Latest PyTorch Features - Part 1
Named Tensors, Model Quantization, and the Latest PyTorch Features - Part 1
PyTorch
48 TorchScript and PyTorch JIT | Deep Dive
TorchScript and PyTorch JIT | Deep Dive
PyTorch
49 Announcing the PyTorch Global Summer Hackathon 2020
Announcing the PyTorch Global Summer Hackathon 2020
PyTorch
50 Opening Up the Black Box: Model Understanding with Captum and PyTorch
Opening Up the Black Box: Model Understanding with Captum and PyTorch
PyTorch
51 PyTorch Mobile Runtime for Android
PyTorch Mobile Runtime for Android
PyTorch
52 Torchvision in 5 minutes
Torchvision in 5 minutes
PyTorch
53 3D Deep Learning with PyTorch3D
3D Deep Learning with PyTorch3D
PyTorch
54 What is Torchtext?
What is Torchtext?
PyTorch
55 TorchAudio: A Quick Intro
TorchAudio: A Quick Intro
PyTorch
56 PyTorch Mobile Runtime for iOS
PyTorch Mobile Runtime for iOS
PyTorch
57 PySlowFast: Deep learning with Video
PySlowFast: Deep learning with Video
PyTorch
58 PyTorch Pruning | How it's Made by Michela Paganini
PyTorch Pruning | How it's Made by Michela Paganini
PyTorch
59 Measuring Fairness in Machine Learning Systems
Measuring Fairness in Machine Learning Systems
PyTorch
60 PyTorch for Hackathons
PyTorch for Hackathons
PyTorch

Related Reads

📰
Day 103: LLM Fine-Tuning Pipeline - AI System Design in Seconds
Learn to design a fine-tuning pipeline for large language models in minutes, streamlining AI system development
Dev.to AI
📰
Open-Weight LLM API Integration: A Practical Developer Guide
Learn to integrate open-weight LLM APIs into your application with a practical developer guide
Dev.to AI
📰
Escaping VRAM Fragmentation: Multi-Model Serving with SGLang
Learn to deploy SGLang on a bare-metal server to escape VRAM fragmentation and optimize multi-model serving for Large Language Models
Dev.to AI
📰
I finally saw a legal agent setup that used OpenClaw for 6 months without pretending to be your lawyer
Learn how OpenClaw is being used in a real-life legal setting without pretending to be a lawyer, and why this approach matters for AI in law
Dev.to AI
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →