Skip to content

Commit a2cb1c3

Browse files
feat: update python packaging for new dynamo UX (#2054)
Signed-off-by: Anant Sharma <anants@nvidia.com> Co-authored-by: Anant Sharma <anants@nvidia.com>
1 parent ff92053 commit a2cb1c3

File tree

13 files changed

+67
-133
lines changed

13 files changed

+67
-133
lines changed

Earthfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ dynamo-build:
105105
FROM +rust-base
106106
WORKDIR /workspace
107107
COPY Cargo.toml Cargo.lock ./
108-
COPY pyproject.toml README.md hatch_build.py ./
108+
COPY pyproject.toml README.md ./
109109
COPY components/ components/
110110
COPY lib/ lib/
111111
COPY launch/ launch/

components/backends/sglang/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

components/backends/vllm/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

container/Dockerfile.sglang

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

29+
# Make sure to update the dependency version in pyproject.toml when updating this
2930
ARG SGLANG_VERSION="0.4.9.post1"
30-
ARG SGL_KERNEL_VERSION="0.2.4"
3131

3232
##################################
3333
########## Base Image ############
@@ -116,7 +116,7 @@ RUN git clone "https://github.com/ai-dynamo/nixl.git" ${NIXL_SRC_DIR} && \
116116
cd ${NIXL_SRC_DIR} && \
117117
git checkout ${NIXL_REF} && \
118118
if [ "$ARCH" = "arm64" ]; then \
119-
nixl_build_args="-Ddisable_gds_backend=true -Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
119+
nixl_build_args="-Ddisable_gds_backend=true"; \
120120
else \
121121
nixl_build_args=""; \
122122
fi && \
@@ -155,7 +155,7 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
155155
# TEMP: disable gds backend for arm64
156156
RUN if [ "$ARCH" = "arm64" ]; then \
157157
cd ${NIXL_SRC_DIR} && uv build . --out-dir /workspace/wheels/nixl \
158-
--config-settings=setup-args="-Ddisable_gds_backend=true -Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
158+
--config-settings=setup-args="-Ddisable_gds_backend=true"; \
159159
else \
160160
cd ${NIXL_SRC_DIR} && uv build . --out-dir /workspace/wheels/nixl; \
161161
fi && \
@@ -269,8 +269,6 @@ RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=$HOME/.comman
269269

270270
RUN mkdir -p /home/$USERNAME/.cache/
271271

272-
ENV VLLM_KV_CAPI_PATH=$HOME/dynamo/.build/target/debug/libdynamo_llm_capi.so
273-
274272
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]
275273

276274
##################################
@@ -321,7 +319,6 @@ COPY LICENSE /workspace/
321319
COPY Cargo.toml /workspace/
322320
COPY Cargo.lock /workspace/
323321
COPY rust-toolchain.toml /workspace/
324-
COPY hatch_build.py /workspace/
325322

326323
# Copy source code
327324
COPY lib/ /workspace/lib/
@@ -364,18 +361,11 @@ COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME
364361
# Copy rest of the code
365362
COPY . /workspace
366363

367-
# Build C bindings, creates lib/bindings/c/include
368-
RUN cd /workspace/lib/bindings/c && cargo build --release --locked
369-
370364
# Package the bindings
371365
RUN mkdir -p /opt/dynamo/bindings/wheels && \
372366
mkdir /opt/dynamo/bindings/lib && \
373367
cp dist/ai_dynamo*cp312*.whl /opt/dynamo/bindings/wheels/. && \
374-
cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
375-
cp -r lib/bindings/c/include /opt/dynamo/bindings/. && \
376-
cp target/release/dynamo-run /usr/local/bin && \
377-
cp target/release/metrics /usr/local/bin && \
378-
cp target/release/mock_worker /usr/local/bin
368+
cp target/release/metrics /usr/local/bin
379369

380370
RUN uv pip install /workspace/dist/ai_dynamo_runtime*cp312*.whl && \
381371
uv pip install /workspace/dist/ai_dynamo*any.whl
@@ -385,9 +375,6 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la
385375
sed '/^#\s/d' /workspace/launch_message.txt > ~/.launch_screen && \
386376
echo "cat ~/.launch_screen" >> ~/.bashrc
387377

388-
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
389-
ENV VLLM_KV_CAPI_PATH=/opt/dynamo/bindings/lib/libdynamo_llm_capi.so
390-
391378
ENV PYTHONPATH=/workspace/dynamo/deploy/sdk/src:/workspace/dynamo/components/planner/src:/workspace/examples/sglang/utils:$PYTHONPATH
392379

393380
########################################
@@ -442,21 +429,13 @@ RUN apt-get update && \
442429
uv venv $VIRTUAL_ENV --python 3.12 && \
443430
echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc
444431

445-
# Install SGLang and related packages (sgl-kernel, einops, sentencepiece) since they are not included in the runtime wheel
446-
# https://github.com/sgl-project/sglang/blob/v0.4.9.post1/python/pyproject.toml#L18-51
447-
ARG SGLANG_VERSION
448-
ARG SGL_KERNEL_VERSION
449-
RUN --mount=type=cache,target=/root/.cache/uv \
450-
uv pip install sglang[runtime_common]==${SGLANG_VERSION} einops sgl-kernel==${SGL_KERNEL_VERSION} sentencepiece
451-
452432
# Install the wheels and symlink executables to /usr/local/bin so dynamo components can use them
433+
# Copy metrics binary from wheel_builder image, not part of ai-dynamo wheel
453434
# Dynamo components currently do not have the VIRTUAL_ENV in their PATH, so we need to symlink the executables
435+
COPY --from=ci_minimum /workspace/target/release/metrics /usr/local/bin/metrics
454436
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
455437
COPY --from=base /workspace/wheels/nixl/*.whl wheelhouse/
456-
RUN uv pip install ai-dynamo nixl --find-links wheelhouse
457-
458-
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
459-
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so"
438+
RUN uv pip install ai-dynamo[sglang] --find-links wheelhouse
460439

461440
# Copy launch banner
462441
RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/launch_message.txt \

container/Dockerfile.tensorrt_llm

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ RUN git clone "https://github.com/ai-dynamo/nixl.git" ${NIXL_SRC_DIR} && \
110110
cd ${NIXL_SRC_DIR} && \
111111
git checkout ${NIXL_REF} && \
112112
if [ "$ARCH" = "arm64" ]; then \
113-
nixl_build_args="-Ddisable_gds_backend=true -Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
113+
nixl_build_args="-Ddisable_gds_backend=true"; \
114114
else \
115115
nixl_build_args=""; \
116116
fi && \
@@ -220,7 +220,7 @@ ENV VIRTUAL_ENV=/opt/dynamo/venv
220220
# TEMP: disable gds backend for arm64
221221
RUN if [ "$ARCH" = "arm64" ]; then \
222222
cd ${NIXL_SRC_DIR} && uv build . --out-dir /workspace/wheels/nixl \
223-
--config-settings=setup-args="-Ddisable_gds_backend=true -Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
223+
--config-settings=setup-args="-Ddisable_gds_backend=true"; \
224224
else \
225225
cd ${NIXL_SRC_DIR} && uv build . --out-dir /workspace/wheels/nixl; \
226226
fi && \
@@ -273,7 +273,6 @@ COPY LICENSE /workspace/
273273
COPY Cargo.toml /workspace/
274274
COPY Cargo.lock /workspace/
275275
COPY rust-toolchain.toml /workspace/
276-
COPY hatch_build.py /workspace/
277276

278277
# Copy source code
279278
COPY lib/ /workspace/lib/
@@ -311,18 +310,11 @@ COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME
311310
# Copy rest of the code
312311
COPY . /workspace
313312

314-
# Build C bindings, creates lib/bindings/c/include
315-
RUN cd /workspace/lib/bindings/c && cargo build --release --locked
316-
317313
# Package the bindings
318314
RUN mkdir -p /opt/dynamo/bindings/wheels && \
319315
mkdir /opt/dynamo/bindings/lib && \
320316
cp dist/ai_dynamo*cp312*.whl /opt/dynamo/bindings/wheels/. && \
321-
cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
322-
cp -r lib/bindings/c/include /opt/dynamo/bindings/. && \
323-
cp target/release/dynamo-run /usr/local/bin && \
324-
cp target/release/metrics /usr/local/bin && \
325-
cp target/release/mock_worker /usr/local/bin
317+
cp target/release/metrics /usr/local/bin
326318

327319
# Install wheels
328320
RUN . /opt/dynamo/venv/bin/activate && \
@@ -484,8 +476,10 @@ ARG TENSORRTLLM_PIP_WHEEL="tensorrt-llm"
484476
ARG TENSORRTLLM_INDEX_URL="https://pypi.python.org/simple"
485477

486478
# Copy Dynamo wheels into wheelhouse
479+
# Copy metrics binary from wheel_builder image, not part of ai-dynamo wheel
487480
COPY --from=dev /workspace/wheels/nixl/*.whl wheelhouse/
488481
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
482+
COPY --from=dev /workspace/target/release/metrics /usr/local/bin/metrics
489483

490484
# NOTE: If a package (tensorrt_llm) exists on both --index-url and --extra-index-url,
491485
# uv will prioritize the --extra-index-url, unless --index-strategy unsafe-best-match

container/Dockerfile.vllm

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ ARG TORCH_BACKEND="cu128"
1818
ARG DEEPGEMM_REF="03d0be3"
1919
ARG FLASHINF_REF="1d72ed4"
2020

21+
# Make sure to update the dependency version in pyproject.toml when updating this
22+
ARG VLLM_VERSION="0.9.2"
23+
2124
# Define general architecture ARGs for supporting both x86 and aarch64 builds.
2225
# ARCH: Used for package suffixes (e.g., amd64, arm64)
2326
# ARCH_ALT: Used for Rust targets, manylinux suffix (e.g., x86_64, aarch64)
@@ -39,10 +42,11 @@ ARG ARCH_ALT=x86_64
3942

4043
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS base
4144

42-
# Redeclare ARCH, ARCH_ALT, TORCH_BACKEND so they're available in this stage
45+
# Redeclare ARCH, ARCH_ALT, TORCH_BACKEND, VLLM_VERSION so they're available in this stage
4346
ARG ARCH
4447
ARG ARCH_ALT
4548
ARG TORCH_BACKEND
49+
ARG VLLM_VERSION
4650

4751
USER root
4852
ARG PYTHON_VERSION=3.12
@@ -134,7 +138,7 @@ RUN git clone "https://github.com/ai-dynamo/nixl.git" ${NIXL_SRC_DIR} && \
134138
cd ${NIXL_SRC_DIR} && \
135139
git checkout ${NIXL_REF} && \
136140
if [ "$ARCH" = "arm64" ]; then \
137-
nixl_build_args="-Ddisable_gds_backend=true -Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
141+
nixl_build_args="-Ddisable_gds_backend=true"; \
138142
else \
139143
nixl_build_args=""; \
140144
fi && \
@@ -171,8 +175,7 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
171175
# TEMP: disable gds backend for arm64
172176
RUN if [ "$ARCH" = "arm64" ]; then \
173177
cd ${NIXL_SRC_DIR} && uv build . --out-dir /workspace/wheels/nixl \
174-
--config-settings=setup-args="-Ddisable_gds_backend=true" \
175-
--config-settings=setup-args="-Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
178+
--config-settings=setup-args="-Ddisable_gds_backend=true"; \
176179
else \
177180
cd ${NIXL_SRC_DIR} && uv build . --out-dir /workspace/wheels/nixl; \
178181
fi && \
@@ -190,13 +193,17 @@ ARG MAX_JOBS=16
190193
ENV MAX_JOBS=$MAX_JOBS
191194
ENV CUDA_HOME=/usr/local/cuda
192195

193-
# TODO - split vllm, DeepEP, DeepGeMM, PPLX installs
194-
# Should be able to select how you want your build to go
195196
RUN --mount=type=bind,source=./container/deps/,target=/tmp/deps \
196197
--mount=type=cache,target=/root/.cache/uv \
197-
cp /tmp/deps/vllm/install_vllm.sh /tmp/install_vllm.sh && \
198-
chmod +x /tmp/install_vllm.sh && \
199-
/tmp/install_vllm.sh --editable --vllm-ref $VLLM_REF --max-jobs $MAX_JOBS --arch $ARCH --installation-dir /opt --deepgemm-ref $DEEPGEMM_REF --flashinf-ref $FLASHINF_REF --torch-backend $TORCH_BACKEND
198+
if [ "$ARCH" = "arm64" ]; then \
199+
# TODO - split vllm, DeepEP, DeepGeMM, PPLX installs
200+
# Should be able to select how you want your build to go
201+
cp /tmp/deps/vllm/install_vllm.sh /tmp/install_vllm.sh && \
202+
chmod +x /tmp/install_vllm.sh && \
203+
/tmp/install_vllm.sh --editable --vllm-ref $VLLM_REF --max-jobs $MAX_JOBS --arch $ARCH --installation-dir /opt --deepgemm-ref $DEEPGEMM_REF --flashinf-ref $FLASHINF_REF --torch-backend $TORCH_BACKEND; \
204+
else \
205+
uv pip install "vllm==${VLLM_VERSION}"; \
206+
fi
200207

201208
ENV LD_LIBRARY_PATH=\
202209
/opt/vllm/tools/ep_kernels/ep_kernels_workspace/nvshmem_install/lib:\
@@ -348,7 +355,6 @@ COPY LICENSE /workspace/
348355
COPY Cargo.toml /workspace/
349356
COPY Cargo.lock /workspace/
350357
COPY rust-toolchain.toml /workspace/
351-
COPY hatch_build.py /workspace/
352358

353359
# Copy source code
354360
COPY lib/ /workspace/lib/
@@ -392,22 +398,11 @@ COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME
392398
# Copy rest of the code
393399
COPY . /workspace
394400

395-
# Build C bindings, creates lib/bindings/c/include
396-
#
397-
# TODO: In theory the 'cargo build' in earlier stage covers this, we "just" need to copy the
398-
# `lib/bindings/c/include` folder that build.rs generated across.
399-
# I couldn't get that to work, hence TODO.
400-
RUN cd /workspace/lib/bindings/c && cargo build --release --locked
401-
402401
# Package the bindings
403402
RUN mkdir -p /opt/dynamo/bindings/wheels && \
404403
mkdir /opt/dynamo/bindings/lib && \
405404
cp dist/ai_dynamo*cp312*.whl /opt/dynamo/bindings/wheels/. && \
406-
cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
407-
cp -r lib/bindings/c/include /opt/dynamo/bindings/. && \
408-
cp target/release/dynamo-run /usr/local/bin && \
409-
cp target/release/metrics /usr/local/bin && \
410-
cp target/release/mock_worker /usr/local/bin
405+
cp target/release/metrics /usr/local/bin
411406

412407
RUN uv pip install /workspace/dist/ai_dynamo_runtime*cp312*.whl && \
413408
uv pip install /workspace/dist/ai_dynamo*any.whl
@@ -455,9 +450,6 @@ RUN apt-get update && \
455450
cuda-toolkit-12-8 && \
456451
rm -rf /var/lib/apt/lists/*
457452

458-
### COPY BINDINGS ###
459-
# Copy all bindings (wheels, lib, include) from ci_minimum
460-
COPY --from=ci_minimum /opt/dynamo/bindings /opt/dynamo/bindings
461453
### COPY NATS & ETCD ###
462454
# Copy nats and etcd from base image
463455
COPY --from=base /usr/bin/nats-server /usr/bin/nats-server
@@ -466,11 +458,16 @@ ENV PATH=/usr/local/bin/etcd/:$PATH
466458

467459
# Copy UCX from base image as plugin for NIXL
468460
# Copy NIXL source from wheel_builder image
461+
# Copy dynamo wheels for gitlab artifacts
469462
COPY --from=base /usr/local/ucx /usr/local/ucx
470463
COPY --from=wheel_builder $NIXL_PREFIX $NIXL_PREFIX
464+
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
471465

472466
# Copies vllm, DeepEP, DeepGEMM, PPLX repos (all editable installs) and nvshmem binaries
473-
COPY --from=base /opt/vllm /opt/vllm
467+
RUN if [ "$ARCH" = "arm64" ]; then \
468+
COPY --from=base /opt/vllm /opt/vllm; \
469+
fi
470+
474471
ENV LD_LIBRARY_PATH=\
475472
/opt/vllm/tools/ep_kernels/ep_kernels_workspace/nvshmem_install/lib:\
476473
$NIXL_LIB_DIR:\
@@ -479,10 +476,11 @@ $NIXL_PLUGIN_DIR:\
479476
/usr/local/ucx/lib/ucx:\
480477
$LD_LIBRARY_PATH
481478

482-
483479
# Copy entire venv
484-
# Theres a lot of stuff we'd have to re-compile
485-
# Think its better to just copy
480+
# Theres a lot of stuff we'd have to re-compile (for arm64)
481+
# TODO: use pip ai-dynamo[vllm] in venv to replicate end user environment
482+
# Copy metrics binary from wheel_builder image, not part of ai-dynamo wheel
483+
COPY --from=ci_minimum /workspace/target/release/metrics /usr/local/bin/metrics
486484
COPY --from=ci_minimum ${VIRTUAL_ENV} ${VIRTUAL_ENV}
487485

488486
# Once UX refactor is merged

deploy/sdk/src/dynamo/sdk/tests/test_e2e_args.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
from dynamo.sdk.cli.cli import cli
2424

25-
pytestmark = pytest.mark.pre_merge
2625
runner = CliRunner()
2726

2827

deploy/sdk/src/dynamo/sdk/tests/test_e2e_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
from dynamo.sdk.cli.cli import cli
2525

26-
pytestmark = pytest.mark.pre_merge
2726
runner = CliRunner()
2827

2928

deploy/sdk/src/dynamo/sdk/tests/test_link.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
import pytest
1716

1817
from dynamo.sdk.core.protocol.interface import LinkedServices
1918

20-
pytestmark = pytest.mark.pre_merge
21-
2219

2320
def test_remove_backend2():
2421
from dynamo.sdk.tests.pipeline import Backend, Backend2, Frontend, Middle

0 commit comments

Comments
 (0)