Skip to content

Commit e044924

Browse files
authored
[Hardware][IBM Z] Optimize s390x Dockerfile (#28023)
Signed-off-by: Rehan Khan <[email protected]>
1 parent 518ec6b commit e044924

File tree

3 files changed

+14
-60
lines changed

3 files changed

+14
-60
lines changed

docker/Dockerfile.s390x

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ENV LANG=C.UTF-8 \
1414

1515
# Install development utilities
1616
RUN microdnf install -y \
17-
which procps findutils tar vim git gcc gcc-gfortran g++ make patch zlib-devel \
17+
which procps findutils tar vim git gcc-toolset-14 gcc-toolset-14-libatomic-devel patch zlib-devel \
1818
libjpeg-turbo-devel libtiff-devel libpng-devel libwebp-devel freetype-devel harfbuzz-devel \
1919
openssl-devel openblas openblas-devel autoconf automake libtool cmake numpy libsndfile \
2020
clang llvm-devel llvm-static clang-devel && \
@@ -85,40 +85,15 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
8585
rustup default stable && \
8686
rustup show
8787

88-
FROM python-install AS torch
89-
ARG TORCH_VERSION=2.7.0
90-
ENV export _GLIBCXX_USE_CXX11_ABI=1
91-
ENV CARGO_HOME=/root/.cargo
92-
ENV RUSTUP_HOME=/root/.rustup
93-
ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
94-
95-
WORKDIR /tmp
96-
97-
RUN --mount=type=cache,target=/root/.cache/uv \
98-
--mount=type=bind,from=rust,source=/root/.cargo,target=/root/.cargo,rw \
99-
--mount=type=bind,from=rust,source=/root/.rustup,target=/root/.rustup,rw \
100-
git clone https://github.com/pytorch/pytorch.git && \
101-
cd pytorch && \
102-
git checkout v2.7.0 && \
103-
git submodule sync && \
104-
git submodule update --init --recursive && \
105-
uv pip install cmake ninja && \
106-
uv pip install -r requirements.txt && \
107-
python setup.py bdist_wheel
108-
109-
11088
FROM python-install AS torch-vision
11189
# Install torchvision
112-
ARG TORCH_VERSION=2.7.0
113-
ARG TORCH_VISION_VERSION=v0.20.1
90+
ARG TORCH_VISION_VERSION=v0.23.0
11491
WORKDIR /tmp
11592
RUN --mount=type=cache,target=/root/.cache/uv \
116-
--mount=type=bind,from=torch,source=/tmp/pytorch/dist,target=/tmp/torch-wheels/ \
11793
git clone https://github.com/pytorch/vision.git && \
11894
cd vision && \
11995
git checkout $TORCH_VISION_VERSION && \
120-
TORCH_WHL_FILE=$(ls /tmp/torch-wheels/*.whl | head -n 1) && \
121-
uv pip install -v $TORCH_WHL_FILE && \
96+
uv pip install torch==2.8.0 --index-url https://download.pytorch.org/whl/cpu && \
12297
python setup.py bdist_wheel
12398

12499
FROM python-install AS hf-xet-builder
@@ -199,44 +174,24 @@ RUN --mount=type=cache,target=/root/.cache/uv \
199174
if ! grep '#include "dynamic_annotations.h"' numba/_dispatcher.cpp; then \
200175
sed -i '/#include "internal\/pycore_atomic.h"/i\#include "dynamic_annotations.h"' numba/_dispatcher.cpp; \
201176
fi && python setup.py bdist_wheel
202-
203-
# Edit aws-lc-sys to support s390x
204-
FROM python-install AS aws-lc-sys-editor
205-
WORKDIR /tmp
206-
ENV CARGO_HOME=/root/.cargo
207-
ENV RUSTUP_HOME=/root/.rustup
208-
ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
209-
ARG AWS_LC_VERSION=v0.30.0
210-
RUN --mount=type=cache,target=/root/.cache/uv \
211-
--mount=type=bind,from=rust,source=/root/.cargo,target=/root/.cargo,rw \
212-
--mount=type=bind,from=rust,source=/root/.rustup,target=/root/.rustup,rw \
213-
git clone --recursive https://github.com/aws/aws-lc-rs.git && \
214-
cd aws-lc-rs && \
215-
git checkout tags/aws-lc-sys/${AWS_LC_VERSION} && \
216-
git submodule sync && \
217-
git submodule update --init --recursive && \
218-
cd aws-lc-sys && \
219-
sed -i '682 s/strncmp(buf, "-----END ", 9)/memcmp(buf, "-----END ", 9)/' aws-lc/crypto/pem/pem_lib.c && \
220-
sed -i '712 s/strncmp(buf, "-----END ", 9)/memcmp(buf, "-----END ", 9)/' aws-lc/crypto/pem/pem_lib.c && \
221-
sed -i '747 s/strncmp(buf, "-----END ", 9)/memcmp(buf, "-----END ", 9)/' aws-lc/crypto/pem/pem_lib.c
222177

223178
# Build Outlines Core
224179
FROM python-install AS outlines-core-builder
225180
WORKDIR /tmp
226181
ENV CARGO_HOME=/root/.cargo
227182
ENV RUSTUP_HOME=/root/.rustup
228183
ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
229-
ARG OUTLINES_CORE_VERSION=0.2.10
184+
COPY requirements/common.txt /tmp/requirements/common.txt
185+
ARG OUTLINES_CORE_VERSION
230186
RUN --mount=type=cache,target=/root/.cache/uv \
231187
--mount=type=bind,from=rust,source=/root/.cargo,target=/root/.cargo,rw \
232188
--mount=type=bind,from=rust,source=/root/.rustup,target=/root/.rustup,rw \
233-
--mount=type=bind,from=aws-lc-sys-editor,source=/tmp/aws-lc-rs/aws-lc-sys,target=/tmp/aws-lc-sys,rw \
189+
OUTLINES_CORE_VERSION=${OUTLINES_CORE_VERSION:-$(grep -E '^outlines_core\s*==\s*[0-9.]+' /tmp/requirements/common.txt | grep -Eo '[0-9.]+')} && \
190+
if [ -z "${OUTLINES_CORE_VERSION}" ]; then echo "ERROR: Could not determine outlines_core version"; exit 1; fi && \
234191
git clone https://github.com/dottxt-ai/outlines-core.git && \
235192
cd outlines-core && \
236193
git checkout tags/${OUTLINES_CORE_VERSION} && \
237194
sed -i "s/version = \"0.0.0\"/version = \"${OUTLINES_CORE_VERSION}\"/" Cargo.toml && \
238-
echo '[patch.crates-io]' >> Cargo.toml && \
239-
echo 'aws-lc-sys = { path = "/tmp/aws-lc-sys" }' >> Cargo.toml && \
240195
uv pip install maturin && \
241196
python -m maturin build --release --out dist
242197

@@ -245,13 +200,15 @@ FROM python-install AS vllm-cpu
245200
ARG PYTHON_VERSION
246201

247202
# Set correct library path for torch and numactl
248-
ENV LD_LIBRARY_PATH="/opt/vllm/lib64/python${PYTHON_VERSION}/site-packages/torch/lib:/usr/local/lib:$LD_LIBRARY_PATH"
203+
ENV LD_LIBRARY_PATH="/opt/vllm/lib64/python${PYTHON_VERSION}/site-packages/torch/lib:/usr/local/lib:/opt/rh/gcc-toolset-14/root/usr/lib64:$LD_LIBRARY_PATH"
249204
ENV C_INCLUDE_PATH="/usr/local/include:$C_INCLUDE_PATH"
250205
ENV UV_LINK_MODE=copy
251206
ENV CARGO_HOME=/root/.cargo
252207
ENV RUSTUP_HOME=/root/.rustup
253-
ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
254208
ENV GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
209+
ENV PCP_DIR=/opt/rh/gcc-toolset-14/root
210+
ENV PKG_CONFIG_PATH="/opt/rh/gcc-toolset-14/root/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig/"
211+
ENV PATH="${VIRTUAL_ENV:+${VIRTUAL_ENV}/bin}:/opt/rh/gcc-toolset-14/root/usr/bin:/usr/local/bin:$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
255212

256213
COPY . /workspace/vllm
257214
WORKDIR /workspace/vllm
@@ -266,23 +223,20 @@ RUN --mount=type=cache,target=/root/.cache/uv \
266223
--mount=type=bind,from=pyarrow,source=/tmp/arrow/python/dist,target=/tmp/arrow-wheels \
267224
--mount=type=bind,from=torch-vision,source=/tmp/vision/dist,target=/tmp/vision-wheels/ \
268225
--mount=type=bind,from=hf-xet-builder,source=/tmp/hf-xet/dist,target=/tmp/hf-xet-wheels/ \
269-
--mount=type=bind,from=torch,source=/tmp/pytorch/dist,target=/tmp/torch-wheels/ \
270226
--mount=type=bind,from=numba-builder,source=/tmp/llvmlite/dist,target=/tmp/llvmlite-wheels/ \
271227
--mount=type=bind,from=numba-builder,source=/tmp/numba/dist,target=/tmp/numba-wheels/ \
272228
--mount=type=bind,from=outlines-core-builder,source=/tmp/outlines-core/dist,target=/tmp/outlines-core/dist/ \
273229
sed -i '/^torch/d' requirements/build.txt && \
274230
ARROW_WHL_FILE=$(ls /tmp/arrow-wheels/pyarrow-*.whl) && \
275231
VISION_WHL_FILE=$(ls /tmp/vision-wheels/*.whl) && \
276232
HF_XET_WHL_FILE=$(ls /tmp/hf-xet-wheels/*.whl) && \
277-
TORCH_WHL_FILE=$(ls /tmp/torch-wheels/*.whl) && \
278233
LLVM_WHL_FILE=$(ls /tmp/llvmlite-wheels/*.whl) && \
279234
NUMBA_WHL_FILE=$(ls /tmp/numba-wheels/*.whl) && \
280235
OUTLINES_CORE_WHL_FILE=$(ls /tmp/outlines-core/dist/*.whl) && \
281236
uv pip install -v \
282237
$ARROW_WHL_FILE \
283238
$VISION_WHL_FILE \
284239
$HF_XET_WHL_FILE \
285-
$TORCH_WHL_FILE \
286240
$LLVM_WHL_FILE \
287241
$NUMBA_WHL_FILE \
288242
$OUTLINES_CORE_WHL_FILE \

requirements/common.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ pillow # Required for image processing
1919
prometheus-fastapi-instrumentator >= 7.0.0
2020
tiktoken >= 0.6.0 # Required for DBRX tokenizer
2121
lm-format-enforcer == 0.11.3
22-
llguidance >= 0.7.11, < 0.8.0; platform_machine == "x86_64" or platform_machine == "arm64" or platform_machine == "aarch64"
22+
llguidance >= 0.7.11, < 0.8.0; platform_machine == "x86_64" or platform_machine == "arm64" or platform_machine == "aarch64" or platform_machine == "s390x"
2323
outlines_core == 0.2.11
2424
# required for outlines backend disk cache
2525
diskcache == 5.6.3
2626
lark == 1.2.2
27-
xgrammar == 0.1.25; platform_machine == "x86_64" or platform_machine == "aarch64" or platform_machine == "arm64"
27+
xgrammar == 0.1.25; platform_machine == "x86_64" or platform_machine == "aarch64" or platform_machine == "arm64" or platform_machine == "s390x"
2828
typing_extensions >= 4.10
2929
filelock >= 3.16.1 # need to contain https://github.com/tox-dev/filelock/pull/317
3030
partial-json-parser # used for parsing partial JSON outputs

requirements/cpu.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ numba == 0.61.2; platform_machine != "s390x" # Required for N-gram speculative d
77
packaging>=24.2
88
setuptools>=77.0.3,<80.0.0
99
--extra-index-url https://download.pytorch.org/whl/cpu
10-
torch==2.8.0+cpu; platform_machine == "x86_64"
10+
torch==2.8.0+cpu; platform_machine == "x86_64" or platform_machine == "s390x"
1111
torch==2.8.0; platform_system == "Darwin"
1212
torch==2.8.0; platform_machine == "ppc64le" or platform_machine == "aarch64"
1313

0 commit comments

Comments
 (0)