From 35c73cb1220d92d7ff1d04bcb54f93bc6344ed6e Mon Sep 17 00:00:00 2001 From: princepirde Date: Mon, 18 May 2026 07:13:32 +0000 Subject: [PATCH 1/3] dockerfile swich to vllm==0.21.0 Signed-off-by: princepirde --- docker/Dockerfile | 183 +++++++++++++++++++--------------------------- docker/README.md | 12 +-- 2 files changed, 77 insertions(+), 118 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3876daaf0..a86abbc76 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,122 +1,87 @@ -ARG SGLANG_IMAGE_TAG=v0.5.10.post1 -FROM slimerl/sglang:${SGLANG_IMAGE_TAG} AS sglang +ARG BASE_IMAGE=vllm/vllm-openai:v0.21.0 +FROM ${BASE_IMAGE} -# ======================================== Arguments ============================================= +# vLLM is the inference/runtime dependency source of truth for this image. +# SGLang is intentionally not installed in this build path. +ARG VLLM_VERSION=0.21.0 +ARG MEGATRON_COMMIT=3714d81d418c9f1bca4594fc35f9e8289f652862 +ARG PATCH_VERSION=v0.5.9 +ARG INSTALL_VLLM=0 +ARG VLLM_PIP_INSTALL_ARGS= -ARG PATCH_VERSION=latest -ARG MEGATRON_COMMIT=1dcf0dafa884ad52ffb243625717a3471643e087 +SHELL ["/bin/bash", "-euxo", "pipefail", "-c"] -ARG ENABLE_CUDA_13=0 +WORKDIR /root -# ======================================== Setup ============================================= +RUN apt-get update && \ + apt-get install -y --no-install-recommends git rsync dnsutils nvtop && \ + rm -rf /var/lib/apt/lists/* -WORKDIR /root/ - -# ======================================== Apt dependencies ============================================= - -RUN apt update -RUN apt install -y nvtop rsync dnsutils - -# ====================================== Python dependencies ============================================ - -# The compilation is slow, thus should be put at top -# TransformerEngines does not support too high FA2 -RUN MAX_JOBS=64 pip -v install flash-attn==2.7.4.post1 --no-build-isolation - -# The compilation is slow, thus should be put at top -RUN git clone https://github.com/Dao-AILab/flash-attention.git && \ - cd flash-attention/ && git checkout fbf24f67cf7f6442c5cfb2c1057f4bfc57e72d89 && git submodule update --init && cd hopper/ && \ - MAX_JOBS=96 python setup.py install && \ - export python_path=`python -c "import site; print(site.getsitepackages()[0])"` && \ - mkdir -p $python_path/flash_attn_3 && \ - cp flash_attn_interface.py $python_path/flash_attn_3/flash_attn_interface.py && \ - rm -rf flash-attention/ - -RUN pip install git+https://github.com/ISEEKYAN/mbridge.git@89eb10887887bc74853f89a4de258c0702932a1c --no-deps - -RUN pip install flash-linear-attention==0.4.1 -RUN pip install tilelang -f https://tile-ai.github.io/whl/nightly/cu128/ - -# TE does not have wheel on cuda 13 yet, thus need to install from source -RUN if [ "${ENABLE_CUDA_13}" = "1" ]; then \ - pip install nvidia-mathdx==26.6.0 && \ - pip -v install --no-build-isolation git+https://github.com/NVIDIA/TransformerEngine.git@release_v2.10; \ - else \ - pip -v install --no-build-isolation "transformer_engine[pytorch]==2.10.0"; \ +# If the base image is not already vllm/vllm-openai:, set +# INSTALL_VLLM=1 to install the requested wheel explicitly. +RUN if [ "${INSTALL_VLLM}" = "1" ]; then \ + python3 -m pip install --force-reinstall "vllm==${VLLM_VERSION}" ${VLLM_PIP_INSTALL_ARGS}; \ fi -RUN NVCC_APPEND_FLAGS="--threads 4" \ - pip -v install --disable-pip-version-check --no-cache-dir \ - --no-build-isolation \ - --config-settings "--build-option=--cpp_ext --cuda_ext --parallel 8" git+https://github.com/NVIDIA/apex.git@10417aceddd7d5d05d7cbf7b0fc2daad1105f8b4 - -RUN git clone https://github.com/NVIDIA/Megatron-LM.git --recursive && \ - cd Megatron-LM && git checkout ${MEGATRON_COMMIT} && \ - pip install -e . - -RUN pip install git+https://github.com/fzyzcjy/torch_memory_saver.git@d64a639 --no-cache-dir --force-reinstall -RUN pip install git+https://github.com/radixark/Megatron-Bridge.git@bridge --no-deps --no-build-isolation -RUN pip install nvidia-modelopt[torch]>=0.37.0 --no-build-isolation - -# This patch from masahi will be included in later Triton releases -RUN if [ "$ENABLE_CUDA_13" = "1" ]; then \ - (cd /root && git clone -b feat/v350_plus_8045 https://github.com/fzyzcjy/triton.git && cd triton && pip install -r python/requirements.txt && pip install --verbose -e .); \ - fi - -COPY requirements.txt /tmp/requirements.txt -RUN pip install --ignore-installed PyJWT && \ - pip install -r /tmp/requirements.txt - -# Temporarily install another sgl-kernel version for GB300 without rebuilding the whole image -RUN if [ "$ENABLE_CUDA_13" = "1" ]; then \ - SGL_KERNEL_VERSION=0.3.17.post2 && \ - python3 -m pip install https://github.com/sgl-project/whl/releases/download/v${SGL_KERNEL_VERSION}/sgl_kernel-${SGL_KERNEL_VERSION}+cu130-cp310-abi3-manylinux2014_$(uname -m).whl --force-reinstall --no-deps; \ - fi +# Install slime runtime requirements while excluding SGLang packages. Future +# code paths should provide vLLM equivalents instead of importing SGLang. +COPY requirements.txt /tmp/slime-requirements.txt +RUN python3 - <<'PY' && \ + python3 -m pip install -r /tmp/slime-requirements-vllm.txt +from pathlib import Path + +source = Path("/tmp/slime-requirements.txt") +target = Path("/tmp/slime-requirements-vllm.txt") +skip_prefixes = ("sglang", "sglang-router") + +lines = [] +for raw_line in source.read_text().splitlines(): + normalized = raw_line.split("#", 1)[0].strip().lower() + if normalized.startswith(skip_prefixes): + continue + lines.append(raw_line) + +target.write_text("\n".join(lines) + "\n") +PY + +# slime's Megatron integration needs the local Megatron patch. This build does +# not apply docker/patch/*/sglang.patch. +RUN git clone https://github.com/NVIDIA/Megatron-LM.git --recursive /root/Megatron-LM && \ + cd /root/Megatron-LM && \ + git checkout "${MEGATRON_COMMIT}" + +COPY docker/patch/${PATCH_VERSION}/megatron.patch /root/Megatron-LM/megatron.patch +RUN cd /root/Megatron-LM && \ + git update-index --refresh && \ + git apply megatron.patch --3way && \ + if grep -R -n '^<<<<<<< ' .; then \ + echo "Megatron patch failed to apply cleanly. Please resolve conflicts." && \ + exit 1; \ + fi && \ + rm megatron.patch && \ + python3 -m pip install -e . --no-deps -# https://github.com/pytorch/pytorch/issues/168167 -RUN pip install nvidia-cudnn-cu12==9.16.0.29 +ENV PYTHONPATH="/root/Megatron-LM:${PYTHONPATH}" -# reinstall numpy 1.x for megatron -RUN pip install "numpy<2" +# Install slime itself without dependency resolution so the vLLM base image +# keeps control of CUDA/PyTorch/Triton/transformers compatibility. +COPY . /root/slime +RUN cd /root/slime && \ + python3 -m pip install -e . --no-deps -RUN pip install https://github.com/zhuzilin/sgl-router/releases/download/v0.3.2-5f8d397/sglang_router-0.3.2-cp38-abi3-manylinux_2_28_x86_64.whl --force-reinstall -RUN python -c "import sglang_router; assert 'slime' in sglang_router.__version__" +WORKDIR /root/slime -RUN rm -rf /root/.cache/pip /root/flash-attention +RUN python3 - <<'PY' +import importlib.metadata as metadata +import vllm -# ====================================== Patches ============================================ +print("vllm import ok", getattr(vllm, "__version__", metadata.version("vllm"))) +try: + metadata.version("sglang") +except metadata.PackageNotFoundError: + print("sglang not installed") +else: + raise SystemExit("sglang should not be installed in the vLLM image") +PY -COPY docker/patch/${PATCH_VERSION}/megatron.patch /root/Megatron-LM/ -RUN cd Megatron-LM && \ - git update-index --refresh && \ - git apply megatron.patch --3way && \ - if grep -R -n '^<<<<<<< ' .; then \ - echo "Patch failed to apply cleanly. Please resolve conflicts." && \ - exit 1; \ - fi && \ - rm megatron.patch - -# TODO temporarily skip patching for GB200/GB300 (and require users to bring their own sglang version). should add back later. -ARG ENABLE_SGLANG_PATCH=1 -COPY docker/patch/${PATCH_VERSION}/sglang.patch /sgl-workspace/sglang/ -RUN if [ "$ENABLE_SGLANG_PATCH" = "1" ]; then \ - cd /sgl-workspace/sglang && \ - git update-index --refresh && \ - git apply sglang.patch --3way && \ - if grep -R -n '^<<<<<<< ' .; then \ - echo "Patch failed to apply cleanly. Please resolve conflicts." && \ - exit 1; \ - fi && \ - rm sglang.patch; \ -fi - -# ====================================== Install main package ============================================ - -ARG SLIME_COMMIT=main -RUN git clone https://github.com/THUDM/slime.git /root/slime && \ - cd /root/slime && \ - git checkout ${SLIME_COMMIT} && \ - pip install -e . --no-deps - -RUN cd /root/slime/slime/backends/megatron_utils/kernels/int4_qat && \ - pip install . --no-build-isolation +CMD ["/bin/bash"] diff --git a/docker/README.md b/docker/README.md index 62105e3ed..bd2a12987 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,17 +1,11 @@ # Docker release rule We will publish 2 kinds of docker images: -1. stable version, which based on official sglang release. We will store the patch on those versions. -2. latest version, which aligns to `lmsysorg/sglang:latest`. +1. stable version, which is based on an official vLLM release. +2. latest version, which aligns to the current vLLM-based Dockerfile. current stable version is: -- sglang v0.5.9 (bbe9c7eeb520b0a67e92d133dfc137a3688dc7f2), megatron dev 3714d81d418c9f1bca4594fc35f9e8289f652862 - -history versions: -- sglang v0.5.7 nightly-dev-20260107-dce8b060 (dce8b0606c06d3a191a24c7b8cbe8e238ab316c9), megatron dev 3714d81d418c9f1bca4594fc35f9e8289f652862 -- sglang v0.5.6 nightly-dev-20251208-5e2cda61 (5e2cda6158e670e64b926a9985d65826c537ac82), megatron v0.14.0 (23e00ed0963c35382dfe8a5a94fb3cda4d21e133) -- sglang v0.5.5.post1 (303cc957e62384044dfa8e52d7d8af8abe12f0ac), megatron v0.14.0 (23e00ed0963c35382dfe8a5a94fb3cda4d21e133) -- sglang v0.5.0rc0-cu126 (8ecf6b9d2480c3f600826c7d8fef6a16ed603c3f), megatron 48406695c4efcf1026a7ed70bb390793918dd97b +- vLLM v0.21.0, megatron dev 3714d81d418c9f1bca4594fc35f9e8289f652862 The command to build: From a3edf0c7f988375cab110daef52c8309e77173f2 Mon Sep 17 00:00:00 2001 From: princepride Date: Mon, 18 May 2026 07:17:54 +0000 Subject: [PATCH 2/3] xxx Signed-off-by: princepride --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index a86abbc76..6ee30a629 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,8 @@ ARG BASE_IMAGE=vllm/vllm-openai:v0.21.0 FROM ${BASE_IMAGE} -# vLLM is the inference/runtime dependency source of truth for this image. -# SGLang is intentionally not installed in this build path. +# ======================================== Arguments ============================================= + ARG VLLM_VERSION=0.21.0 ARG MEGATRON_COMMIT=3714d81d418c9f1bca4594fc35f9e8289f652862 ARG PATCH_VERSION=v0.5.9 From 62746951c019f9836094d44b17bbb4d019e007e7 Mon Sep 17 00:00:00 2001 From: princepride Date: Tue, 19 May 2026 03:58:16 +0000 Subject: [PATCH 3/3] add sglang --no-deps and change vllm to 0.20.2 Signed-off-by: princepride --- docker/Dockerfile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6ee30a629..f451d0d9a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,13 +1,15 @@ -ARG BASE_IMAGE=vllm/vllm-openai:v0.21.0 +ARG BASE_IMAGE=vllm/vllm-openai:v0.20.2 FROM ${BASE_IMAGE} # ======================================== Arguments ============================================= -ARG VLLM_VERSION=0.21.0 +ARG VLLM_VERSION=0.20.2 ARG MEGATRON_COMMIT=3714d81d418c9f1bca4594fc35f9e8289f652862 ARG PATCH_VERSION=v0.5.9 ARG INSTALL_VLLM=0 ARG VLLM_PIP_INSTALL_ARGS= +ARG ENABLE_CUDA_13=1 +ARG SGLANG_VERSION=0.5.9 SHELL ["/bin/bash", "-euxo", "pipefail", "-c"] @@ -23,6 +25,18 @@ RUN if [ "${INSTALL_VLLM}" = "1" ]; then \ python3 -m pip install --force-reinstall "vllm==${VLLM_VERSION}" ${VLLM_PIP_INSTALL_ARGS}; \ fi +# TE does not have wheel on cuda 13 yet, thus need to install from source +RUN if [ "${ENABLE_CUDA_13}" = "1" ]; then \ + pip install --no-deps nvidia-mathdx==26.6.0 && \ + pip -v install --no-build-isolation --no-deps git+https://github.com/NVIDIA/TransformerEngine.git@release_v2.10; \ + else \ + pip -v install --no-build-isolation --no-deps "transformer_engine[pytorch]==2.10.0"; \ + fi && \ + pip install --no-deps onnxscript onnx_ir onnx ml_dtypes + +# Keep sglang installed (with --no-deps) so training-side imports keep working +RUN pip install --no-deps "sglang==${SGLANG_VERSION}" sglang-router==0.3.2 torch_memory_saver==0.0.9 + # Install slime runtime requirements while excluding SGLang packages. Future # code paths should provide vLLM equivalents instead of importing SGLang. COPY requirements.txt /tmp/slime-requirements.txt @@ -76,12 +90,8 @@ import importlib.metadata as metadata import vllm print("vllm import ok", getattr(vllm, "__version__", metadata.version("vllm"))) -try: - metadata.version("sglang") -except metadata.PackageNotFoundError: - print("sglang not installed") -else: - raise SystemExit("sglang should not be installed in the vLLM image") +print("sglang version", metadata.version("sglang")) +print("transformer_engine version", metadata.version("transformer_engine")) PY CMD ["/bin/bash"]