Skip to content

Commit 6a1350c

Browse files
authored
build: minor improvements to sglang dockerfile (#1917)
1 parent e2a619b commit 6a1350c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

container/Dockerfile.sglang

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ ARG RUNTIME_IMAGE_TAG="12.8.1-runtime-ubuntu24.04"
2626
ARG ARCH=amd64
2727
ARG ARCH_ALT=x86_64
2828

29+
ARG SGLANG_VERSION="0.4.9.post1"
30+
ARG SGL_KERNEL_VERSION="0.2.4"
31+
2932
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS nixl_base
3033

3134
# Redeclare ARCH and ARCH_ALT so they're available in this stage
@@ -159,14 +162,13 @@ RUN cd /opt/nixl && uv build . --out-dir /workspace/wheels/nixl
159162
RUN uv pip install /workspace/wheels/nixl/*.whl
160163

161164
# Install sglang
162-
# This commit references a NIXL fix that was released after the 0.4.8.post1 release https://github.com/sgl-project/sglang/pull/7330
163165
#TODO: Built wheel should become an artifact which can be cached and reused in subsequent builds
164-
ARG SGLANG_COMMIT="bb9b608c86ebad7d9d01e29fe058bc184dc7285f"
166+
ARG SGLANG_VERSION
165167
RUN --mount=type=cache,target=/root/.cache/uv \
166168
cd /opt && \
167169
git clone https://github.com/sgl-project/sglang.git && \
168170
cd sglang && \
169-
git checkout ${SGLANG_COMMIT} && \
171+
git checkout v${SGLANG_VERSION} && \
170172
# Install in editable mode for development
171173
uv pip install -e "python[all]"
172174

@@ -419,6 +421,7 @@ ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu/plugins
419421
ENV LD_LIBRARY_PATH=/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu:/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu/plugins:/usr/local/ucx/lib:$LD_LIBRARY_PATH
420422

421423
# Setup the python environment
424+
# libnuma-dev is a required dependency for sglang integration with NIXL
422425
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
423426
RUN apt-get update && \
424427
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential python3-dev libnuma-dev && \
@@ -428,19 +431,16 @@ RUN apt-get update && \
428431

429432
# Install SGLang and related packages (sgl-kernel, einops, sentencepiece) since they are not included in the runtime wheel
430433
# https://github.com/sgl-project/sglang/blob/v0.4.9.post1/python/pyproject.toml#L18-51
431-
RUN uv pip install "sglang[runtime_common]>=0.4.9.post1" && \
432-
uv pip install einops && \
433-
uv pip install sgl-kernel==0.2.4 && \
434-
uv pip install sentencepiece
434+
ARG SGLANG_VERSION
435+
ARG SGL_KERNEL_VERSION
436+
RUN --mount=type=cache,target=/root/.cache/uv \
437+
uv pip install sglang[runtime_common]==${SGLANG_VERSION} einops sgl-kernel==${SGL_KERNEL_VERSION} sentencepiece
435438

436439
# Install the wheels and symlink executables to /usr/local/bin so dynamo components can use them
437440
# Dynamo components currently do not have the VIRTUAL_ENV in their PATH, so we need to symlink the executables
438441
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
439442
COPY --from=base /workspace/wheels/nixl/*.whl wheelhouse/
440-
RUN uv pip install ai-dynamo --find-links wheelhouse && \
441-
uv pip install ai-dynamo-runtime --find-links wheelhouse && \
442-
uv pip install nixl --find-links wheelhouse && \
443-
ln -sf $VIRTUAL_ENV/bin/* /usr/local/bin/
443+
RUN uv pip install ai-dynamo nixl --find-links wheelhouse
444444

445445
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
446446
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so"
@@ -450,8 +450,16 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la
450450
sed '/^#\s/d' /workspace/launch_message.txt > ~/.launch_screen && \
451451
echo "cat ~/.launch_screen" >> ~/.bashrc
452452

453-
# Copy examples and set up Python path
454-
COPY . /workspace
453+
# Copy benchmarks, examples, and tests for CI
454+
# TODO: Remove this once we have a functional CI image built on top of the runtime image
455+
COPY tests /workspace/tests
456+
COPY benchmarks /workspace/benchmarks
457+
COPY examples /workspace/examples
458+
RUN uv pip install /workspace/benchmarks
459+
460+
# Copy attribution files
461+
COPY ATTRIBUTION* LICENSE /workspace/
462+
455463
ENV PYTHONPATH=/workspace/examples/sglang/utils:$PYTHONPATH
456464

457465
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]

0 commit comments

Comments
 (0)