Skip to content

Commit 33b312c

Browse files
R3hankhan123skyloevil
authored andcommitted
[Hardware][IBM Z] Fix Outlines Core issue for s390x (vllm-project#24034)
Signed-off-by: Rehan Khan <[email protected]>
1 parent 5e67769 commit 33b312c

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

docker/Dockerfile.s390x

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ ENV LANG=C.UTF-8 \
1616
RUN microdnf install -y \
1717
which procps findutils tar vim git gcc gcc-gfortran g++ make patch zlib-devel \
1818
libjpeg-turbo-devel libtiff-devel libpng-devel libwebp-devel freetype-devel harfbuzz-devel \
19-
openssl-devel openblas openblas-devel autoconf automake libtool cmake numpy libsndfile && \
19+
openssl-devel openblas openblas-devel autoconf automake libtool cmake numpy libsndfile \
20+
clang llvm-devel llvm-static clang-devel && \
2021
microdnf clean all
2122

2223
# Python Installation
@@ -191,7 +192,6 @@ RUN --mount=type=cache,target=/root/.cache/uv \
191192
-DCOMPILER_RT_BUILD_ORC=OFF \
192193
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
193194
${CMAKE_ARGS} -GNinja ../llvm \
194-
195195
&& ninja install . && \
196196
# build llvmlite
197197
cd ../../llvmlite && python setup.py bdist_wheel && \
@@ -200,6 +200,45 @@ RUN --mount=type=cache,target=/root/.cache/uv \
200200
sed -i '/#include "internal\/pycore_atomic.h"/i\#include "dynamic_annotations.h"' numba/_dispatcher.cpp; \
201201
fi && python setup.py bdist_wheel
202202

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
222+
223+
# Build Outlines Core
224+
FROM python-install AS outlines-core-builder
225+
WORKDIR /tmp
226+
ENV CARGO_HOME=/root/.cargo
227+
ENV RUSTUP_HOME=/root/.rustup
228+
ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
229+
ARG OUTLINES_CORE_VERSION=0.2.10
230+
RUN --mount=type=cache,target=/root/.cache/uv \
231+
--mount=type=bind,from=rust,source=/root/.cargo,target=/root/.cargo,rw \
232+
--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 \
234+
git clone https://github.com/dottxt-ai/outlines-core.git && \
235+
cd outlines-core && \
236+
git checkout tags/${OUTLINES_CORE_VERSION} && \
237+
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 && \
240+
uv pip install maturin && \
241+
python -m maturin build --release --out dist
203242

204243
# Final build stage
205244
FROM python-install AS vllm-cpu
@@ -230,20 +269,23 @@ RUN --mount=type=cache,target=/root/.cache/uv \
230269
--mount=type=bind,from=torch,source=/tmp/pytorch/dist,target=/tmp/torch-wheels/ \
231270
--mount=type=bind,from=numba-builder,source=/tmp/llvmlite/dist,target=/tmp/llvmlite-wheels/ \
232271
--mount=type=bind,from=numba-builder,source=/tmp/numba/dist,target=/tmp/numba-wheels/ \
272+
--mount=type=bind,from=outlines-core-builder,source=/tmp/outlines-core/dist,target=/tmp/outlines-core/dist/ \
233273
sed -i '/^torch/d' requirements/build.txt && \
234274
ARROW_WHL_FILE=$(ls /tmp/arrow-wheels/pyarrow-*.whl) && \
235275
VISION_WHL_FILE=$(ls /tmp/vision-wheels/*.whl) && \
236276
HF_XET_WHL_FILE=$(ls /tmp/hf-xet-wheels/*.whl) && \
237277
TORCH_WHL_FILE=$(ls /tmp/torch-wheels/*.whl) && \
238278
LLVM_WHL_FILE=$(ls /tmp/llvmlite-wheels/*.whl) && \
239279
NUMBA_WHL_FILE=$(ls /tmp/numba-wheels/*.whl) && \
280+
OUTLINES_CORE_WHL_FILE=$(ls /tmp/outlines-core/dist/*.whl) && \
240281
uv pip install -v \
241282
$ARROW_WHL_FILE \
242283
$VISION_WHL_FILE \
243284
$HF_XET_WHL_FILE \
244285
$TORCH_WHL_FILE \
245286
$LLVM_WHL_FILE \
246287
$NUMBA_WHL_FILE \
288+
$OUTLINES_CORE_WHL_FILE \
247289
--index-strategy unsafe-best-match \
248290
-r requirements/build.txt \
249291
-r requirements/cpu.txt

requirements/common.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ prometheus-fastapi-instrumentator >= 7.0.0
2020
tiktoken >= 0.6.0 # Required for DBRX tokenizer
2121
lm-format-enforcer == 0.11.3
2222
llguidance >= 0.7.11, < 0.8.0; platform_machine == "x86_64" or platform_machine == "arm64" or platform_machine == "aarch64"
23-
outlines_core == 0.2.10 ; platform_machine != "s390x"
24-
outlines == 0.1.11 ; platform_machine == "s390x"
23+
outlines_core == 0.2.10
2524
# required for outlines backend disk cache
2625
diskcache == 5.6.3
2726
lark == 1.2.2

0 commit comments

Comments
 (0)