Перейти к содержимому

SGLang Explained: How Efficient LLM Serving Works

Forward Pass

0:00 / 0:00

SGLang Explained: How Efficient LLM Serving Works

190 просмотров · 8 дн. назад
Forward Pass
69 подписчиков
190 просмотров · 8 дн. назад
Follow a coding-agent request through SGLang: prefill and decode, RadixAttention and exact prefix reuse, continuous batching, chunked prefill, structured outputs, speculative decoding, multi-GPU parallelism, and prefill/decode disaggregation. Finish with a practical local-server walkthrough and the measurements that matter under real traffic. If you learned something, please like this video and subscribe for more explanations like this. Commands shown in the video Illustrative tutorial for compatible Linux/NVIDIA hardware. Check the official installation guide for your CUDA, driver, Python and GPU combination. The video does not report a GPU run or benchmark. Qwen2.5-0.5B-Instruct is a small demonstration model. Install in an isolated environment With uv already installed: ```sh uv venv --python 3.12 --seed source .venv/bin/activate uv pip install --prerelease=allow sglang ``` Start the server ```sh python3 -m sglang.launch_server \ --model-path Qwen/Qwen2.5-0.5B-Instruct \ --host 127.0.0.1 \ --port 30000 ``` Wait for the server to finish preparing before sending requests. The demonstration binds to localhost. Send a streaming request from a second terminal ```sh curl -N http://127.0.0.1:30000/v1/chat/completions \ -H 'Content-Type: application/json' \ -d '{ "model": "Qwen/Qwen2.5-0.5B-Instruct", "messages": [ {"role": "user", "content": "Explain prefix caching."} ], "max_tokens": 100, "stream": true }' ``` An OpenAI client can use base URL `http://127.0.0.1:30000/v1`. The native generation endpoint is `http://127.0.0.1:30000/generate`; it uses its own request schema. Chapters: 00:00 What SGLang does 01:24 Prefill, decode and the runtime 02:53 RadixAttention and exact prefix reuse 05:12 Continuous batching and chunked prefill 06:33 Structured generation 07:54 Speculative decoding 09:22 Multi-GPU serving 10:45 Prefill/decode disaggregation 11:31 Install, launch and stream 13:03 Where SGLang fits 13:57 Measure performance and conclude