Skip to content

Commit 4d4498d

Browse files
committed
build: minor improvements to sglang dockerfile (#1917)
1 parent 5ec0a07 commit 4d4498d

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
@@ -158,14 +161,13 @@ RUN cd /opt/nixl && uv build . --out-dir /workspace/wheels/nixl
158161
RUN uv pip install /workspace/wheels/nixl/*.whl
159162

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

@@ -420,6 +422,7 @@ ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu/plugins
420422
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
421423

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

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

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

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

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

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

0 commit comments

Comments
 (0)