Setup VSCode on a Remote Host
(Optional - you can skip this step if you plan to run sglang dev container locally)- In the remote host, download
codefrom Https://code.visualstudio.com/docs/?dv=linux64cli and runcode tunnelin a shell.
- In your local machine, press F1 in VSCode and choose “Remote Tunnels: Connect to Tunnel”.
Setup Docker Container
Option 1. Use the default dev container automatically from VSCode
There is a.devcontainer folder in the sglang repository root folder to allow VSCode to automatically start up within dev container. You can read more about this VSCode extension in VSCode official document Developing inside a Container.
- Start Visual Studio Code and install VSCode dev container extension.
- Press F1, type and choose “Dev Container: Open Folder in Container.
- Input the
sglanglocal repo path in your machine and press enter.
sglang.launch_server in the VSCode terminal or start debugging using F5, sglang server will be started in the dev container with all your local changes applied automatically:
Option 2. Start up containers manually (advanced)
The following startup command is an example for internal development by the SGLang team. You can modify or add directory mappings as needed, especially for model weight downloads, to prevent repeated downloads by different Docker containers. ❗️ Note on RDMA--network hostand--privilegedare required by RDMA. If you don’t need RDMA, you can remove them but keeping them there does not harm. Thus, we enable these two flags by default in the commands below.- You may need to set
NCCL_IB_GID_INDEXif you are using RoCE, for example:export NCCL_IB_GID_INDEX=3.
- Huggingface model cache: mounting model cache can avoid re-download every time docker restarts. Default location on Linux is
~/.cache/huggingface/. - SGLang repository: code changes in the SGLang local repository will be automatically synced to the .devcontainer.
/opt/dlami/nvme/.cache but not the SGLang repo. Use this when you prefer to manually transfer local code changes to the devcontainer.
Debug SGLang with VSCode Debugger
-
(Create if not exist) open
launch.jsonin VSCode. -
Add the following config and save. Please note that you can edit the script as needed to apply different parameters or debug a different program (e.g. benchmark script).
- Press “F5” to start. VSCode debugger will ensure that the program will pause at the breakpoints even if the program is running at remote SSH/Tunnel host + dev container.
