-
Notifications
You must be signed in to change notification settings - Fork 601
build: Add support for sglang runtime image #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
458bb9f
3667820
063f6af
279939f
a1fd995
d3e0d50
c829b95
90b93c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,32 @@ RUN apt-get update -y && \ | |
|
||
WORKDIR /workspace | ||
|
||
### TODO: Bring back UCX EFA setup once we are confident it works with IB devices | ||
### UCX EFA Setup ### | ||
RUN rm -rf /opt/hpcx/ucx | ||
RUN rm -rf /usr/local/ucx | ||
RUN cd /usr/local/src && \ | ||
git clone https://github.com/openucx/ucx.git && \ | ||
cd ucx && \ | ||
git checkout v1.19.x && \ | ||
./autogen.sh && ./configure \ | ||
--prefix=/usr/local/ucx \ | ||
--enable-shared \ | ||
--disable-static \ | ||
--disable-doxygen-doc \ | ||
--enable-optimizations \ | ||
--enable-cma \ | ||
--enable-devel-headers \ | ||
--with-cuda=/usr/local/cuda \ | ||
--with-verbs \ | ||
--with-efa \ | ||
--with-dm \ | ||
--with-gdrcopy=/usr/local \ | ||
--enable-mt && \ | ||
make -j && \ | ||
make -j install-strip && \ | ||
ldconfig | ||
|
||
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/ucx/lib:$LD_LIBRARY_PATH | ||
ENV CPATH=/usr/include:$CPATH | ||
ENV PATH=/usr/bin:$PATH | ||
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH | ||
|
@@ -127,21 +152,22 @@ ENV VIRTUAL_ENV=/opt/dynamo/venv | |
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
|
||
# Install NIXL Python module | ||
# TODO: Move gds_path selection based on arch into NIXL build | ||
RUN if [ "$ARCH" = "arm64" ]; then \ | ||
cd /opt/nixl && uv pip install . --config-settings=setup-args="-Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \ | ||
else \ | ||
cd /opt/nixl && uv pip install . ; \ | ||
fi | ||
RUN cd /opt/nixl && uv build . --out-dir /workspace/wheels/nixl | ||
|
||
# Install the wheel | ||
# TODO: Move NIXL wheel install to the wheel_builder stage | ||
RUN uv pip install /workspace/wheels/nixl/*.whl | ||
|
||
# Install sglang | ||
# This commit references a NIXL fix that was releasted after the 0.4.8.post1 release https://github.com/sgl-project/sglang/pull/7330 | ||
# This commit references a NIXL fix that was released after the 0.4.8.post1 release https://github.com/sgl-project/sglang/pull/7330 | ||
#TODO: Built wheel should become an artifact which can be cached and reused in subsequent builds | ||
ARG SGLANG_COMMIT="bb9b608c86ebad7d9d01e29fe058bc184dc7285f" | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
cd /opt && \ | ||
git clone https://github.com/sgl-project/sglang.git && \ | ||
cd sglang && \ | ||
git checkout ${SGLANG_COMMIT} && \ | ||
# Install in editable mode for development | ||
uv pip install -e "python[all]" | ||
|
||
# Set env var that allows for forceful shutdown of inflight requests in SGL's TokenizerManager | ||
|
@@ -380,20 +406,43 @@ ENV DYNAMO_HOME=/workspace | |
ENV VIRTUAL_ENV=/opt/dynamo/venv | ||
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
|
||
### COPY NATS & ETCD ### | ||
# Copy nats and etcd from base image | ||
COPY --from=base /usr/bin/nats-server /usr/bin/nats-server | ||
COPY --from=base /usr/local/bin/etcd/ /usr/local/bin/etcd/ | ||
ENV PATH=/usr/local/bin/etcd/:$PATH | ||
|
||
# Copy UCX from base image as plugin for NIXL | ||
# Copy NIXL source from base image (required for NIXL plugins) | ||
COPY --from=base /usr/local/ucx /usr/local/ucx | ||
COPY --from=base /usr/local/nixl /usr/local/nixl | ||
ARG ARCH_ALT | ||
ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu/plugins | ||
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 | ||
|
||
# Setup the python environment | ||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3-dev && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential python3-dev libnuma-dev && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is libnuma a requirement for sglang? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is a required dependency for NIXL integration with the sglang backend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment please in dockerfile |
||
rm -rf /var/lib/apt/lists/* && \ | ||
uv venv $VIRTUAL_ENV --python 3.12 && \ | ||
echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc | ||
|
||
# Install SGLang and related packages (sgl-kernel, einops, sentencepiece) since they are not included in the runtime wheel | ||
# https://github.com/sgl-project/sglang/blob/v0.4.9.post1/python/pyproject.toml#L18-51 | ||
RUN uv pip install "sglang[runtime_common]>=0.4.9.post1" && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this version different than what is installed in dev container? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version installed in the devel container is built from source commit: sgl-project/sglang#7330 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use same commit/tag in both places? ideally with an ARG. |
||
uv pip install einops && \ | ||
uv pip install sgl-kernel==0.2.4 && \ | ||
uv pip install sentencepiece | ||
|
||
# Install the wheels and symlink executables to /usr/local/bin so dynamo components can use them | ||
# Dynamo components currently do not have the VIRTUAL_ENV in their PATH, so we need to symlink the executables | ||
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/ | ||
RUN uv pip install ai-dynamo[vllm] --find-links wheelhouse && \ | ||
ln -sf $VIRTUAL_ENV/bin/* /usr/local/bin/ && \ | ||
rm -r wheelhouse | ||
COPY --from=base /workspace/wheels/nixl/*.whl wheelhouse/ | ||
RUN uv pip install ai-dynamo --find-links wheelhouse && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can do
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will update in upcoming PRs. |
||
uv pip install ai-dynamo-runtime --find-links wheelhouse && \ | ||
uv pip install nixl --find-links wheelhouse && \ | ||
ln -sf $VIRTUAL_ENV/bin/* /usr/local/bin/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think updating PATH variable is generally better than symlink? |
||
|
||
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing | ||
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so" | ||
|
@@ -403,8 +452,9 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la | |
sed '/^#\s/d' /workspace/launch_message.txt > ~/.launch_screen && \ | ||
echo "cat ~/.launch_screen" >> ~/.bashrc | ||
|
||
# Copy examples | ||
COPY ./examples examples/ | ||
# Copy examples and set up Python path | ||
COPY . /workspace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we copy specific folders, I think examples, tests, and benchmarks copy should do? |
||
ENV PYTHONPATH=/workspace/examples/sglang/utils:$PYTHONPATH | ||
|
||
ENTRYPOINT [ "/usr/bin/bash" ] | ||
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"] | ||
CMD [] |
Uh oh!
There was an error while loading. Please reload this page.