chore: vendor sglang v0.5.10 snapshot
This commit is contained in:
581
third_party/sglang/docker/Dockerfile
vendored
Normal file
581
third_party/sglang/docker/Dockerfile
vendored
Normal file
@@ -0,0 +1,581 @@
|
||||
ARG CUDA_VERSION=12.9.1
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu24.04 AS base
|
||||
|
||||
ARG TARGETARCH
|
||||
ARG BUILD_TYPE=all
|
||||
ARG BRANCH_TYPE=remote
|
||||
ARG GRACE_BLACKWELL=0
|
||||
ARG HOPPER_SBO=0
|
||||
|
||||
ARG GRACE_BLACKWELL_DEEPEP_BRANCH=gb200_blog_part_2
|
||||
ARG HOPPER_SBO_DEEPEP_COMMIT=9f2fc4b3182a51044ae7ecb6610f7c9c3258c4d6
|
||||
ARG DEEPEP_COMMIT=9af0e0d0e74f3577af1979c9b9e1ac2cad0104ee
|
||||
ARG BUILD_AND_DOWNLOAD_PARALLEL=8
|
||||
ARG SGL_KERNEL_VERSION=0.4.1
|
||||
ARG SGL_VERSION
|
||||
ARG USE_LATEST_SGLANG=0
|
||||
ARG GDRCOPY_VERSION=2.5.1
|
||||
ARG PIP_DEFAULT_INDEX
|
||||
ARG UBUNTU_MIRROR
|
||||
ARG GITHUB_ARTIFACTORY=github.com
|
||||
ARG INSTALL_FLASHINFER_JIT_CACHE=0
|
||||
ARG FLASHINFER_VERSION=0.6.7.post2
|
||||
ARG MOONCAKE_VERSION=0.3.9
|
||||
#if need other arg please add in MOONCAKE_COMPILE_ARG
|
||||
ARG MOONCAKE_COMPILE_ARG="-DUSE_HTTP=ON -DUSE_MNNVL=ON -DUSE_CUDA=ON -DWITH_EP=ON"
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
CUDA_HOME=/usr/local/cuda \
|
||||
GDRCOPY_HOME=/usr/src/gdrdrv-${GDRCOPY_VERSION}/ \
|
||||
FLASHINFER_VERSION=${FLASHINFER_VERSION}
|
||||
|
||||
# Add GKE default lib and bin locations
|
||||
ENV PATH="${PATH}:/usr/local/nvidia/bin" \
|
||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64"
|
||||
|
||||
# Replace Ubuntu sources if specified
|
||||
RUN if [ -n "$UBUNTU_MIRROR" ]; then \
|
||||
sed -i "s|http://.*archive.ubuntu.com|$UBUNTU_MIRROR|g" /etc/apt/sources.list && \
|
||||
sed -i "s|http://.*security.ubuntu.com|$UBUNTU_MIRROR|g" /etc/apt/sources.list; \
|
||||
fi
|
||||
|
||||
# Python setup (combined with apt update to reduce layers)
|
||||
RUN --mount=type=cache,target=/var/cache/apt,id=base-apt \
|
||||
apt update && apt install -y --no-install-recommends wget software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
||||
&& apt install -y --no-install-recommends python3.12-full python3.12-dev python3.10-venv \
|
||||
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 \
|
||||
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 \
|
||||
&& update-alternatives --set python3 /usr/bin/python3.12 \
|
||||
&& wget -q https://bootstrap.pypa.io/get-pip.py \
|
||||
&& python3 get-pip.py --break-system-packages \
|
||||
&& rm get-pip.py \
|
||||
# Allow pip to install packages globally (PEP 668 workaround for Ubuntu 24.04)
|
||||
&& python3 -m pip config set global.break-system-packages true \
|
||||
# Fix for apt-add-repository
|
||||
&& cd /usr/lib/python3/dist-packages/ \
|
||||
&& ln -s apt_pkg.cpython-310-*-linux-gnu.so apt_pkg.so
|
||||
|
||||
# Install system dependencies (organized by category for better caching)
|
||||
RUN --mount=type=cache,target=/var/cache/apt,id=base-apt \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
# Core system utilities
|
||||
ca-certificates \
|
||||
software-properties-common \
|
||||
netcat-openbsd \
|
||||
kmod \
|
||||
unzip \
|
||||
openssh-server \
|
||||
curl \
|
||||
wget \
|
||||
lsof \
|
||||
locales \
|
||||
# Build essentials (needed for framework stage)
|
||||
build-essential \
|
||||
cmake \
|
||||
perl \
|
||||
patchelf \
|
||||
ccache \
|
||||
git-lfs \
|
||||
# MPI and NUMA
|
||||
libopenmpi-dev \
|
||||
libnuma1 \
|
||||
libnuma-dev \
|
||||
numactl \
|
||||
# transformers multimodal VLM
|
||||
ffmpeg \
|
||||
# InfiniBand/RDMA
|
||||
libibverbs-dev \
|
||||
libibverbs1 \
|
||||
libibumad3 \
|
||||
librdmacm1 \
|
||||
libnl-3-200 \
|
||||
libnl-route-3-200 \
|
||||
libnl-route-3-dev \
|
||||
libnl-3-dev \
|
||||
ibverbs-providers \
|
||||
infiniband-diags \
|
||||
perftest \
|
||||
# Development libraries
|
||||
libgoogle-glog-dev \
|
||||
libgtest-dev \
|
||||
libjsoncpp-dev \
|
||||
libunwind-dev \
|
||||
libboost-all-dev \
|
||||
libssl-dev \
|
||||
libgrpc-dev \
|
||||
libgrpc++-dev \
|
||||
libprotobuf-dev \
|
||||
protobuf-compiler \
|
||||
protobuf-compiler-grpc \
|
||||
pybind11-dev \
|
||||
libhiredis-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libczmq4 \
|
||||
libczmq-dev \
|
||||
libfabric-dev \
|
||||
linux-libc-dev \
|
||||
# Package building tools
|
||||
devscripts \
|
||||
debhelper \
|
||||
fakeroot \
|
||||
dkms \
|
||||
check \
|
||||
libsubunit0 \
|
||||
libsubunit-dev \
|
||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean
|
||||
|
||||
# Replace pip global cache if specified
|
||||
RUN if [ -n "${PIP_DEFAULT_INDEX}" ]; then \
|
||||
python3 -m pip config set global.index-url ${PIP_DEFAULT_INDEX}; \
|
||||
fi
|
||||
|
||||
# GDRCopy installation
|
||||
RUN mkdir -p /tmp/gdrcopy && cd /tmp \
|
||||
&& curl --retry 3 --retry-delay 2 -fsSL -o v${GDRCOPY_VERSION}.tar.gz \
|
||||
https://${GITHUB_ARTIFACTORY}/NVIDIA/gdrcopy/archive/refs/tags/v${GDRCOPY_VERSION}.tar.gz \
|
||||
&& tar -xzf v${GDRCOPY_VERSION}.tar.gz && rm v${GDRCOPY_VERSION}.tar.gz \
|
||||
&& cd gdrcopy-${GDRCOPY_VERSION}/packages \
|
||||
&& CUDA=/usr/local/cuda ./build-deb-packages.sh \
|
||||
&& dpkg -i gdrdrv-dkms_*.deb libgdrapi_*.deb gdrcopy-tests_*.deb gdrcopy_*.deb \
|
||||
&& cd / && rm -rf /tmp/gdrcopy
|
||||
|
||||
# Fix DeepEP IBGDA symlink
|
||||
RUN ln -sf /usr/lib/$(uname -m)-linux-gnu/libmlx5.so.1 /usr/lib/$(uname -m)-linux-gnu/libmlx5.so
|
||||
|
||||
# Set up locale
|
||||
RUN locale-gen en_US.UTF-8
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US:en \
|
||||
LC_ALL=en_US.UTF-8
|
||||
|
||||
########################################################
|
||||
########## Framework Development Image ################
|
||||
########################################################
|
||||
|
||||
# Copy local source if building from local
|
||||
FROM scratch AS local_src
|
||||
COPY . /src
|
||||
|
||||
FROM base AS framework
|
||||
|
||||
ARG BRANCH_TYPE
|
||||
ARG BUILD_TYPE
|
||||
ARG CUDA_VERSION
|
||||
ARG BUILD_AND_DOWNLOAD_PARALLEL
|
||||
ARG SGL_KERNEL_VERSION
|
||||
ARG SGL_VERSION
|
||||
ARG USE_LATEST_SGLANG
|
||||
ARG INSTALL_FLASHINFER_JIT_CACHE
|
||||
ARG FLASHINFER_VERSION
|
||||
ARG GRACE_BLACKWELL
|
||||
ARG GRACE_BLACKWELL_DEEPEP_BRANCH
|
||||
ARG DEEPEP_COMMIT
|
||||
ARG TRITON_LANG_COMMIT
|
||||
ARG GITHUB_ARTIFACTORY
|
||||
|
||||
WORKDIR /sgl-workspace
|
||||
|
||||
# Install SGLang
|
||||
COPY --from=local_src /src /tmp/local_src
|
||||
RUN if [ "$BRANCH_TYPE" = "local" ]; then \
|
||||
cp -r /tmp/local_src /sgl-workspace/sglang; \
|
||||
elif [ "$USE_LATEST_SGLANG" = "1" ]; then \
|
||||
git clone --depth=1 https://github.com/sgl-project/sglang.git /sgl-workspace/sglang; \
|
||||
elif [ -z "$SGL_VERSION" ]; then \
|
||||
echo "ERROR: SGL_VERSION must be set when USE_LATEST_SGLANG=0 and BRANCH_TYPE!=local" && exit 1; \
|
||||
else \
|
||||
git clone --depth=1 --branch v${SGL_VERSION} https://github.com/sgl-project/sglang.git /sgl-workspace/sglang; \
|
||||
fi \
|
||||
&& rm -rf /tmp/local_src
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python3 -m pip install --upgrade pip setuptools wheel html5lib six \
|
||||
&& cd sglang \
|
||||
&& case "$CUDA_VERSION" in \
|
||||
12.6.1) CUINDEX=126 ;; \
|
||||
12.8.1) CUINDEX=128 ;; \
|
||||
12.9.1) CUINDEX=129 ;; \
|
||||
13.0.1) CUINDEX=130 ;; \
|
||||
*) echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1 ;; \
|
||||
esac \
|
||||
&& if [ "$CUDA_VERSION" = "12.6.1" ]; then \
|
||||
python3 -m pip install https://${GITHUB_ARTIFACTORY}/sgl-project/whl/releases/download/v${SGL_KERNEL_VERSION}/sglang_kernel-${SGL_KERNEL_VERSION}+cu124-cp310-abi3-manylinux2014_$(uname -m).whl --force-reinstall --no-deps \
|
||||
; \
|
||||
elif [ "$CUDA_VERSION" = "12.8.1" ] || [ "$CUDA_VERSION" = "12.9.1" ]; then \
|
||||
python3 -m pip install sglang-kernel==${SGL_KERNEL_VERSION} \
|
||||
; \
|
||||
elif [ "$CUDA_VERSION" = "13.0.1" ]; then \
|
||||
python3 -m pip install https://github.com/sgl-project/whl/releases/download/v${SGL_KERNEL_VERSION}/sglang_kernel-${SGL_KERNEL_VERSION}+cu130-cp310-abi3-manylinux2014_$(uname -m).whl --force-reinstall --no-deps \
|
||||
; \
|
||||
else \
|
||||
echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1 \
|
||||
; \
|
||||
fi \
|
||||
&& python3 -m pip install -e "python[${BUILD_TYPE}]" --extra-index-url https://download.pytorch.org/whl/cu${CUINDEX} \
|
||||
&& if [ "$INSTALL_FLASHINFER_JIT_CACHE" = "1" ]; then \
|
||||
python3 -m pip install flashinfer-jit-cache==${FLASHINFER_VERSION} --index-url https://flashinfer.ai/whl/cu${CUINDEX} ; \
|
||||
fi \
|
||||
&& FLASHINFER_CUBIN_DOWNLOAD_THREADS=${BUILD_AND_DOWNLOAD_PARALLEL} FLASHINFER_LOGGING_LEVEL=warning python3 -m flashinfer --download-cubin
|
||||
|
||||
# DeepEP
|
||||
# We use Tom's DeepEP fork for GB200 for now; the 1fd57b0276311d035d16176bb0076426166e52f3 commit is https://github.com/fzyzcjy/DeepEP/tree/gb200_blog_part_2
|
||||
# TODO: move from Tom's branch to DeepEP hybrid-ep branch
|
||||
# We use the nvshmem version that ships with torch 2.9.1
|
||||
# CU12 uses 3.3.20 and CU13 uses 3.3.24
|
||||
RUN set -eux; \
|
||||
if [ "$GRACE_BLACKWELL" = "1" ]; then \
|
||||
git clone https://github.com/fzyzcjy/DeepEP.git && \
|
||||
cd DeepEP && \
|
||||
git checkout ${GRACE_BLACKWELL_DEEPEP_BRANCH} && \
|
||||
sed -i 's/#define NUM_CPU_TIMEOUT_SECS 100/#define NUM_CPU_TIMEOUT_SECS 1000/' csrc/kernels/configs.cuh && \
|
||||
sed -i 's/#define NUM_TIMEOUT_CYCLES 200000000000ull/#define NUM_TIMEOUT_CYCLES 2000000000000ull/' csrc/kernels/configs.cuh && \
|
||||
cd .. ; \
|
||||
elif [ "$HOPPER_SBO" = "1" ]; then \
|
||||
git clone https://github.com/deepseek-ai/DeepEP.git -b antgroup-opt && \
|
||||
cd DeepEP && \
|
||||
git checkout ${HOPPER_SBO_DEEPEP_COMMIT} && \
|
||||
sed -i 's/#define NUM_CPU_TIMEOUT_SECS 100/#define NUM_CPU_TIMEOUT_SECS 1000/' csrc/kernels/configs.cuh && \
|
||||
sed -i 's/#define NUM_TIMEOUT_CYCLES 200000000000ull/#define NUM_TIMEOUT_CYCLES 2000000000000ull/' csrc/kernels/configs.cuh && \
|
||||
cd .. ; \
|
||||
else \
|
||||
curl --retry 3 --retry-delay 2 -fsSL -o ${DEEPEP_COMMIT}.zip \
|
||||
https://${GITHUB_ARTIFACTORY}/deepseek-ai/DeepEP/archive/${DEEPEP_COMMIT}.zip && \
|
||||
unzip -q ${DEEPEP_COMMIT}.zip && rm ${DEEPEP_COMMIT}.zip && mv DeepEP-${DEEPEP_COMMIT} DeepEP && cd DeepEP && \
|
||||
sed -i 's/#define NUM_CPU_TIMEOUT_SECS 100/#define NUM_CPU_TIMEOUT_SECS 1000/' csrc/kernels/configs.cuh && \
|
||||
sed -i 's/#define NUM_TIMEOUT_CYCLES 200000000000ull/#define NUM_TIMEOUT_CYCLES 2000000000000ull/' csrc/kernels/configs.cuh && \
|
||||
cd .. ; \
|
||||
fi
|
||||
|
||||
# Install DeepEP
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
cd /sgl-workspace/DeepEP && \
|
||||
case "$CUDA_VERSION" in \
|
||||
12.6.1) \
|
||||
CHOSEN_TORCH_CUDA_ARCH_LIST='9.0' \
|
||||
;; \
|
||||
12.8.1) \
|
||||
# FIXED: 12.8.1 does NOT support Blackwell 10.3 \
|
||||
CHOSEN_TORCH_CUDA_ARCH_LIST='9.0;10.0' \
|
||||
;; \
|
||||
12.9.1|13.0.1) \
|
||||
# 12.9.1+ properly supports Blackwell 10.3 \
|
||||
CHOSEN_TORCH_CUDA_ARCH_LIST='9.0;10.0;10.3' \
|
||||
;; \
|
||||
*) \
|
||||
echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1 \
|
||||
;; \
|
||||
esac && \
|
||||
if [ "${CUDA_VERSION%%.*}" = "13" ]; then \
|
||||
sed -i "/^ include_dirs = \['csrc\/'\]/a\ include_dirs.append('${CUDA_HOME}/include/cccl')" setup.py; \
|
||||
fi && \
|
||||
TORCH_CUDA_ARCH_LIST="${CHOSEN_TORCH_CUDA_ARCH_LIST}" MAX_JOBS=${BUILD_AND_DOWNLOAD_PARALLEL} pip install --no-build-isolation .
|
||||
|
||||
# Install Mooncake
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
CUDA_MAJOR="${CUDA_VERSION%%.*}" && \
|
||||
if [ "$CUDA_MAJOR" -ge 13 ]; then \
|
||||
echo "CUDA >= 13, installing mooncake-transfer-engine from source code"; \
|
||||
git clone --branch v${MOONCAKE_VERSION} --depth 1 https://github.com/kvcache-ai/Mooncake.git && \
|
||||
cd Mooncake && \
|
||||
bash dependencies.sh && \
|
||||
mkdir -p build && \
|
||||
cd build && \
|
||||
cmake .. ${MOONCAKE_COMPILE_ARG} && \
|
||||
make -j$(nproc) && \
|
||||
make install; \
|
||||
else \
|
||||
echo "CUDA < 13, installing mooncake-transfer-engine from pip"; \
|
||||
python3 -m pip install mooncake-transfer-engine==${MOONCAKE_VERSION}; \
|
||||
fi
|
||||
# Install essential Python packages
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python3 -m pip install \
|
||||
datamodel_code_generator \
|
||||
pre-commit \
|
||||
pytest \
|
||||
black \
|
||||
isort \
|
||||
icdiff \
|
||||
uv \
|
||||
wheel \
|
||||
scikit-build-core \
|
||||
nixl \
|
||||
py-spy \
|
||||
cubloaty \
|
||||
google-cloud-storage
|
||||
|
||||
# Build and install sgl-model-gateway (install Rust, build, then remove Rust toolchain)
|
||||
# Cleanup runs unconditionally via trap to ensure Rust artifacts don't bloat the layer
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
cleanup() { rm -rf /root/.cargo /root/.rustup /sgl-workspace/sglang/sgl-model-gateway/target /sgl-workspace/sglang/sgl-model-gateway/bindings/python/target /sgl-workspace/sglang/sgl-model-gateway/bindings/python/dist; sed -i '/\.cargo\/env/d' /root/.profile /root/.bashrc 2>/dev/null; } \
|
||||
&& trap cleanup EXIT \
|
||||
&& curl --proto '=https' --tlsv1.2 --retry 3 --retry-delay 2 -sSf https://sh.rustup.rs | sh -s -- -y \
|
||||
&& export PATH="/root/.cargo/bin:${PATH}" \
|
||||
&& rustc --version && cargo --version \
|
||||
&& python3 -m pip install maturin \
|
||||
&& cd /sgl-workspace/sglang/sgl-model-gateway/bindings/python \
|
||||
&& ulimit -n 65536 && maturin build --release --features vendored-openssl --out dist \
|
||||
&& python3 -m pip install --force-reinstall dist/*.whl \
|
||||
&& cd /sgl-workspace/sglang/sgl-model-gateway \
|
||||
&& cargo build --release --bin sgl-model-gateway --features vendored-openssl \
|
||||
&& cp target/release/sgl-model-gateway /usr/local/bin/sgl-model-gateway
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python3 -m pip install "nvidia-cutlass-dsl>=4.4.1" "nvidia-cutlass-dsl-libs-base>=4.4.1" --force-reinstall --no-deps;
|
||||
|
||||
# Patching packages for CUDA 12/13 compatibility
|
||||
# TODO: Remove when torch version covers these packages
|
||||
RUN --mount=type=cache,target=/root/.cache/pip if [ "${CUDA_VERSION%%.*}" = "12" ]; then \
|
||||
python3 -m pip install nvidia-nccl-cu12==2.28.3 --force-reinstall --no-deps ; \
|
||||
python3 -m pip install nvidia-cudnn-cu12==9.16.0.29 --force-reinstall --no-deps ; \
|
||||
python3 -m pip install cuda-python==12.9 ; \
|
||||
elif [ "${CUDA_VERSION%%.*}" = "13" ]; then \
|
||||
python3 -m pip install nvidia-nccl-cu13==2.28.3 --force-reinstall --no-deps ; \
|
||||
python3 -m pip install nvidia-cudnn-cu13==9.16.0.29 --force-reinstall --no-deps ; \
|
||||
python3 -m pip install nvidia-cublas==13.1.0.3 --force-reinstall --no-deps ; \
|
||||
python3 -m pip install nixl-cu13 --no-deps ; \
|
||||
python3 -m pip install cuda-python==13.2.0 ; \
|
||||
fi
|
||||
|
||||
# Install development tools
|
||||
RUN --mount=type=cache,target=/var/cache/apt,id=framework-apt \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
gdb \
|
||||
ninja-build \
|
||||
vim \
|
||||
tmux \
|
||||
htop \
|
||||
zsh \
|
||||
tree \
|
||||
silversearcher-ag \
|
||||
cloc \
|
||||
pkg-config \
|
||||
bear \
|
||||
less \
|
||||
rdma-core \
|
||||
openssh-server \
|
||||
gnuplot \
|
||||
infiniband-diags \
|
||||
perftest \
|
||||
ibverbs-providers \
|
||||
libibumad3 \
|
||||
libibverbs1 \
|
||||
libnl-3-200 \
|
||||
libnl-route-3-200 \
|
||||
librdmacm1 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean
|
||||
|
||||
# Install NVIDIA development tools
|
||||
RUN --mount=type=cache,target=/var/cache/apt,id=framework-apt \
|
||||
apt update -y \
|
||||
&& apt install -y --no-install-recommends gnupg \
|
||||
&& echo "deb http://developer.download.nvidia.com/devtools/repos/ubuntu2004/$(if [ "$(uname -m)" = "aarch64" ]; then echo "arm64"; else echo "amd64"; fi) /" | tee /etc/apt/sources.list.d/nvidia-devtools.list \
|
||||
&& apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/$(if [ "$(uname -m)" = "aarch64" ]; then echo "arm64"; else echo "x86_64"; fi)/7fa2af80.pub \
|
||||
&& apt update -y \
|
||||
&& apt install -y --no-install-recommends nsight-systems-cli \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install minimal Python dev packages
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python3 -m pip install --break-system-packages \
|
||||
pytest \
|
||||
black \
|
||||
isort \
|
||||
icdiff \
|
||||
scikit-build-core \
|
||||
uv \
|
||||
pre-commit \
|
||||
pandas \
|
||||
matplotlib \
|
||||
tabulate \
|
||||
termplotlib
|
||||
|
||||
# diff-so-fancy
|
||||
RUN curl --retry 3 --retry-delay 2 -LSso /usr/local/bin/diff-so-fancy \
|
||||
https://${GITHUB_ARTIFACTORY}/so-fancy/diff-so-fancy/releases/download/v1.4.4/diff-so-fancy \
|
||||
&& chmod +x /usr/local/bin/diff-so-fancy
|
||||
|
||||
# clang-format
|
||||
RUN curl --retry 3 --retry-delay 2 -LSso /usr/local/bin/clang-format \
|
||||
https://${GITHUB_ARTIFACTORY}/muttleyxd/clang-tools-static-binaries/releases/download/master-32d3ac78/clang-format-16_linux-amd64 \
|
||||
&& chmod +x /usr/local/bin/clang-format
|
||||
|
||||
# clangd
|
||||
RUN curl --retry 3 --retry-delay 2 -fsSL -o clangd.zip \
|
||||
https://${GITHUB_ARTIFACTORY}/clangd/clangd/releases/download/18.1.3/clangd-linux-18.1.3.zip \
|
||||
&& unzip -q clangd.zip \
|
||||
&& cp -r clangd_18.1.3/bin/* /usr/local/bin/ \
|
||||
&& cp -r clangd_18.1.3/lib/* /usr/local/lib/ \
|
||||
&& rm -rf clangd_18.1.3 clangd.zip
|
||||
|
||||
# CMake
|
||||
RUN CMAKE_VERSION=3.31.1 \
|
||||
&& ARCH=$(uname -m) \
|
||||
&& CMAKE_INSTALLER="cmake-${CMAKE_VERSION}-linux-${ARCH}" \
|
||||
&& curl --retry 3 --retry-delay 2 -fsSL -o "${CMAKE_INSTALLER}.tar.gz" \
|
||||
"https://${GITHUB_ARTIFACTORY}/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_INSTALLER}.tar.gz" \
|
||||
&& tar -xzf "${CMAKE_INSTALLER}.tar.gz" \
|
||||
&& cp -r "${CMAKE_INSTALLER}/bin/"* /usr/local/bin/ \
|
||||
&& cp -r "${CMAKE_INSTALLER}/share/"* /usr/local/share/ \
|
||||
&& rm -rf "${CMAKE_INSTALLER}" "${CMAKE_INSTALLER}.tar.gz"
|
||||
|
||||
# Install just
|
||||
RUN curl --proto '=https' --tlsv1.2 --retry 3 --retry-delay 2 -sSf https://just.systems/install.sh | \
|
||||
sed "s|https://github.com|https://${GITHUB_ARTIFACTORY}|g" | \
|
||||
bash -s -- --tag 1.42.4 --to /usr/local/bin
|
||||
|
||||
# Add yank script
|
||||
COPY --chown=root:root --chmod=755 docker/configs/yank /usr/local/bin/yank
|
||||
|
||||
# Install oh-my-zsh and plugins
|
||||
RUN sh -c "$(curl --retry 3 --retry-delay 2 -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \
|
||||
&& git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \
|
||||
&& git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
||||
|
||||
# These configs are optional; users can override them by mounting their own files
|
||||
COPY docker/configs/opt/.vimrc /opt/sglang/.vimrc
|
||||
COPY docker/configs/opt/.tmux.conf /opt/sglang/.tmux.conf
|
||||
COPY docker/configs/opt/.gitconfig /opt/sglang/.gitconfig
|
||||
|
||||
# Configure development environment
|
||||
COPY docker/configs/.zshrc /root/.zshrc
|
||||
|
||||
# Fix Triton to use system ptxas for Blackwell (sm_103a) support (CUDA 13+ only)
|
||||
RUN if [ "${CUDA_VERSION%%.*}" = "13" ] && [ -d /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin ]; then \
|
||||
rm -f /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas && \
|
||||
ln -s /usr/local/cuda/bin/ptxas /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas; \
|
||||
fi
|
||||
|
||||
RUN python3 -m pip install --upgrade "urllib3>=2.6.3" "pillow>=12.1.1"
|
||||
|
||||
# Set workspace directory
|
||||
WORKDIR /sgl-workspace/sglang
|
||||
|
||||
########################################################
|
||||
########## Runtime Image ##############################
|
||||
########################################################
|
||||
#
|
||||
# PURPOSE: Production runtime environment with JIT support
|
||||
#
|
||||
# This stage creates a production-ready image containing:
|
||||
# - Pre-compiled SGLang and DeepEP components
|
||||
# - Full CUDA toolchain for JIT compilation (DeepGEMM, Triton, FlashInfer)
|
||||
# - Optimized for inference workloads and deployment
|
||||
# - Smaller than framework (no dev tools like vim, tmux, nsight, etc.)
|
||||
#
|
||||
# Use this stage when you need:
|
||||
# - Production deployment of SGLang
|
||||
# - JIT compilation support for FP8/microscaling kernels
|
||||
# - Ready-to-run inference server environment
|
||||
#
|
||||
# Note: Uses devel base for complete NVCC toolchain required by DeepGEMM JIT
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu24.04 AS runtime
|
||||
|
||||
ARG CUDA_VERSION
|
||||
ARG TARGETARCH
|
||||
ARG GDRCOPY_VERSION=2.5.1
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
CUDA_HOME=/usr/local/cuda \
|
||||
GDRCOPY_HOME=/usr/src/gdrdrv-${GDRCOPY_VERSION}/
|
||||
|
||||
# Add GKE default lib and bin locations + CUDA compiler paths for FlashInfer JIT
|
||||
ENV PATH="${PATH}:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/cuda/nvvm/bin" \
|
||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64"
|
||||
|
||||
# Install runtime dependencies (devel base provides gcc/g++/build tools)
|
||||
RUN --mount=type=cache,target=/var/cache/apt,id=runtime-apt \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
# Python runtime
|
||||
software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends --allow-change-held-packages \
|
||||
python3.12-full \
|
||||
python3.12-dev \
|
||||
wget \
|
||||
# Core system utilities
|
||||
ca-certificates \
|
||||
netcat-openbsd \
|
||||
curl \
|
||||
git \
|
||||
# Runtime libraries
|
||||
libopenmpi3 \
|
||||
libnuma1 \
|
||||
libibverbs1 \
|
||||
libibumad3 \
|
||||
librdmacm1 \
|
||||
libnl-3-200 \
|
||||
libnl-route-3-200 \
|
||||
ibverbs-providers \
|
||||
libgoogle-glog0v6t64 \
|
||||
libunwind8 \
|
||||
libboost-system1.83.0 \
|
||||
libboost-thread1.83.0 \
|
||||
libboost-filesystem1.83.0 \
|
||||
libgrpc++1.51t64 \
|
||||
libprotobuf32t64 \
|
||||
libhiredis1.1.0 \
|
||||
libcurl4 \
|
||||
libczmq4 \
|
||||
libfabric1 \
|
||||
libssl3 \
|
||||
# RDMA runtime
|
||||
rdma-core \
|
||||
infiniband-diags \
|
||||
perftest \
|
||||
# Build tools for JIT compilation
|
||||
ninja-build \
|
||||
# NCCL packages needed for pynccl_allocator JIT compilation (-lnccl)
|
||||
libnccl2 \
|
||||
libnccl-dev \
|
||||
# GPG key verification
|
||||
gnupg2 \
|
||||
linux-libc-dev \
|
||||
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 \
|
||||
&& update-alternatives --set python3 /usr/bin/python3.12 \
|
||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python \
|
||||
&& wget -q https://bootstrap.pypa.io/get-pip.py \
|
||||
&& python3 get-pip.py --break-system-packages \
|
||||
&& rm get-pip.py \
|
||||
# Allow pip to install packages globally (PEP 668 workaround for Ubuntu 24.04)
|
||||
&& python3 -m pip config set global.break-system-packages true \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean
|
||||
|
||||
# Set up locale
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends locales \
|
||||
&& locale-gen en_US.UTF-8 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US:en \
|
||||
LC_ALL=en_US.UTF-8
|
||||
|
||||
# Copy Python site-packages from framework (contains all built packages)
|
||||
COPY --from=framework /usr/local/lib/python3.12/dist-packages /usr/local/lib/python3.12/dist-packages
|
||||
|
||||
# Copy SGLang workspace
|
||||
COPY --from=framework /sgl-workspace /sgl-workspace
|
||||
|
||||
# Fix Triton to use system ptxas for Blackwell (sm_103a) support (CUDA 13+ only)
|
||||
RUN if [ "${CUDA_VERSION%%.*}" = "13" ] && [ -d /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin ]; then \
|
||||
rm -f /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas && \
|
||||
ln -s /usr/local/cuda/bin/ptxas /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas; \
|
||||
fi
|
||||
|
||||
# Copy GDRCopy runtime libraries (but not the build artifacts)
|
||||
COPY --from=framework /usr/lib/libgdrapi.so* /usr/lib/
|
||||
COPY --from=framework /usr/bin/gdrcopy_* /usr/bin/
|
||||
COPY --from=framework /usr/src/gdrdrv-2.5.1 /usr/src/gdrdrv-2.5.1
|
||||
|
||||
# Fix DeepEP IBGDA symlink in runtime
|
||||
RUN ln -sf /usr/lib/$(uname -m)-linux-gnu/libmlx5.so.1 /usr/lib/$(uname -m)-linux-gnu/libmlx5.so
|
||||
|
||||
WORKDIR /sgl-workspace/sglang
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/bash"]
|
||||
35
third_party/sglang/docker/compose.yaml
vendored
Normal file
35
third_party/sglang/docker/compose.yaml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
services:
|
||||
sglang:
|
||||
image: lmsysorg/sglang:latest
|
||||
container_name: sglang
|
||||
volumes:
|
||||
- ${HOME}/.cache/huggingface:/root/.cache/huggingface
|
||||
# If you use modelscope, you need mount this directory
|
||||
# - ${HOME}/.cache/modelscope:/root/.cache/modelscope
|
||||
restart: always
|
||||
network_mode: host # required by RDMA
|
||||
privileged: true # required by RDMA
|
||||
# Or you can only publish port 30000
|
||||
# ports:
|
||||
# - 30000:30000
|
||||
environment:
|
||||
- HF_TOKEN=<secret>
|
||||
# if you use modelscope to download model, you need set this environment
|
||||
# - SGLANG_USE_MODELSCOPE=true
|
||||
entrypoint: python3 -m sglang.launch_server
|
||||
command: --model-path meta-llama/Llama-3.1-8B-Instruct
|
||||
--host 0.0.0.0
|
||||
--port 30000
|
||||
ulimits:
|
||||
memlock: -1
|
||||
stack: 67108864
|
||||
ipc: host
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:30000/health || exit 1"]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
27
third_party/sglang/docker/configs/.zshrc
vendored
Normal file
27
third_party/sglang/docker/configs/.zshrc
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export ZSH="/root/.oh-my-zsh"
|
||||
|
||||
# Theme
|
||||
ZSH_THEME="robbyrussell"
|
||||
|
||||
# Plugins
|
||||
plugins=(
|
||||
git
|
||||
z
|
||||
zsh-autosuggestions
|
||||
zsh-syntax-highlighting
|
||||
)
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
# Aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
alias vi='vim'
|
||||
|
||||
# Enhanced history
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
setopt INC_APPEND_HISTORY
|
||||
30
third_party/sglang/docker/configs/opt/.gitconfig
vendored
Normal file
30
third_party/sglang/docker/configs/opt/.gitconfig
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
[core]
|
||||
editor = vim
|
||||
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
|
||||
pager = diff-so-fancy | less --tabs=4 -RFX
|
||||
|
||||
[color]
|
||||
ui = true
|
||||
|
||||
[color "diff-highlight"]
|
||||
oldNormal = red bold
|
||||
oldHighlight = red bold 52
|
||||
newNormal = green bold
|
||||
newHighlight = green bold 22
|
||||
|
||||
[color "diff"]
|
||||
meta = 11
|
||||
frag = magenta bold
|
||||
commit = yellow bold
|
||||
old = red bold
|
||||
new = green bold
|
||||
whitespace = red reverse
|
||||
|
||||
[alias]
|
||||
lg = log --color --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%C(auto)%d%Creset' --abbrev-commit --
|
||||
|
||||
[http]
|
||||
sslVerify = false
|
||||
|
||||
[pull]
|
||||
rebase = true
|
||||
27
third_party/sglang/docker/configs/opt/.tmux.conf
vendored
Normal file
27
third_party/sglang/docker/configs/opt/.tmux.conf
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# Pane border styling
|
||||
set -g pane-border-style fg='#742727',bg=black
|
||||
set -g pane-active-border-style fg=red,bg=black
|
||||
|
||||
# Status bar styling
|
||||
set -g status-style bg='#0C8A92',fg=black
|
||||
|
||||
# Change prefix key to backtick
|
||||
set-option -g prefix `
|
||||
unbind C-b
|
||||
bind-key ` send-prefix
|
||||
|
||||
# Split panes using - and = with current path
|
||||
unbind '"'
|
||||
bind - splitw -v -c '#{pane_current_path}'
|
||||
unbind '%'
|
||||
bind = splitw -h -c '#{pane_current_path}'
|
||||
|
||||
# Vi mode settings
|
||||
bind-key -T copy-mode-vi Y send-keys -X copy-pipe 'yank > #{pane_tty}'
|
||||
set-window-option -g mode-keys vi
|
||||
|
||||
# Other settings
|
||||
set-option -g escape-time 0
|
||||
set-option -g base-index 1
|
||||
set-window-option -g mouse on
|
||||
set -g history-limit 100000
|
||||
45
third_party/sglang/docker/configs/opt/.vimrc
vendored
Normal file
45
third_party/sglang/docker/configs/opt/.vimrc
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
function! Yank(text) abort
|
||||
let escape = system('yank', a:text)
|
||||
if v:shell_error
|
||||
echoerr escape
|
||||
else
|
||||
call writefile([escape], '/dev/tty', 'b')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
noremap <silent> <Leader>y y:<C-U>call Yank(@0)<CR>
|
||||
|
||||
" automatically run yank(1) whenever yanking in Vim
|
||||
function! CopyYank() abort
|
||||
call Yank(join(v:event.regcontents, "\n"))
|
||||
endfunction
|
||||
|
||||
autocmd TextYankPost * call CopyYank()
|
||||
|
||||
" Basic settings
|
||||
set number
|
||||
syntax on
|
||||
set mouse=a
|
||||
filetype indent on
|
||||
|
||||
" Indentation
|
||||
set autoindent nosmartindent
|
||||
set smarttab
|
||||
set expandtab
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
|
||||
" Visual guides
|
||||
set colorcolumn=120
|
||||
highlight ColorColumn ctermbg=5
|
||||
|
||||
" Status line
|
||||
set laststatus=2
|
||||
set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
|
||||
|
||||
" Backspace behavior
|
||||
set backspace=2
|
||||
|
||||
" Encoding
|
||||
set encoding=utf-8
|
||||
set fileencoding=utf-8
|
||||
12
third_party/sglang/docker/configs/yank
vendored
Executable file
12
third_party/sglang/docker/configs/yank
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
put() {
|
||||
esc=$1
|
||||
test -n "$TMUX" -o -z "${TERM##screen*}" && esc="\033Ptmux;\033$esc\033\\"
|
||||
printf "$esc"
|
||||
}
|
||||
put "\033]52;c;!\a"
|
||||
buf=$( cat "$@" )
|
||||
len=$( printf %s "$buf" | wc -c ) max=74994
|
||||
test $len -gt $max && echo "$0: input is $(( len - max )) bytes too long" >&2
|
||||
put "\033]52;c;$( printf %s "$buf" | head -c $max | base64 | tr -d '\r\n' )\a"
|
||||
test -n "$TMUX" && tmux set-buffer "$buf" ||:
|
||||
104
third_party/sglang/docker/diffusion.Dockerfile
vendored
Normal file
104
third_party/sglang/docker/diffusion.Dockerfile
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
FROM nvidia/cuda:12.8.0-cudnn-devel-ubuntu22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
WORKDIR /sgl-workspace/sglang
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
wget \
|
||||
git \
|
||||
ca-certificates \
|
||||
openssh-server \
|
||||
zsh \
|
||||
vim \
|
||||
curl \
|
||||
gcc-11 \
|
||||
g++-11 \
|
||||
clang-11 \
|
||||
libnuma1 libnuma-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install oh-my-zsh and plugins
|
||||
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \
|
||||
&& git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \
|
||||
&& git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
||||
|
||||
|
||||
# Set up C++20 compilers for ThunderKittens
|
||||
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11
|
||||
|
||||
# Set CUDA environment variables
|
||||
ENV CUDA_HOME=/usr/local/cuda-12.8
|
||||
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
||||
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
|
||||
|
||||
# Install uv and source its environment
|
||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
||||
echo 'source $HOME/.local/bin/env' >> /root/.zshrc
|
||||
|
||||
# Copy just the pyproject.toml first to leverage Docker cache
|
||||
COPY python/pyproject.toml python/
|
||||
|
||||
# Create a dummy README to satisfy the installation
|
||||
RUN mkdir -p python && echo "# Placeholder" > python/README.md
|
||||
|
||||
# Create and activate virtual environment with specific Python version and seed
|
||||
RUN source $HOME/.local/bin/env && \
|
||||
uv venv --python 3.12 --seed /opt/venv && \
|
||||
source /opt/venv/bin/activate && \
|
||||
uv pip install nvitop && \
|
||||
uv pip install --no-cache-dir --upgrade pip && \
|
||||
uv pip install --no-cache-dir --prerelease=allow ./python[diffusion]
|
||||
|
||||
COPY . .
|
||||
|
||||
# Install dependencies using uv and set up shell configuration
|
||||
RUN source $HOME/.local/bin/env && \
|
||||
source /opt/venv/bin/activate && \
|
||||
git config --unset-all http.https://github.com/.extraheader || true && \
|
||||
echo 'source /opt/venv/bin/activate' >> /root/.zshrc && \
|
||||
echo 'if [ -n "$ZSH_VERSION" ] && [ -f ~/.zshrc ]; then . ~/.zshrc; elif [ -f ~/.bashrc ]; then . ~/.bashrc; fi' > /root/.profile
|
||||
|
||||
# Set PATH to include venv bin
|
||||
ENV PATH=/opt/venv/bin:$PATH
|
||||
|
||||
# Configure zsh
|
||||
COPY --chown=root:root <<-"EOF" /root/.zshrc
|
||||
export ZSH="/root/.oh-my-zsh"
|
||||
|
||||
source $HOME/.local/bin/env
|
||||
source /opt/venv/bin/activate
|
||||
|
||||
## Theme
|
||||
ZSH_THEME="robbyrussell"
|
||||
|
||||
## Plugins
|
||||
plugins=(
|
||||
git
|
||||
z
|
||||
zsh-autosuggestions
|
||||
zsh-syntax-highlighting
|
||||
)
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
## Aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
alias vi='vim'
|
||||
|
||||
## Enhanced history
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
setopt INC_APPEND_HISTORY
|
||||
EOF
|
||||
|
||||
|
||||
EXPOSE 22
|
||||
|
||||
CMD ["/bin/zsh"]
|
||||
77
third_party/sglang/docker/gateway.Dockerfile
vendored
Normal file
77
third_party/sglang/docker/gateway.Dockerfile
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
######################## BASE IMAGE ##########################
|
||||
FROM ubuntu:24.04 AS base
|
||||
|
||||
ARG PYTHON_VERSION=3.12
|
||||
|
||||
# set the environment variables
|
||||
ENV PATH="/root/.local/bin:${PATH}"
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# uv environment variables
|
||||
ENV UV_HTTP_TIMEOUT=500
|
||||
ENV VIRTUAL_ENV="/opt/venv"
|
||||
ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python
|
||||
ENV UV_LINK_MODE="copy"
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
|
||||
# install dependencies
|
||||
RUN apt update -y \
|
||||
&& apt install -y curl \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt clean
|
||||
|
||||
# install uv
|
||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
# install python
|
||||
RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV}
|
||||
|
||||
FROM scratch AS local_src
|
||||
COPY . /src
|
||||
|
||||
######################### BUILD IMAGE #########################
|
||||
FROM base AS build-image
|
||||
|
||||
# set the environment variables
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
|
||||
# install dependencies
|
||||
RUN apt update -y \
|
||||
&& apt install -y git build-essential libssl-dev pkg-config protobuf-compiler \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt clean
|
||||
|
||||
# install rustup from rustup.rs
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
|
||||
&& rustc --version && cargo --version && protoc --version
|
||||
|
||||
# copy source code
|
||||
COPY --from=local_src /src /opt/sglang
|
||||
|
||||
# working directory
|
||||
WORKDIR /opt/sglang/sgl-model-gateway
|
||||
|
||||
# install maturin and build the wheel with vendored OpenSSL
|
||||
RUN uv pip install maturin \
|
||||
&& cargo clean \
|
||||
&& rm -rf bindings/python/dist/ \
|
||||
&& cd bindings/python \
|
||||
&& ulimit -n 65536 && maturin build --release --features vendored-openssl --out dist \
|
||||
&& rm -rf /root/.cache
|
||||
|
||||
######################### ROUTER IMAGE #########################
|
||||
FROM base AS router-image
|
||||
|
||||
# Copy the built package from the build image
|
||||
COPY --from=build-image /opt/sglang/sgl-model-gateway/bindings/python/dist/*.whl dist/
|
||||
|
||||
# Build the package and install
|
||||
RUN uv pip install --force-reinstall dist/*.whl
|
||||
|
||||
# Clean up unnecessary files to reduce the image size
|
||||
RUN rm -rf /root/.cache dist/ \
|
||||
&& apt purge -y --auto-remove curl
|
||||
|
||||
# Set the entrypoint to the main command
|
||||
ENTRYPOINT ["python3", "-m", "sglang_router.launch_router"]
|
||||
103
third_party/sglang/docker/k8s-sglang-distributed-sts.yaml
vendored
Normal file
103
third_party/sglang/docker/k8s-sglang-distributed-sts.yaml
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
# Two Nodes Sglang example
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: distributed-sglang
|
||||
spec:
|
||||
replicas: 2 # number of nodes/pods to run distributed sglang
|
||||
selector:
|
||||
matchLabels:
|
||||
app: distributed-sglang
|
||||
serviceName: ""
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: distributed-sglang
|
||||
spec:
|
||||
containers:
|
||||
- name: sglang-container
|
||||
image: docker.io/lmsysorg/sglang:latest
|
||||
imagePullPolicy: Always # image may be replaced by official CI versioned image
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
# please modify the sglang serving arguments below, as necessary.
|
||||
# NOTE: the --expert-parallel-size is for MoE model like DeepSeek-R1
|
||||
args:
|
||||
- |
|
||||
python3 -m sglang.launch_server \
|
||||
--model /llm-folder \
|
||||
--dist-init-addr sglang-master-pod:5000 \
|
||||
--tensor-parallel-size 16 \
|
||||
--nnodes 2 \
|
||||
--node-rank $POD_INDEX \
|
||||
--trust-remote-code \
|
||||
--host 0.0.0.0 \
|
||||
--port 8000 \
|
||||
--enable-metrics \
|
||||
--expert-parallel-size 16
|
||||
env:
|
||||
- name: POD_INDEX # reflects the node-rank
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.labels['apps.kubernetes.io/pod-index']
|
||||
- name: NCCL_DEBUG
|
||||
value: INFO
|
||||
resources:
|
||||
limits:
|
||||
nvidia.com/gpu: "8"
|
||||
requests:
|
||||
volumeMounts:
|
||||
- mountPath: /dev/shm
|
||||
name: dshm
|
||||
- mountPath: /llm-folder
|
||||
name: llm
|
||||
securityContext:
|
||||
privileged: true # to leverage RDMA/InfiniBand device, co-work with HostNetwork=true
|
||||
hostNetwork: true
|
||||
volumes:
|
||||
- emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 10Gi
|
||||
name: dshm
|
||||
- hostPath:
|
||||
path: /llm-folder # replace with PVC or hostPath with your model weights
|
||||
type: DirectoryOrCreate
|
||||
name: llm
|
||||
#- persistentVolumeClaim:
|
||||
# claimName: llm-pvc
|
||||
# name: llm
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sglang-master-pod
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: distributed-sglang
|
||||
apps.kubernetes.io/pod-index: "0"
|
||||
ports:
|
||||
- name: dist-port
|
||||
port: 5000
|
||||
targetPort: 5000
|
||||
---
|
||||
# the serving service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sglang-serving-on-master
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
app: distributed-sglang
|
||||
apps.kubernetes.io/pod-index: "0"
|
||||
ports:
|
||||
- name: serving
|
||||
port: 8000
|
||||
targetPort: 8000
|
||||
- name: metrics
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
117
third_party/sglang/docker/k8s-sglang-service.yaml
vendored
Normal file
117
third_party/sglang/docker/k8s-sglang-service.yaml
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: llama-31-8b-sglang
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 30Gi
|
||||
storageClassName: default # change this to your preferred storage class
|
||||
volumeMode: Filesystem
|
||||
---
|
||||
apiVersion: node.k8s.io/v1
|
||||
kind: RuntimeClass
|
||||
metadata:
|
||||
name: nvidia
|
||||
handler: nvidia
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: meta-llama-31-8b-instruct-sglang
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: meta-llama-31-8b-instruct-sglang
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: meta-llama-31-8b-instruct-sglang
|
||||
model: meta-llama-31-8b-instruct
|
||||
engine: sglang
|
||||
spec:
|
||||
restartPolicy: Always
|
||||
runtimeClassName: nvidia
|
||||
containers:
|
||||
- name: meta-llama-31-8b-instruct-sglang
|
||||
image: docker.io/lmsysorg/sglang:latest
|
||||
imagePullPolicy: Always # IfNotPresent or Never
|
||||
ports:
|
||||
- containerPort: 30000
|
||||
command: ["python3", "-m", "sglang.launch_server"]
|
||||
args:
|
||||
[
|
||||
"--model-path",
|
||||
"meta-llama/Llama-3.1-8B-Instruct",
|
||||
"--host",
|
||||
"0.0.0.0",
|
||||
"--port",
|
||||
"30000",
|
||||
]
|
||||
env:
|
||||
- name: HF_TOKEN
|
||||
value: <secret>
|
||||
resources:
|
||||
limits:
|
||||
nvidia.com/gpu: 1
|
||||
cpu: 8
|
||||
memory: 40Gi
|
||||
requests:
|
||||
cpu: 2
|
||||
memory: 16Gi
|
||||
nvidia.com/gpu: 1
|
||||
volumeMounts:
|
||||
- name: shm
|
||||
mountPath: /dev/shm
|
||||
- name: hf-cache
|
||||
mountPath: /root/.cache/huggingface
|
||||
- name: localtime
|
||||
mountPath: /etc/localtime
|
||||
readOnly: true
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 30000
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health_generate
|
||||
port: 30000
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
volumes:
|
||||
- name: shm
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 10Gi
|
||||
- name: hf-cache
|
||||
persistentVolumeClaim:
|
||||
claimName: llama-31-8b-sglang
|
||||
- name: localtime
|
||||
hostPath:
|
||||
path: /etc/localtime
|
||||
type: File
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: meta-llama-31-8b-instruct-sglang
|
||||
spec:
|
||||
selector:
|
||||
app: meta-llama-31-8b-instruct-sglang
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80 # port on host
|
||||
targetPort: 30000 # port in container
|
||||
type: LoadBalancer # change to ClusterIP if needed
|
||||
104
third_party/sglang/docker/npu.Dockerfile
vendored
Normal file
104
third_party/sglang/docker/npu.Dockerfile
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
ARG CANN_VERSION=8.5.0
|
||||
ARG DEVICE_TYPE=a3
|
||||
ARG OS=ubuntu22.04
|
||||
ARG PYTHON_VERSION=py3.11
|
||||
|
||||
FROM quay.io/ascend/cann:$CANN_VERSION-$DEVICE_TYPE-$OS-$PYTHON_VERSION
|
||||
|
||||
# Update pip & apt sources
|
||||
ARG TARGETARCH
|
||||
ARG CANN_VERSION
|
||||
ARG DEVICE_TYPE
|
||||
ARG PIP_INDEX_URL="https://pypi.org/simple/"
|
||||
ARG APTMIRROR=""
|
||||
ARG PYTORCH_VERSION="2.8.0"
|
||||
ARG TORCHVISION_VERSION="0.23.0"
|
||||
ARG PTA_URL_ARM64="https://gitcode.com/Ascend/pytorch/releases/download/v7.3.0-pytorch2.8.0/torch_npu-2.8.0.post2-cp311-cp311-manylinux_2_28_aarch64.whl"
|
||||
ARG PTA_URL_AMD64="https://gitcode.com/Ascend/pytorch/releases/download/v7.3.0-pytorch2.8.0/torch_npu-2.8.0.post2-cp311-cp311-manylinux_2_28_x86_64.whl"
|
||||
ARG SGLANG_TAG=main
|
||||
ARG ASCEND_CANN_PATH=/usr/local/Ascend/ascend-toolkit
|
||||
ARG SGLANG_KERNEL_NPU_TAG=main
|
||||
|
||||
ARG PIP_INSTALL="python3 -m pip install --no-cache-dir"
|
||||
ARG DEVICE_TYPE
|
||||
|
||||
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
||||
echo "Using x86_64 dependencies"; \
|
||||
echo "PTA_URL=$PTA_URL_AMD64" >> /etc/environment_new; \
|
||||
elif [ "$TARGETARCH" = "arm64" ]; then \
|
||||
echo "Using aarch64 dependencies"; \
|
||||
echo "PTA_URL=$PTA_URL_ARM64" >> /etc/environment_new; \
|
||||
else \
|
||||
echo "Unsupported TARGETARCH: $TARGETARCH"; exit 1; \
|
||||
fi
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
# Define environments
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN pip config set global.index-url $PIP_INDEX_URL
|
||||
RUN if [ -n "$APTMIRROR" ];then sed -i "s|.*.ubuntu.com|$APTMIRROR|g" /etc/apt/sources.list ;fi
|
||||
|
||||
# Install development tools and utilities
|
||||
RUN apt-get update -y && apt upgrade -y && apt-get install -y \
|
||||
unzip \
|
||||
build-essential \
|
||||
cmake \
|
||||
vim \
|
||||
wget \
|
||||
curl \
|
||||
net-tools \
|
||||
zlib1g-dev \
|
||||
lld \
|
||||
clang \
|
||||
locales \
|
||||
ccache \
|
||||
openssl \
|
||||
libssl-dev \
|
||||
pkg-config \
|
||||
libgl1-mesa-glx \
|
||||
libgl1-mesa-dri \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/cache/apt/* \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& update-ca-certificates \
|
||||
&& locale-gen en_US.UTF-8
|
||||
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV LANGUAGE=en_US:en
|
||||
ENV LC_ALL=en_US.UTF-8
|
||||
|
||||
|
||||
### Install MemFabric
|
||||
RUN ${PIP_INSTALL} memfabric-hybrid==1.0.5
|
||||
### Install SGLang Model Gateway
|
||||
RUN ${PIP_INSTALL} sglang-router
|
||||
|
||||
|
||||
### Install PyTorch and PTA
|
||||
RUN . /etc/environment_new && \
|
||||
(${PIP_INSTALL} torch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} --index-url https://download.pytorch.org/whl/cpu) \
|
||||
&& (${PIP_INSTALL} ${PTA_URL})
|
||||
|
||||
|
||||
## Install triton-ascend
|
||||
RUN (${PIP_INSTALL} pybind11 triton-ascend)
|
||||
|
||||
# Install SGLang
|
||||
RUN git clone https://github.com/sgl-project/sglang --branch $SGLANG_TAG && \
|
||||
(cd sglang/python && rm -rf pyproject.toml && mv pyproject_npu.toml pyproject.toml && ${PIP_INSTALL} -v .[all_npu]) && \
|
||||
rm -rf sglang
|
||||
|
||||
# Install Deep-ep
|
||||
# pin wheel to 0.45.1 ref: https://github.com/pypa/wheel/issues/662
|
||||
RUN ${PIP_INSTALL} wheel==0.45.1 pybind11 pyyaml decorator scipy attrs psutil \
|
||||
&& mkdir sgl-kernel-npu \
|
||||
&& cd sgl-kernel-npu \
|
||||
&& wget https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch2.8.0-py311-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip \
|
||||
&& unzip sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch2.8.0-py311-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip \
|
||||
&& ${PIP_INSTALL} deep_ep*.whl sgl_kernel_npu*.whl \
|
||||
&& cd .. && rm -rf sgl-kernel-npu \
|
||||
&& cd "$(python3 -m pip show deep-ep | awk '/^Location:/ {print $2}')" && ln -sf deep_ep/deep_ep_cpp*.so
|
||||
|
||||
CMD ["/bin/bash"]
|
||||
556
third_party/sglang/docker/rocm.Dockerfile
vendored
Normal file
556
third_party/sglang/docker/rocm.Dockerfile
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
# Usage (to build SGLang ROCm docker image):
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx942 -t v0.5.9-rocm700-mi30x -f rocm.Dockerfile .
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx942-rocm720 -t v0.5.9-rocm720-mi30x -f rocm.Dockerfile .
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx950 -t v0.5.9-rocm700-mi35x -f rocm.Dockerfile .
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx950-rocm720 -t v0.5.9-rocm720-mi35x -f rocm.Dockerfile .
|
||||
|
||||
# Usage (to build SGLang ROCm + Mori docker image):
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx942 --build-arg ENABLE_MORI=1 --build-arg NIC_BACKEND=ainic -t v0.5.9-rocm700-mi30x -f rocm.Dockerfile .
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx942-rocm720 --build-arg ENABLE_MORI=1 --build-arg NIC_BACKEND=ainic -t v0.5.9-rocm720-mi30x -f rocm.Dockerfile .
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx950 --build-arg ENABLE_MORI=1 --build-arg NIC_BACKEND=ainic -t v0.5.9-rocm700-mi35x -f rocm.Dockerfile .
|
||||
# docker build --build-arg SGL_BRANCH=v0.5.9 --build-arg GPU_ARCH=gfx950-rocm720 --build-arg ENABLE_MORI=1 --build-arg NIC_BACKEND=ainic -t v0.5.9-rocm720-mi35x -f rocm.Dockerfile .
|
||||
|
||||
# Default base images
|
||||
ARG BASE_IMAGE_942="rocm/sgl-dev:rocm7-vllm-20250904"
|
||||
ARG BASE_IMAGE_942_ROCM720="rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.9.1"
|
||||
ARG BASE_IMAGE_950="rocm/sgl-dev:rocm7-vllm-20250904"
|
||||
ARG BASE_IMAGE_950_ROCM720="rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.9.1"
|
||||
|
||||
# This is necessary for scope purpose
|
||||
ARG GPU_ARCH=gfx950
|
||||
|
||||
# ===============================
|
||||
# Base image 942 with rocm700 and args
|
||||
FROM $BASE_IMAGE_942 AS gfx942
|
||||
ENV BUILD_VLLM="0"
|
||||
ENV BUILD_TRITON="0"
|
||||
ENV BUILD_LLVM="0"
|
||||
ENV BUILD_AITER_ALL="1"
|
||||
ENV BUILD_MOONCAKE="1"
|
||||
ENV AITER_COMMIT_DEFAULT="v0.1.11.post1"
|
||||
|
||||
# ===============================
|
||||
# Base image 942 with rocm720 and args
|
||||
FROM $BASE_IMAGE_942_ROCM720 AS gfx942-rocm720
|
||||
ENV BUILD_VLLM="0"
|
||||
ENV BUILD_TRITON="1"
|
||||
ENV BUILD_LLVM="0"
|
||||
ENV BUILD_AITER_ALL="1"
|
||||
ENV BUILD_MOONCAKE="1"
|
||||
ENV AITER_COMMIT_DEFAULT="v0.1.11.post1"
|
||||
|
||||
# ===============================
|
||||
# Base image 950 and args
|
||||
FROM $BASE_IMAGE_950 AS gfx950
|
||||
ENV BUILD_VLLM="0"
|
||||
ENV BUILD_TRITON="0"
|
||||
ENV BUILD_LLVM="0"
|
||||
ENV BUILD_AITER_ALL="1"
|
||||
ENV BUILD_MOONCAKE="1"
|
||||
ENV AITER_COMMIT_DEFAULT="v0.1.11.post1"
|
||||
|
||||
# ===============================
|
||||
# Base image 950 with rocm720 and args
|
||||
FROM $BASE_IMAGE_950_ROCM720 AS gfx950-rocm720
|
||||
ENV BUILD_VLLM="0"
|
||||
ENV BUILD_TRITON="1"
|
||||
ENV BUILD_LLVM="0"
|
||||
ENV BUILD_AITER_ALL="1"
|
||||
ENV BUILD_MOONCAKE="1"
|
||||
ENV AITER_COMMIT_DEFAULT="v0.1.11.post1"
|
||||
|
||||
# ===============================
|
||||
# Chosen arch and args
|
||||
FROM ${GPU_ARCH}
|
||||
|
||||
# This is necessary for scope purpose, again
|
||||
ARG GPU_ARCH=gfx950
|
||||
ENV GPU_ARCH_LIST=${GPU_ARCH%-*}
|
||||
ENV PYTORCH_ROCM_ARCH=gfx942;gfx950
|
||||
|
||||
ARG SGL_REPO="https://github.com/sgl-project/sglang.git"
|
||||
ARG SGL_DEFAULT="main"
|
||||
ARG SGL_BRANCH=${SGL_DEFAULT}
|
||||
|
||||
# Version override for setuptools_scm (used in nightly builds)
|
||||
ARG SETUPTOOLS_SCM_PRETEND_VERSION=""
|
||||
|
||||
ARG TRITON_REPO="https://github.com/triton-lang/triton.git"
|
||||
ARG TRITON_COMMIT="42270451990532c67e69d753fbd026f28fcc4840"
|
||||
|
||||
ARG AITER_REPO="https://github.com/ROCm/aiter.git"
|
||||
ARG AITER_COMMIT=""
|
||||
ENV AITER_COMMIT="${AITER_COMMIT:-${AITER_COMMIT_DEFAULT}}"
|
||||
|
||||
ARG LLVM_REPO="https://github.com/jrbyrnes/llvm-project.git"
|
||||
ARG LLVM_BRANCH="MainOpSelV2"
|
||||
ARG LLVM_COMMIT="6520ace8227ffe2728148d5f3b9872a870b0a560"
|
||||
|
||||
ARG MOONCAKE_REPO="https://github.com/kvcache-ai/Mooncake.git"
|
||||
ARG MOONCAKE_COMMIT="b6a841dc78c707ec655a563453277d969fb8f38d"
|
||||
|
||||
ARG TILELANG_REPO="https://github.com/tile-ai/tilelang.git"
|
||||
ARG TILELANG_COMMIT="a55a82302bf7f3c5af635b5c9146f728185cc900"
|
||||
|
||||
ARG FHT_REPO="https://github.com/jeffdaily/fast-hadamard-transform.git"
|
||||
ARG FHT_BRANCH="rocm"
|
||||
ARG FHT_COMMIT="46efb7d776d38638fc39f3c803eaee3dd7016bd1"
|
||||
|
||||
ARG ENABLE_MORI=0
|
||||
ARG NIC_BACKEND=none
|
||||
|
||||
ARG MORI_REPO="https://github.com/ROCm/mori.git"
|
||||
ARG MORI_COMMIT="v0.1.0"
|
||||
|
||||
# AMD AINIC apt repo settings
|
||||
ARG AINIC_VERSION=1.117.5
|
||||
ARG UBUNTU_CODENAME=jammy
|
||||
USER root
|
||||
|
||||
# Fix hipDeviceGetName returning empty string in ROCm 7.0 docker images.
|
||||
# The ROCm 7.0 base image is missing libdrm-amdgpu-common which provides the
|
||||
# amdgpu.ids device-ID-to-marketing-name mapping file.
|
||||
# ROCm 7.2 base images already ship these packages, so this step is skipped.
|
||||
# See https://github.com/ROCm/ROCm/issues/5992
|
||||
RUN set -eux; \
|
||||
case "${GPU_ARCH}" in \
|
||||
*rocm720*) \
|
||||
echo "ROCm 7.2 (GPU_ARCH=${GPU_ARCH}): libdrm-amdgpu packages already present, skipping"; \
|
||||
;; \
|
||||
*) \
|
||||
echo "ROCm 7.0 (GPU_ARCH=${GPU_ARCH}): installing libdrm-amdgpu packages"; \
|
||||
curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key \
|
||||
| gpg --dearmor -o /etc/apt/keyrings/amdgpu-graphics.gpg \
|
||||
&& echo 'deb [arch=amd64,i386 signed-by=/etc/apt/keyrings/amdgpu-graphics.gpg] https://repo.radeon.com/graphics/7.0/ubuntu jammy main' \
|
||||
> /etc/apt/sources.list.d/amdgpu-graphics.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
libdrm-amdgpu-common \
|
||||
libdrm-amdgpu-amdgpu1 \
|
||||
libdrm2-amdgpu \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& cp /opt/amdgpu/share/libdrm/amdgpu.ids /usr/share/libdrm/amdgpu.ids; \
|
||||
;; \
|
||||
esac
|
||||
|
||||
|
||||
# Install some basic utilities
|
||||
RUN python -m pip install --upgrade pip && pip install setuptools_scm
|
||||
RUN apt-get purge -y sccache; python -m pip uninstall -y sccache; rm -f "$(which sccache)"
|
||||
|
||||
# Install AMD SMI Python package from ROCm distribution.
|
||||
# The ROCm 7.2 base image (rocm/pytorch) does not pre-install this package.
|
||||
RUN set -eux; \
|
||||
case "${GPU_ARCH}" in \
|
||||
*rocm720*) \
|
||||
echo "ROCm 7.2 flavor detected from GPU_ARCH=${GPU_ARCH}"; \
|
||||
cd /opt/rocm/share/amd_smi \
|
||||
&& python3 -m pip install --no-cache-dir . \
|
||||
;; \
|
||||
*) \
|
||||
echo "Not rocm720 (GPU_ARCH=${GPU_ARCH}), skip amdsmi installation"; \
|
||||
;; \
|
||||
esac
|
||||
|
||||
WORKDIR /sgl-workspace
|
||||
|
||||
# -----------------------
|
||||
# llvm
|
||||
RUN if [ "$BUILD_LLVM" = "1" ]; then \
|
||||
ENV HIP_CLANG_PATH="/sgl-workspace/llvm-project/build/bin/" \
|
||||
git clone --single-branch ${LLVM_REPO} -b ${LLVM_BRANCH} \
|
||||
&& cd llvm-project \
|
||||
&& git checkout ${LLVM_COMMIT} \
|
||||
&& mkdir build \
|
||||
&& cd build \
|
||||
&& cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_PROJECTS="clang;lld;" -DLLVM_ENABLE_RUNTIMES="compiler-rt" ../llvm \
|
||||
&& make -j$(nproc); \
|
||||
fi
|
||||
|
||||
# -----------------------
|
||||
# AITER
|
||||
# Unset setuptools_scm override so AITER gets its own version (AITER_COMMIT), not SGLang's
|
||||
# (SETUPTOOLS_SCM_PRETEND_VERSION is set later for SGLang nightly builds and would otherwise
|
||||
# leak into AITER's version when AITER uses setuptools_scm)
|
||||
ENV SETUPTOOLS_SCM_PRETEND_VERSION=
|
||||
RUN pip uninstall -y aiter \
|
||||
&& pip install flydsl==0.0.1.dev95158637 \
|
||||
&& pip install psutil pybind11 # Required by AITER setup.py
|
||||
RUN git clone ${AITER_REPO} \
|
||||
&& cd aiter \
|
||||
&& git checkout ${AITER_COMMIT} \
|
||||
&& git submodule update --init --recursive
|
||||
|
||||
# Hot patches for AITER in v0.1.10.post3
|
||||
# This is for ROCm 7.2 only, because of the image rebase from vllm
|
||||
# to rocm/pytorch.
|
||||
RUN set -eux; \
|
||||
case "${GPU_ARCH}" in \
|
||||
*rocm720*) \
|
||||
echo "ROCm 7.2 flavor detected from GPU_ARCH=${GPU_ARCH}"; \
|
||||
cd aiter \
|
||||
&& sed -i '459 s/if.*:/if False:/' aiter/ops/triton/attention/pa_mqa_logits.py; \
|
||||
;; \
|
||||
*) \
|
||||
echo "Not rocm720 (GPU_ARCH=${GPU_ARCH}), skip patch"; \
|
||||
;; \
|
||||
esac
|
||||
# [WA] from kk-huang
|
||||
# add sed -i '/c1 = torch.empty((M, D, S1 + S3) for aiter triton gemm config issue
|
||||
# the corresponding pr is https://github.com/ROCm/aiter/pull/2173
|
||||
# it will be removed when server launched issue is fixed by aiter
|
||||
RUN cd aiter \
|
||||
&& echo "[AITER] GPU_ARCH=${GPU_ARCH}" \
|
||||
&& sed -i '/c1 = torch.empty((M, D, S1 + S3), dtype=dtype, device=x.device)/i\ config = dict(config)' aiter/ops/triton/gemm/fused/fused_gemm_afp4wfp4_split_cat.py \
|
||||
&& if [ "$BUILD_AITER_ALL" = "1" ] && [ "$BUILD_LLVM" = "1" ]; then \
|
||||
sh -c "HIP_CLANG_PATH=/sgl-workspace/llvm-project/build/bin/ PREBUILD_KERNELS=1 GPU_ARCHS=$GPU_ARCH_LIST python setup.py build_ext --inplace" \
|
||||
&& sh -c "HIP_CLANG_PATH=/sgl-workspace/llvm-project/build/bin/ GPU_ARCHS=$GPU_ARCH_LIST pip install -e ."; \
|
||||
elif [ "$BUILD_AITER_ALL" = "1" ]; then \
|
||||
sh -c "PREBUILD_KERNELS=1 GPU_ARCHS=$GPU_ARCH_LIST python setup.py build_ext --inplace" \
|
||||
&& sh -c "GPU_ARCHS=$GPU_ARCH_LIST pip install -e ."; \
|
||||
else \
|
||||
sh -c "GPU_ARCHS=$GPU_ARCH_LIST pip install -e ."; \
|
||||
fi \
|
||||
&& echo "export PYTHONPATH=/sgl-workspace/aiter:\${PYTHONPATH}" >> /etc/bash.bashrc
|
||||
|
||||
# -----------------------
|
||||
# Build Mooncake
|
||||
ENV PATH=$PATH:/usr/local/go/bin
|
||||
|
||||
RUN if [ "$BUILD_MOONCAKE" = "1" ]; then \
|
||||
apt update && apt install -y zip unzip wget && \
|
||||
apt install -y gcc make libtool autoconf librdmacm-dev rdmacm-utils infiniband-diags ibverbs-utils perftest ethtool libibverbs-dev rdma-core && \
|
||||
apt install -y openssh-server openmpi-bin openmpi-common libopenmpi-dev && \
|
||||
git clone ${MOONCAKE_REPO} && \
|
||||
cd Mooncake && \
|
||||
git checkout ${MOONCAKE_COMMIT} && \
|
||||
git submodule update --init --recursive && \
|
||||
bash dependencies.sh -y && \
|
||||
rm -rf /usr/local/go && \
|
||||
wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz && \
|
||||
tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz && \
|
||||
rm go1.22.2.linux-amd64.tar.gz && \
|
||||
mkdir -p build && \
|
||||
cd build && \
|
||||
cmake .. -DUSE_HIP=ON -DUSE_ETCD=ON && \
|
||||
make -j "$(nproc)" && make install; \
|
||||
fi
|
||||
|
||||
# -----------------------
|
||||
# Build SGLang
|
||||
ARG BUILD_TYPE=all
|
||||
|
||||
# Set version for setuptools_scm if provided (for nightly builds). Only pass in the SGLang
|
||||
# pip install RUN so it does not affect AITER, sgl-model-gateway, TileLang, FHT, MORI, etc.
|
||||
ARG SETUPTOOLS_SCM_PRETEND_VERSION
|
||||
|
||||
RUN pip install IPython \
|
||||
&& pip install orjson \
|
||||
&& pip install python-multipart \
|
||||
&& pip install torchao==0.9.0 \
|
||||
&& pip install pybind11
|
||||
|
||||
RUN pip uninstall -y sgl_kernel sglang
|
||||
RUN git clone ${SGL_REPO} \
|
||||
&& cd sglang \
|
||||
&& if [ "${SGL_BRANCH}" = ${SGL_DEFAULT} ]; then \
|
||||
echo "Using ${SGL_DEFAULT}, default branch."; \
|
||||
git checkout ${SGL_DEFAULT}; \
|
||||
else \
|
||||
echo "Using ${SGL_BRANCH} branch."; \
|
||||
git checkout ${SGL_BRANCH}; \
|
||||
fi \
|
||||
&& cd sgl-kernel \
|
||||
&& rm -f pyproject.toml \
|
||||
&& mv pyproject_rocm.toml pyproject.toml \
|
||||
&& AMDGPU_TARGET=$GPU_ARCH_LIST python setup_rocm.py install \
|
||||
&& cd .. \
|
||||
&& rm -rf python/pyproject.toml && mv python/pyproject_other.toml python/pyproject.toml \
|
||||
&& if [ "$BUILD_TYPE" = "srt" ]; then \
|
||||
export SETUPTOOLS_SCM_PRETEND_VERSION="${SETUPTOOLS_SCM_PRETEND_VERSION}" && python -m pip --no-cache-dir install -e "python[srt_hip,diffusion_hip]"; \
|
||||
else \
|
||||
export SETUPTOOLS_SCM_PRETEND_VERSION="${SETUPTOOLS_SCM_PRETEND_VERSION}" && python -m pip --no-cache-dir install -e "python[all_hip]"; \
|
||||
fi
|
||||
|
||||
RUN python -m pip cache purge
|
||||
|
||||
# Copy config files to support MI300X in virtualized environments (MI300X_VF). Symlinks will not be created in image build.
|
||||
RUN find /sgl-workspace/sglang/python/sglang/srt/layers/quantization/configs/ \
|
||||
/sgl-workspace/sglang/python/sglang/srt/layers/moe/fused_moe_triton/configs/ \
|
||||
-type f -name '*MI300X*' | xargs -I {} sh -c 'vf_config=$(echo "$1" | sed "s/MI300X/MI300X_VF/"); cp "$1" "$vf_config"' -- {}
|
||||
|
||||
# Install Rust toolchain for sgl-model-gateway
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
|
||||
&& rustc --version && cargo --version
|
||||
ENV CARGO_BUILD_JOBS=4
|
||||
|
||||
# Build and install sgl-model-gateway
|
||||
RUN python3 -m pip install --no-cache-dir maturin \
|
||||
&& cd /sgl-workspace/sglang/sgl-model-gateway/bindings/python \
|
||||
&& ulimit -n 65536 && maturin build --release --features vendored-openssl --out dist \
|
||||
&& python3 -m pip install --force-reinstall dist/*.whl \
|
||||
&& rm -rf /root/.cache
|
||||
|
||||
# -----------------------
|
||||
# TileLang
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV LIBGL_ALWAYS_INDIRECT=1
|
||||
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
|
||||
|
||||
RUN /bin/bash -lc 'set -euo pipefail; \
|
||||
echo "[TileLang] Building TileLang for ${GPU_ARCH}"; \
|
||||
# System dependencies (NO llvm-dev to avoid llvm-config-16 shadowing)
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential git wget curl ca-certificates gnupg \
|
||||
libgtest-dev libgmock-dev \
|
||||
libprotobuf-dev protobuf-compiler libgflags-dev libsqlite3-dev \
|
||||
python3 python3-dev python3-setuptools python3-pip python3-apt \
|
||||
gcc libtinfo-dev zlib1g-dev libedit-dev libxml2-dev vim \
|
||||
cmake ninja-build pkg-config libstdc++6 software-properties-common \
|
||||
&& rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
# Prefer the container venv
|
||||
VENV_PY="/opt/venv/bin/python"; \
|
||||
VENV_PIP="/opt/venv/bin/pip"; \
|
||||
if [ ! -x "$VENV_PY" ]; then VENV_PY="python3"; fi; \
|
||||
if [ ! -x "$VENV_PIP" ]; then VENV_PIP="pip3"; fi; \
|
||||
\
|
||||
# Build GoogleTest static libs (Ubuntu package ships sources only)
|
||||
cmake -S /usr/src/googletest -B /tmp/build-gtest -DBUILD_GTEST=ON -DBUILD_GMOCK=ON -DCMAKE_BUILD_TYPE=Release && \
|
||||
cmake --build /tmp/build-gtest -j"$(nproc)" && \
|
||||
cp -v /tmp/build-gtest/lib/*.a /usr/lib/x86_64-linux-gnu/ && \
|
||||
rm -rf /tmp/build-gtest; \
|
||||
\
|
||||
# Keep setuptools < 80 (compat with base image)
|
||||
"$VENV_PIP" install --upgrade "setuptools>=77.0.3,<80" wheel cmake ninja scikit-build-core && \
|
||||
"$VENV_PIP" cache purge || true; \
|
||||
\
|
||||
# Locate ROCm llvm-config; fallback to installing LLVM 18 if missing
|
||||
LLVM_CONFIG_PATH=""; \
|
||||
for p in /opt/rocm/llvm/bin/llvm-config /opt/rocm/llvm-*/bin/llvm-config /opt/rocm-*/llvm*/bin/llvm-config; do \
|
||||
if [ -x "$p" ]; then LLVM_CONFIG_PATH="$p"; break; fi; \
|
||||
done; \
|
||||
if [ -z "$LLVM_CONFIG_PATH" ]; then \
|
||||
echo "[TileLang] ROCm llvm-config not found; installing LLVM 18..."; \
|
||||
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /etc/apt/keyrings/llvm.gpg; \
|
||||
echo "deb [signed-by=/etc/apt/keyrings/llvm.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" > /etc/apt/sources.list.d/llvm.list; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends llvm-18; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
LLVM_CONFIG_PATH="$(command -v llvm-config-18)"; \
|
||||
if [ -z "$LLVM_CONFIG_PATH" ]; then echo "ERROR: llvm-config-18 not found after install"; exit 1; fi; \
|
||||
fi; \
|
||||
echo "[TileLang] Using LLVM_CONFIG at: $LLVM_CONFIG_PATH"; \
|
||||
export PATH="$(dirname "$LLVM_CONFIG_PATH"):/usr/local/bin:${PATH}"; \
|
||||
export LLVM_CONFIG="$LLVM_CONFIG_PATH"; \
|
||||
\
|
||||
# Optional shim for tools that expect llvm-config-16
|
||||
mkdir -p /usr/local/bin && \
|
||||
printf "#!/usr/bin/env bash\nexec \"%s\" \"\$@\"\n" "$LLVM_CONFIG_PATH" > /usr/local/bin/llvm-config-16 && \
|
||||
chmod +x /usr/local/bin/llvm-config-16; \
|
||||
\
|
||||
# TVM Python bits need Cython + z3 before configure.
|
||||
# Pin z3-solver==4.15.4.0: 4.15.4.0 has a manylinux wheel; 4.15.5.0 has no wheel and builds from source (fails: C++20 <format> needs GCC 14+, image has GCC 11).
|
||||
"$VENV_PIP" install --no-cache-dir "cython>=0.29.36,<3.0" "apache-tvm-ffi @ git+https://github.com/apache/tvm-ffi.git@37d0485b2058885bf4e7a486f7d7b2174a8ac1ce" "z3-solver==4.15.4.0"; \
|
||||
\
|
||||
# Clone + pin TileLang (bundled TVM), then build
|
||||
git clone --recursive "${TILELANG_REPO}" /opt/tilelang && \
|
||||
cd /opt/tilelang && \
|
||||
git fetch --depth=1 origin "${TILELANG_COMMIT}" || true && \
|
||||
git checkout -f "${TILELANG_COMMIT}" && \
|
||||
git submodule update --init --recursive && \
|
||||
export CMAKE_ARGS="-DUSE_CUDA=OFF -DUSE_ROCM=ON -DROCM_PATH=/opt/rocm -DLLVM_CONFIG=${LLVM_CONFIG} -DSKBUILD_SABI_VERSION= ${CMAKE_ARGS:-}" && \
|
||||
"$VENV_PIP" install -e . -v --no-build-isolation --no-deps; \
|
||||
if [ -f pyproject.toml ]; then sed -i "/^[[:space:]]*\"torch/d" pyproject.toml || true; fi; \
|
||||
"$VENV_PIP" cache purge || true; \
|
||||
"$VENV_PY" -c "import tilelang; print(tilelang.__version__)"'
|
||||
|
||||
# -----------------------
|
||||
# Hadamard-transform (HIP build)
|
||||
RUN /bin/bash -lc 'set -euo pipefail; \
|
||||
git clone --branch "${FHT_BRANCH}" "${FHT_REPO}" fast-hadamard-transform; \
|
||||
cd fast-hadamard-transform; \
|
||||
git checkout -f "${FHT_COMMIT}"; \
|
||||
python setup.py install'
|
||||
|
||||
# -----------------------
|
||||
# Python tools
|
||||
RUN python3 -m pip install --no-cache-dir \
|
||||
py-spy \
|
||||
pre-commit \
|
||||
tabulate
|
||||
|
||||
# -----------------------
|
||||
# MORI (optional)
|
||||
RUN /bin/bash -lc 'set -euo pipefail; \
|
||||
if [ "${ENABLE_MORI}" != "1" ]; then \
|
||||
echo "[MORI] Skipping (ENABLE_MORI=${ENABLE_MORI})"; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
echo "[MORI] Enabling MORI (NIC_BACKEND=${NIC_BACKEND})"; \
|
||||
\
|
||||
# Base deps for MORI build
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
g++ \
|
||||
jq \
|
||||
libopenmpi-dev \
|
||||
libpci-dev \
|
||||
initramfs-tools \
|
||||
&& rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
# NIC backend deps
|
||||
case "${NIC_BACKEND}" in \
|
||||
# default: mlx5
|
||||
none) \
|
||||
export USE_IONIC="OFF"; \
|
||||
export USE_BNXT="OFF"; \
|
||||
;; \
|
||||
# AMD NIC
|
||||
ainic) \
|
||||
export USE_IONIC="ON"; \
|
||||
export USE_BNXT="OFF"; \
|
||||
apt-get update && apt-get install -y --no-install-recommends ca-certificates curl gnupg apt-transport-https && \
|
||||
rm -rf /var/lib/apt/lists/* && mkdir -p /etc/apt/keyrings; \
|
||||
curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor > /etc/apt/keyrings/amdainic.gpg; \
|
||||
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/amdainic.gpg] https://repo.radeon.com/amdainic/pensando/ubuntu/${AINIC_VERSION} ${UBUNTU_CODENAME} main" \
|
||||
> /etc/apt/sources.list.d/amdainic.list; \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
libionic-dev \
|
||||
ionic-common \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
;; \
|
||||
# TODO: Add Broadcom bnxt packages/repos here later.
|
||||
# bnxt) \
|
||||
# export USE_IONIC="OFF"; \
|
||||
# export USE_BNXT="ON"; \
|
||||
# echo "[MORI] NIC_BACKEND=bnxt: USE_BNXT=ON. Add Broadcom bnxt packages/repos here later."; \
|
||||
# ;; \
|
||||
*) \
|
||||
echo "ERROR: unknown NIC_BACKEND=${NIC_BACKEND}. Use one of: none, ainic"; \
|
||||
exit 2; \
|
||||
;; \
|
||||
esac; \
|
||||
\
|
||||
# Build/install MORI
|
||||
export MORI_GPU_ARCHS="${GPU_ARCH_LIST}"; \
|
||||
echo "[MORI] MORI_GPU_ARCHS=${MORI_GPU_ARCHS} USE_IONIC=${USE_IONIC} USE_BNXT=${USE_BNXT}"; \
|
||||
rm -rf /sgl-workspace/mori; \
|
||||
git clone "${MORI_REPO}" /sgl-workspace/mori; \
|
||||
cd /sgl-workspace/mori; \
|
||||
git checkout "${MORI_COMMIT}"; \
|
||||
git submodule update --init --recursive; \
|
||||
python3 setup.py develop; \
|
||||
python3 -c "import os, torch; print(os.path.join(os.path.dirname(torch.__file__), \"lib\"))" > /etc/ld.so.conf.d/torch.conf; \
|
||||
ldconfig; \
|
||||
echo "export PYTHONPATH=/sgl-workspace/mori:\${PYTHONPATH}" >> /etc/bash.bashrc; \
|
||||
echo "[MORI] Done."'
|
||||
|
||||
# -----------------------
|
||||
# Hot patch: torch-ROCm
|
||||
# The artifact hardcoded the supported triton version to be 3.5.1.
|
||||
# Rewrite the restriction directly.
|
||||
ARG TORCH_ROCM_FILE="torch-2.9.1+rocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl"
|
||||
RUN mkdir /tmp/whl && cd /tmp/whl \
|
||||
&& export TORCH_ROCM_FILE="${TORCH_ROCM_FILE}" \
|
||||
&& cat > hack.py <<"PY"
|
||||
import zipfile, csv, os, re
|
||||
from pathlib import Path
|
||||
|
||||
fname = os.environ["TORCH_ROCM_FILE"]
|
||||
in_whl = Path("/") / fname
|
||||
out_whl = Path("/tmp")/ fname
|
||||
work = Path("/tmp/whl")
|
||||
|
||||
# 1) Extract
|
||||
with zipfile.ZipFile(in_whl, "r") as z:
|
||||
z.extractall(work)
|
||||
|
||||
# 2) Locate dist-info and patch METADATA (edit this logic to match your exact line)
|
||||
dist_info = next(work.glob("*.dist-info"))
|
||||
meta = dist_info / "METADATA"
|
||||
txt = meta.read_text(encoding="utf-8")
|
||||
|
||||
# Example: replace one exact requirement form.
|
||||
# Adjust the string to match what you actually see.
|
||||
pat = r"^Requires-Dist:\s*triton==3.5.1[^\s]*;"
|
||||
txt2, n = re.subn(pat, r"triton>=3.5.1;", txt, flags=re.MULTILINE)
|
||||
if txt2 == txt:
|
||||
raise SystemExit("Did not find expected Requires-Dist line to replace in METADATA")
|
||||
meta.write_text(txt2, encoding="utf-8")
|
||||
|
||||
# 3) Hacky step: blank hash/size columns in RECORD
|
||||
record = dist_info / "RECORD"
|
||||
rows = []
|
||||
with record.open(newline="", encoding="utf-8") as f:
|
||||
for r in csv.reader(f):
|
||||
if not r:
|
||||
continue
|
||||
# keep filename, blank out hash and size
|
||||
rows.append([r[0], "", ""])
|
||||
with record.open("w", newline="", encoding="utf-8") as f:
|
||||
csv.writer(f).writerows(rows)
|
||||
|
||||
# 4) Re-zip as a wheel
|
||||
with zipfile.ZipFile(out_whl, "w", compression=zipfile.ZIP_DEFLATED) as z:
|
||||
for p in work.rglob("*"):
|
||||
if p.is_file():
|
||||
z.write(p, p.relative_to(work).as_posix())
|
||||
|
||||
print("Wrote", out_whl)
|
||||
PY
|
||||
|
||||
RUN cd /tmp/whl \
|
||||
&& case "${GPU_ARCH}" in \
|
||||
*rocm720*) \
|
||||
echo "ROCm 7.2 flavor detected from GPU_ARCH=${GPU_ARCH}"; \
|
||||
python hack.py \
|
||||
&& python3 -m pip install --force --no-deps /tmp/${TORCH_ROCM_FILE} \
|
||||
&& rm -fr /tmp/whl /tmp/${TORCH_ROCM_FILE} \
|
||||
;; \
|
||||
*) \
|
||||
echo "Not rocm720 (GPU_ARCH=${GPU_ARCH}), skip patch"; \
|
||||
;; \
|
||||
esac
|
||||
|
||||
|
||||
# -----------------------
|
||||
# Hot patch: Triton
|
||||
# For ROCm 7.2, this custom build breaks pip dependency management,
|
||||
# so future `pip install` will break the ROCm stack.
|
||||
# A workaround for this is to reinstall the default triton
|
||||
# wheel with the `rocm/pytorch` image in the root directory.
|
||||
RUN if [ "$BUILD_TRITON" = "1" ]; then \
|
||||
pip uninstall -y triton \
|
||||
&& apt install -y cmake \
|
||||
&& git clone ${TRITON_REPO} triton-custom \
|
||||
&& cd triton-custom \
|
||||
&& git checkout ${TRITON_COMMIT} \
|
||||
&& pip install -r python/requirements.txt \
|
||||
&& pip install -e .; \
|
||||
fi
|
||||
|
||||
# -----------------------
|
||||
# Performance environment variable.
|
||||
|
||||
# Skip CuDNN compatibility check - not applicable for ROCm (uses MIOpen instead)
|
||||
ENV SGLANG_DISABLE_CUDNN_CHECK=1
|
||||
ENV HIP_FORCE_DEV_KERNARG=1
|
||||
ENV HSA_NO_SCRATCH_RECLAIM=1
|
||||
ENV SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1
|
||||
ENV SGLANG_INT4_WEIGHT=0
|
||||
ENV SGLANG_MOE_PADDING=1
|
||||
ENV SGLANG_ROCM_DISABLE_LINEARQUANT=0
|
||||
ENV SGLANG_ROCM_FUSED_DECODE_MLA=1
|
||||
ENV SGLANG_SET_CPU_AFFINITY=1
|
||||
ENV SGLANG_USE_AITER=1
|
||||
ENV SGLANG_USE_ROCM700A=1
|
||||
|
||||
ENV NCCL_MIN_NCHANNELS=112
|
||||
ENV ROCM_QUICK_REDUCE_QUANTIZATION=INT8
|
||||
ENV TORCHINDUCTOR_MAX_AUTOTUNE=1
|
||||
ENV TORCHINDUCTOR_MAX_AUTOTUNE_POINTWISE=1
|
||||
|
||||
CMD ["/bin/bash"]
|
||||
6
third_party/sglang/docker/sagemaker.Dockerfile
vendored
Normal file
6
third_party/sglang/docker/sagemaker.Dockerfile
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM lmsysorg/sglang:latest
|
||||
|
||||
COPY serve /usr/bin/serve
|
||||
RUN chmod 777 /usr/bin/serve
|
||||
|
||||
ENTRYPOINT [ "/usr/bin/serve" ]
|
||||
34
third_party/sglang/docker/serve
vendored
Executable file
34
third_party/sglang/docker/serve
vendored
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
echo "Starting server"
|
||||
|
||||
PREFIX="SM_SGLANG_"
|
||||
ARG_PREFIX="--"
|
||||
|
||||
ARGS=()
|
||||
|
||||
while IFS='=' read -r key value; do
|
||||
arg_name=$(echo "${key#"${PREFIX}"}" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
|
||||
|
||||
ARGS+=("${ARG_PREFIX}${arg_name}")
|
||||
if [ -n "$value" ]; then
|
||||
ARGS+=("$value")
|
||||
fi
|
||||
done < <(env | grep "^${PREFIX}")
|
||||
|
||||
# Add default port only if not already set
|
||||
if ! [[ " ${ARGS[@]} " =~ " --port " ]]; then
|
||||
ARGS+=(--port "${SM_SGLANG_PORT:-8080}")
|
||||
fi
|
||||
|
||||
# Add default host only if not already set
|
||||
if ! [[ " ${ARGS[@]} " =~ " --host " ]]; then
|
||||
ARGS+=(--host "${SM_SGLANG_HOST:-0.0.0.0}")
|
||||
fi
|
||||
|
||||
# Add default model-path only if not already set
|
||||
if ! [[ " ${ARGS[@]} " =~ " --model-path " ]]; then
|
||||
ARGS+=(--model-path "${SM_SGLANG_MODEL_PATH:-/opt/ml/model}")
|
||||
fi
|
||||
|
||||
echo "Running command: exec python3 -m sglang.launch_server ${ARGS[@]}"
|
||||
exec python3 -m sglang.launch_server "${ARGS[@]}"
|
||||
51
third_party/sglang/docker/xeon.Dockerfile
vendored
Normal file
51
third_party/sglang/docker/xeon.Dockerfile
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
FROM ubuntu:24.04
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
ARG SGLANG_REPO=https://github.com/sgl-project/sglang.git
|
||||
ARG VER_SGLANG=main
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get full-upgrade -y && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||
ca-certificates \
|
||||
git \
|
||||
curl \
|
||||
wget \
|
||||
vim \
|
||||
gcc \
|
||||
g++ \
|
||||
make \
|
||||
libsqlite3-dev \
|
||||
google-perftools \
|
||||
libtbb-dev \
|
||||
libnuma-dev \
|
||||
numactl
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
||||
source $HOME/.local/bin/env && \
|
||||
uv venv --python 3.12
|
||||
|
||||
RUN echo -e '[[index]]\nname = "torch"\nurl = "https://download.pytorch.org/whl/cpu"\n\n[[index]]\nname = "torchvision"\nurl = "https://download.pytorch.org/whl/cpu"\n\n[[index]]\nname = "torchaudio"\nurl = "https://download.pytorch.org/whl/cpu"\n\n[[index]]\nname = "triton"\nurl = "https://download.pytorch.org/whl/cpu"' > .venv/uv.toml
|
||||
|
||||
ENV UV_CONFIG_FILE=/opt/.venv/uv.toml
|
||||
|
||||
WORKDIR /sgl-workspace
|
||||
RUN source $HOME/.local/bin/env && \
|
||||
source /opt/.venv/bin/activate && \
|
||||
git clone ${SGLANG_REPO} sglang && \
|
||||
cd sglang && \
|
||||
git checkout ${VER_SGLANG} && \
|
||||
cd python && \
|
||||
cp pyproject_cpu.toml pyproject.toml && \
|
||||
uv pip install . && \
|
||||
cd ../sgl-kernel && \
|
||||
cp pyproject_cpu.toml pyproject.toml && \
|
||||
uv pip install .
|
||||
|
||||
ENV SGLANG_USE_CPU_ENGINE=1
|
||||
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4:/usr/lib/x86_64-linux-gnu/libtbbmalloc.so:/opt/.venv/lib/libiomp5.so
|
||||
RUN echo 'source /opt/.venv/bin/activate' >> /root/.bashrc
|
||||
|
||||
WORKDIR /sgl-workspace/sglang
|
||||
73
third_party/sglang/docker/xpu.Dockerfile
vendored
Normal file
73
third_party/sglang/docker/xpu.Dockerfile
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# If the device is Battlemage, we need to set UBUNTU_VERSION to 24.10
|
||||
|
||||
# Usage: docker build --build-arg UBUNTU_VERSION=24.04 --build-arg PYTHON_VERSION=3.10 -t sglang:xpu_kernel -f xpu.Dockerfile --no-cache .
|
||||
|
||||
# Use Intel deep learning essentials base image with Ubuntu 24.04
|
||||
FROM intel/deep-learning-essentials:2025.3.2-0-devel-ubuntu24.04
|
||||
|
||||
# Avoid interactive prompts during package install
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Define build arguments
|
||||
ARG PYTHON_VERSION=3.10
|
||||
|
||||
ARG SG_LANG_REPO=https://github.com/sgl-project/sglang.git
|
||||
ARG SG_LANG_BRANCH=main
|
||||
|
||||
ARG SG_LANG_KERNEL_REPO=https://github.com/sgl-project/sgl-kernel-xpu.git
|
||||
ARG SG_LANG_KERNEL_BRANCH=main
|
||||
|
||||
RUN useradd -m -d /home/sdp -s /bin/bash sdp && \
|
||||
chown -R sdp:sdp /home/sdp
|
||||
|
||||
# Switch to non-root user 'sdp'
|
||||
USER sdp
|
||||
|
||||
# Set HOME and WORKDIR to user's home directory
|
||||
ENV HOME=/home/sdp
|
||||
WORKDIR /home/sdp
|
||||
|
||||
RUN curl -fsSL -v -o miniforge.sh -O https://github.com/conda-forge/miniforge/releases/download/25.1.1-0/Miniforge3-Linux-x86_64.sh && \
|
||||
bash miniforge.sh -b -p ./miniforge3 && \
|
||||
rm miniforge.sh && \
|
||||
# Initialize conda environment and install pip
|
||||
. ./miniforge3/bin/activate && \
|
||||
conda create -y -n py${PYTHON_VERSION} python=${PYTHON_VERSION} && \
|
||||
conda activate py${PYTHON_VERSION} && \
|
||||
conda install pip && \
|
||||
# Append environment activation to .bashrc for interactive shells
|
||||
echo ". /home/sdp/miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; . /opt/intel/oneapi/setvars.sh; cd /home/sdp" >> /home/sdp/.bashrc
|
||||
|
||||
USER root
|
||||
RUN apt-get update && apt install -y intel-ocloc
|
||||
|
||||
# Switch back to user sdp
|
||||
USER sdp
|
||||
|
||||
RUN --mount=type=secret,id=github_token \
|
||||
cd /home/sdp && \
|
||||
. /home/sdp/miniforge3/bin/activate && \
|
||||
conda activate py${PYTHON_VERSION} && \
|
||||
pip3 install torch==2.10.0+xpu torchao torchvision torchaudio==2.10.0+xpu triton-xpu==3.6.0 --index-url https://download.pytorch.org/whl/xpu
|
||||
|
||||
RUN --mount=type=secret,id=github_token \
|
||||
cd /home/sdp && \
|
||||
. /home/sdp/miniforge3/bin/activate && \
|
||||
conda activate py${PYTHON_VERSION} && \
|
||||
echo "Cloning ${SG_LANG_BRANCH} from ${SG_LANG_REPO}" && \
|
||||
git clone --branch ${SG_LANG_BRANCH} --single-branch ${SG_LANG_REPO} && \
|
||||
cd sglang && cd python && \
|
||||
cp pyproject_xpu.toml pyproject.toml && \
|
||||
pip install . && \
|
||||
pip install xgrammar --no-deps && \
|
||||
pip install msgspec blake3 py-cpuinfo compressed_tensors gguf partial_json_parser einops tabulate --root-user-action=ignore && \
|
||||
conda install libsqlite=3.48.0 -y && \
|
||||
# Add environment setup commands to .bashrc again (in case it was overwritten)
|
||||
echo ". /home/sdp/miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; cd /home/sdp" >> /home/sdp/.bashrc
|
||||
|
||||
# Use bash as default shell with initialization from .bashrc
|
||||
SHELL ["bash", "-c"]
|
||||
|
||||
# Start an interactive bash shell with all environment set up
|
||||
USER sdp
|
||||
CMD ["bash", "-c", "source /home/sdp/.bashrc && exec bash"]
|
||||
Reference in New Issue
Block a user