Skip to content

Commit bd92ab8

Browse files
committed
feat(sglang): upgrade to v0.5.9 on plain torch base for SLIME support
SLIME's post-training pipeline (Megatron + SGLang) requires SGLang v0.5.9. This upgrades from v0.4.x and rebases the image onto a plain torch base, dropping the torch-extras layer (DeepSpeed, Apex, xFormers) that neither SGLang nor SLIME actually uses. FlashInfer moves from JIT to v0.6.3 AOT compilation via TVM. sgl-kernel is now built with scikit-build-core and enables SM100A (Blackwell) and FP4 support. vLLM and Triton are removed from this image since they are served by the dedicated vllm-tensorizer image.
1 parent 83319a6 commit bd92ab8

5 files changed

Lines changed: 70 additions & 131 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ jobs:
6262
uses: docker/setup-buildx-action@v3.7.1
6363
with:
6464
driver: remote
65-
endpoint: ${{ secrets.BUILDKIT_CONSUMER_AMD64_ENDPOINT }}
65+
endpoint: ${{ secrets.BUILDKIT_DEDICATED_0_AMD64_ENDPOINT }}
6666
platforms: linux/amd64
6767
append: |
68-
- endpoint: ${{ secrets.BUILDKIT_CONSUMER_ARM64_ENDPOINT }}
68+
- endpoint: ${{ secrets.BUILDKIT_DEDICATED_0_ARM64_ENDPOINT }}
6969
platforms: linux/arm64
7070
env:
7171
BUILDER_NODE_0_AUTH_TLS_CACERT: ${{ steps.client-certs.outputs.TLS_CACERT }}

.github/workflows/sglang.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
with:
2525
image-name: sglang
2626
folder: sglang
27-
tag-suffix: ${{ inputs.tag || '386fabe-nccl-cuda12.8.0-ubuntu22.04-nccl2.25.1-1-torch2.6.0-vision0.21.0-audio2.6.0-abi1' }}
27+
tag-suffix: ${{ inputs.tag || 'nccl-cuda12.9.1-ubuntu22.04-nccl2.29.2-1-torch2.10.0-vision0.25.0-audio2.10.0-abi1' }}
2828
build-args: |
29-
BASE_IMAGE=${{ inputs.base-image || 'ghcr.io/coreweave/ml-containers/torch-extras:es-actions-386fabe-nccl-cuda12.8.0-ubuntu22.04-nccl2.25.1-1-torch2.6.0-vision0.21.0-audio2.6.0-abi1'}}
30-
${{ inputs.base-image && 'BASE_IMAGE=' }}${{ inputs.base-image}}
29+
BASE_IMAGE=${{ inputs.base-image || 'ghcr.io/coreweave/ml-containers/torch:17ad6db-nccl-cuda12.9.1-ubuntu22.04-nccl2.29.2-1-torch2.10.0-vision0.25.0-audio2.10.0-abi1'}}
30+
${{ inputs.builder-image && format('BUILDER_IMAGE={0}', inputs.builder-image) || '' }}

sglang/Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,30 @@ ARG BUILDER_IMAGE="${BASE_IMAGE}"
44

55
FROM ${BUILDER_IMAGE} AS builder
66

7-
ARG BUILD_TORCH_CUDA_ARCH_LIST='8.0 8.6 8.9 9.0 10.0+PTX'
7+
ARG BUILD_TORCH_CUDA_ARCH_LIST='8.0 8.6 8.9 9.0a 10.0a 12.0+PTX'
88

9-
ARG FLASHINFER_COMMIT='c04755e21f4d6fb7813c703f2b00a7ef012be9b8'
10-
ARG CUTLASS_COMMIT='b78588d1630aa6643bf021613717bafb705df4ef'
11-
ARG VLLM_COMMIT='5095e966069b9e65b7c4c63427e06cebacaad0a0'
12-
ARG SGLANG_COMMIT='4b6f62e2bc52a528551e9a21e7b0a4945c6115bb'
13-
ARG DECORD_COMMIT='d2e56190286ae394032a8141885f76d5372bd44b'
14-
# Building Triton is not currently enabled,
15-
# but this is the commit that would be used if it were
16-
ARG TRITON_COMMIT='1e0e51c4aeb3e1beea000da5d0e494f8b9ac40dd'
9+
# v0.6.3
10+
ARG FLASHINFER_COMMIT='v0.6.3'
11+
# v0.5.9
12+
ARG SGLANG_COMMIT='v0.5.9'
13+
ARG MAX_JOBS=4
1714

1815
WORKDIR /build
1916
COPY build.bash /build/
2017
RUN mkdir /wheels && \
18+
if [ -n "${MAX_JOBS}" ]; then \
19+
export CMAKE_BUILD_PARALLEL_LEVEL="${MAX_JOBS}"; \
20+
else \
21+
unset MAX_JOBS; \
22+
fi && \
2123
bash build.bash -a "${BUILD_TORCH_CUDA_ARCH_LIST}" && \
2224
rm -rf /build/*
2325
COPY install.bash /wheels/
2426

2527
FROM ${BASE_IMAGE}
28+
29+
ENV SGLANG_COMMIT='v0.5.9'
30+
2631
RUN --mount=type=bind,from=builder,source=/wheels,target=/wheels \
2732
cd /wheels && \
2833
bash install.bash

sglang/build.bash

Lines changed: 46 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ set -xeo pipefail
33
export DEBIAN_FRONTEND=noninteractive
44

55
TORCH_CUDA_ARCH_LIST=''
6-
FILTER_ARCHES=''
7-
BUILD_TRITON=''
86

9-
while getopts 'a:ft' OPT; do
7+
while getopts 'a:' OPT; do
108
case "${OPT}" in
119
a) TORCH_CUDA_ARCH_LIST="${OPTARG}" ;;
12-
f) FILTER_ARCHES='1' ;;
13-
t) BUILD_TRITON='1' ;;
1410
*) exit 92 ;;
1511
esac
1612
done
1713

18-
export NVCC_APPEND_FLAGS='-gencode=arch=compute_100,code=[sm_100,compute_100] -gencode=arch=compute_100a,code=sm_100a --diag-suppress 174'
19-
export TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-9.0 10.0+PTX}"
14+
printf 'Using %s=%s\n' \
15+
FLASHINFER_COMMIT "${FLASHINFER_COMMIT:-<None>}" \
16+
SGLANG_COMMIT "${SGLANG_COMMIT:-<None>}"
17+
18+
export NVCC_APPEND_FLAGS='--diag-suppress 174,177,2361'
19+
export TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-9.0a 10.0a 12.0+PTX}"
2020

2121
mkdir -p /wheels/logs
2222

23-
_BUILD() { python3 -m build -w -n -v -o /wheels "${1:-.}"; }
23+
_CLONE() {
24+
git clone --filter=tree:0 --no-single-branch --no-checkout "${1:?}" "${2:?}" && \
25+
git -C "${2:?}" checkout "${3:?}" && \
26+
git -C "${2:?}" submodule update --init --recursive --jobs 8 --depth 1;
27+
}
28+
_BUILD() { python3 -m build -w -n -v -o /wheels "${@:-.}"; }
2429
_LOG() { tee -a "/wheels/logs/${1:?}"; }
2530
_CONSTRAINTS="$(python3 -m pip list | sed -En 's@^(torch(vision|audio)?)\s+(\S+)$@\1==\3@p')"
2631
_PIP_INSTALL() {
@@ -29,122 +34,55 @@ _PIP_INSTALL() {
2934
"$@"
3035
}
3136

32-
_PIP_INSTALL -U pip setuptools wheel build pybind11 ninja cmake
33-
34-
# triton (not compatible with torch 2.6)
35-
if [ "${BUILD_TRITON}" = 1 ]; then (
36-
: "${TRITON_COMMIT:?}"
37-
echo 'Building triton-lang/triton'
38-
git clone --recursive --filter=blob:none https://github.com/triton-lang/triton
39-
cd triton
40-
git checkout "${TRITON_COMMIT}"
41-
_BUILD python |& _LOG triton.log
42-
); fi
37+
_PIP_INSTALL -U pip setuptools wheel build pybind11 ninja 'cmake<4.0.0' 'scikit-build-core>=0.10' 'setuptools-scm>=8.0'
4338

4439
# flashinfer
4540
: "${FLASHINFER_COMMIT:?}"
46-
: "${CUTLASS_COMMIT:?}"
4741
(
48-
echo 'Building flashinfer-ai/flashinfer'
49-
git clone --recursive --filter=blob:none https://github.com/flashinfer-ai/flashinfer
42+
echo "Building flashinfer-ai/flashinfer @ ${FLASHINFER_COMMIT}"
43+
_CLONE https://github.com/flashinfer-ai/flashinfer flashinfer "${FLASHINFER_COMMIT}"
5044
cd flashinfer
51-
git checkout "${FLASHINFER_COMMIT}"
52-
sed -i 's/name = "flashinfer-python"/name = "flashinfer"/' pyproject.toml
53-
git -C 3rdparty/cutlass checkout "${CUTLASS_COMMIT}"
54-
_PIP_INSTALL -U optree
45+
# flashinfer v0.6+ uses TVM for AOT kernel compilation
46+
_PIP_INSTALL -U optree 'apache-tvm-ffi>=0.1.5,<0.2' requests pynvml nvidia-nvshmem-cu12
47+
# Convert TORCH_CUDA_ARCH_LIST to FlashInfer's format:
48+
# - Add 'a' suffix to >=9.0 arches for architecture-specific instructions
49+
# - Strip +PTX (FlashInfer AOT only generates native SASS, not PTX)
50+
# See vllm-tensorizer/Dockerfile for the reference pattern.
51+
FLASHINFER_ARCH_LIST="$(echo "${TORCH_CUDA_ARCH_LIST}" | sed -E 's@\b(9|10|12)\.0\b@\1.0a@g; s@\+PTX\b@@g' | xargs)"
52+
FLASHINFER_CUDA_ARCH_LIST="${FLASHINFER_ARCH_LIST}" python3 -m flashinfer.aot
5553
NVCC_APPEND_FLAGS="${NVCC_APPEND_FLAGS:+$NVCC_APPEND_FLAGS } --diag-suppress 20281,174" \
56-
FLASHINFER_ENABLE_AOT=1 _BUILD . |& _LOG flashinfer.log
57-
)
58-
59-
# Setup cutlass repo for vLLM to use
60-
git clone --recursive --filter=blob:none https://github.com/NVIDIA/cutlass
61-
git -C cutlass checkout "${CUTLASS_COMMIT}"
62-
63-
# vLLM
64-
: "${VLLM_COMMIT:?}"
65-
(
66-
echo 'Building vllm-project/vllm'
67-
export VLLM_CUTLASS_SRC_DIR="${PWD}/cutlass"
68-
test -d "${VLLM_CUTLASS_SRC_DIR}"
69-
git clone --recursive --filter=blob:none https://github.com/vllm-project/vllm
70-
cd vllm
71-
git checkout "${VLLM_COMMIT}"
72-
# For lsmod
73-
apt-get -qq update && apt-get -qq install --no-install-recommends -y kmod
74-
python3 use_existing_torch.py
75-
_PIP_INSTALL -r requirements-build.txt
76-
USE_CUDNN=1 USE_CUSPARSELT=1 _BUILD . |& _LOG vllm.log
54+
_BUILD . \
55+
|& _LOG flashinfer.log \
56+
| sed '/^Killed$/{p; Q1}'
7757
)
7858

79-
# sglang
59+
# sglang (sgl-kernel CUDA extension + Python package)
8060
: "${SGLANG_COMMIT:?}"
8161
(
82-
echo 'Building sglang'
83-
git clone --recursive --filter=blob:none https://github.com/sgl-project/sglang
62+
echo "Building sgl-project/sglang @ ${SGLANG_COMMIT}"
63+
_CLONE https://github.com/sgl-project/sglang sglang "${SGLANG_COMMIT}"
8464
cd sglang
85-
git checkout "${SGLANG_COMMIT}"
65+
66+
# sgl-kernel (CUDA extension, compiled via scikit-build-core/CMake)
8667
(
8768
cd sgl-kernel
88-
git -C 3rdparty/cutlass checkout "${CUTLASS_COMMIT}"
89-
git -C 3rdparty/flashinfer/3rdparty/cutlass checkout "${CUTLASS_COMMIT}"
90-
91-
ARCH_TRIPLE="$(gcc -print-multiarch)"
92-
LIB_DIR="/usr/lib/${ARCH_TRIPLE:?}"
93-
test -d "${LIB_DIR:?}"
94-
PYTHON_API_VER="$(
95-
python3 --version | sed -En 's@Python ([0-9])\.([0-9]+)\..*@cp\1\2@p'
96-
)"
97-
ARCH_FILTER=()
98-
if [ "${FILTER_ARCHES}" = 1 ]; then
99-
ARCH_FILTER=(-e 's@"-gencode=arch=compute_[78][0-9],code=sm_[78][0-9]",@#\0@')
100-
fi
10169

102-
sed -Ei \
103-
"${ARCH_FILTER[@]}" \
104-
-e 's@/usr/lib/x86_64-linux-gnu@'"${LIB_DIR}"'@' \
105-
-e 's@(\s+)(\w.+manylinux2014_x86_64.+)@\1pass # \2@' \
106-
-e 's@\{"py_limited_api": "cp39"}@{"py_limited_api": "'"${PYTHON_API_VER:-cp310}"'"}@' \
107-
setup.py
108-
SGL_KERNEL_ENABLE_BF16=1 SGL_KERNEL_ENABLE_FP8=1 SGL_KERNEL_ENABLE_SM90A=1 \
109-
_BUILD . |& _LOG sglang.log
70+
_BUILD \
71+
-Cbuild-dir=build \
72+
-Ccmake.define.SGL_KERNEL_ENABLE_SM100A=1 \
73+
-Ccmake.define.SGL_KERNEL_ENABLE_SM90A=1 \
74+
-Ccmake.define.SGL_KERNEL_ENABLE_BF16=1 \
75+
-Ccmake.define.SGL_KERNEL_ENABLE_FP8=1 \
76+
-Ccmake.define.SGL_KERNEL_ENABLE_FP4=1 \
77+
. \
78+
|& _LOG sgl-kernel.log \
79+
| sed '/^Killed$/{p; Q1}'
11080
)
81+
82+
# sglang Python package (no CUDA compilation)
83+
# Remove torch/torchaudio pins — the base image provides these.
84+
sed -i -E '/torch(audio)?[><=~]/d' python/pyproject.toml
11185
_BUILD python |& _LOG sglang.log
11286
)
11387

114-
# decord and xgrammar aren't available on PyPI for ARM64
115-
116-
if [ ! "$(uname -m)" = 'x86_64' ]; then
117-
# xgrammar (for sglang)
118-
(
119-
git clone --recursive --filter=blob:none -b v0.1.11 https://github.com/mlc-ai/xgrammar && \
120-
cd xgrammar
121-
(
122-
mkdir build && cd build
123-
cmake -S.. -B. -DCMAKE_BUILD_TYPE=Release -GNinja |& _LOG xgrammar.log
124-
cmake --build . |& _LOG xgrammar.log
125-
)
126-
_BUILD python |& _LOG xgrammar.log
127-
)
128-
129-
# decord (for sglang)
130-
: "${DECORD_COMMIT:?}"
131-
(
132-
apt-get -qq update && apt-get -q install --no-install-recommends -y \
133-
build-essential python3-dev python3-setuptools \
134-
make cmake ffmpeg \
135-
libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev
136-
git clone --recursive --filter=blob:none https://github.com/dmlc/decord
137-
cd decord
138-
git checkout "${DECORD_COMMIT}"
139-
(
140-
mkdir build && cd build
141-
cmake -S.. -B. -DUSE_CUDA=0 -DCMAKE_BUILD_TYPE=Release -GNinja |& _LOG decord.log
142-
cmake --build . |& _LOG decord.log
143-
cp libdecord.so /wheels/libdecord.so
144-
)
145-
cd python
146-
_BUILD . |& _LOG decord.log
147-
)
148-
fi
149-
15088
apt-get clean

sglang/install.bash

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@ _PIP_INSTALL() {
1212
}
1313

1414
_PIP_INSTALL /wheels/*.whl
15-
if [ -x /wheels/libdecord.so ]; then
16-
apt-get -qq update && apt-get -q install --no-install-recommends -y \
17-
libavfilter7 libavformat58 && \
18-
apt-get clean
19-
cp /wheels/libdecord.so /usr/local/lib/ && ldconfig
20-
fi
2115

22-
SGLANG_EXTRA_PIP_DEPENDENCIES=()
16+
SGLANG_EXTRA_PIP_DEPENDENCIES=('decord2')
2317
if [ "$(uname -m)" = 'x86_64' ]; then
24-
SGLANG_EXTRA_PIP_DEPENDENCIES=('decord' 'xgrammar>=0.1.10')
18+
SGLANG_EXTRA_PIP_DEPENDENCIES+=('xgrammar>=0.1.10')
2519
fi
20+
2621
_PIP_INSTALL \
2722
'aiohttp' 'fastapi' \
2823
'hf_transfer' 'huggingface_hub' 'interegular' 'modelscope' \
2924
'orjson' 'packaging' 'pillow' 'prometheus-client>=0.20.0' \
3025
'psutil' 'pydantic' 'python-multipart' 'pyzmq>=25.1.2' \
3126
'torchao>=0.7.0' 'uvicorn' 'uvloop' \
32-
'cuda-python' 'outlines>=0.0.44,<0.1.0' \
27+
'cuda-python' 'outlines==0.1.11' \
28+
'pybase64' \
3329
"${SGLANG_EXTRA_PIP_DEPENDENCIES[@]}"

0 commit comments

Comments
 (0)