Development Setup
This guide covers setting up a development environment for SGLang, including Docker-based and local setups.Prerequisites
- Python 3.8+
- CUDA 11.8+ (for GPU support)
- Docker (optional, for containerized development)
- Git
Option 1: Local Development
Clone Repository
Install Dependencies
Install Kernels
Verify Installation
Option 2: Docker Development
Using VSCode Dev Containers (Recommended)
SGLang includes a.devcontainer configuration for seamless Docker-based development.
Setup Steps
- Install VSCode and the Dev Containers extension
-
Open the repository in VSCode:
-
Press
F1, type “Dev Containers: Reopen in Container”, and press Enter - VSCode will build the container and install all dependencies automatically
Running the Server in Dev Container
Manual Docker Setup
For manual Docker container management:Volume Mounts Explained
~/.cache/huggingface: Avoids re-downloading models on container restart$(pwd): Syncs your local code changes to the container--network=host: Required for RDMA (can be omitted if RDMA is not needed)--privileged: Required for RDMA (can be omitted if RDMA is not needed)
RDMA Note: If using RoCE, you may need to set
export NCCL_IB_GID_INDEX=3 inside the container.Option 3: Remote Development
VSCode Remote Tunnels
Develop on a remote machine using VSCode Remote Tunnels:On Remote Host
On Local Machine
- Press
F1in VSCode - Select “Remote Tunnels: Connect to Tunnel”
- Sign in and select your remote host
Debugging with VSCode
Configure Launch Settings
Create or edit.vscode/launch.json:
Start Debugging
- Set breakpoints in the code
- Press
F5to start debugging - The debugger will pause at breakpoints, even in remote/container environments
Testing
Run Unit Tests
Run Integration Tests
Profiling
PyTorch Profiler
Nsight Systems
Environment Variables
Common environment variables for development:Common Development Tasks
Format Code
Run Linters
Build Documentation
Update Dependencies
Troubleshooting
Out of Memory
CUDA Errors
Import Errors
Pre-commit Failures
Next Steps
- Contribution Guide - How to contribute code
- Architecture Overview - Understanding SGLang’s architecture
- Adding Models - How to add support for new models
- Testing - Testing guidelines
