main
sh 89 lines 3.58 KB
Raw
1 #!/bin/bash
2
3 # This script builds the HPU docker image and runs the offline inference inside the container.
4 # It serves a sanity check for compilation and basic model usage.
5 #
6 # vllm-gaudi compatibility pinning:
7 # The vllm-gaudi plugin is installed on top of the vllm upstream checkout used by this CI job.
8 # When upstream vllm changes its API, the plugin may break before it has been updated.
9 # To handle this, the vllm-gaudi repository maintains a file:
10 # vllm/last-good-commit-for-vllm-gaudi/VLLM_COMMUNITY_COMMIT
11 # The first line of that file controls what version of vllm is used inside the Docker image:
12 # - "latest" : no checkout override; the current Buildkite CI commit is used as-is.
13 # - "<commit SHA>" : vllm is checked out to that specific commit before building, pinning
14 # the test to a known-compatible baseline.
15 # To unpin (resume testing against the live vllm tip), set the file content back to "latest".
16 set -exuo pipefail
17
18 # Fetch the vllm community commit reference from vllm-gaudi (first line only).
19 VLLM_COMMUNITY_COMMIT=$(curl -s \
20 https://raw.githubusercontent.com/vllm-project/vllm-gaudi/vllm/last-good-commit-for-vllm-gaudi/VLLM_COMMUNITY_COMMIT \
21 | head -1 | tr -d '\n')
22
23 echo "Using vllm community commit: ${VLLM_COMMUNITY_COMMIT}"
24
25 # Try building the docker image
26 image_name="hpu/upstream-vllm-ci:${BUILDKITE_COMMIT}"
27 container_name="hpu-upstream-vllm-ci-${BUILDKITE_COMMIT}-container"
28 cat <<EOF | docker build -t "${image_name}" -f - .
29 FROM gaudi-base-image:latest
30
31 COPY ./ /workspace/vllm
32
33 # If VLLM_COMMUNITY_COMMIT is a specific commit (not "latest"), check it out to pin vllm
34 # to the version known to be compatible with vllm-gaudi. When the value is "latest",
35 # the current checkout (the Buildkite CI commit) is used unchanged.
36 RUN if [ "${VLLM_COMMUNITY_COMMIT}" != "latest" ]; then \
37 cd /workspace/vllm && git fetch --unshallow 2>/dev/null || true && git checkout ${VLLM_COMMUNITY_COMMIT}; \
38 fi
39
40 WORKDIR /workspace/vllm
41
42 ENV no_proxy=localhost,127.0.0.1
43 ENV PT_HPU_ENABLE_LAZY_COLLECTIVES=true
44
45 RUN bash -c 'pip install -r <(sed "/^torch/d" requirements/build/cuda.txt)'
46 RUN VLLM_TARGET_DEVICE=empty pip install --no-build-isolation -e .
47 RUN pip install git+https://github.com/vllm-project/vllm-gaudi.git
48
49 # install development dependencies (for testing)
50 RUN python3 -m pip install -e tests/vllm_test_utils
51
52 WORKDIR /workspace/
53
54 RUN git clone https://github.com/vllm-project/vllm-gaudi.git
55
56 RUN ln -s /workspace/vllm/tests && ln -s /workspace/vllm/examples && ln -s /workspace/vllm/benchmarks
57
58 EOF
59
60 # Setup cleanup
61 # certain versions of HPU software stack have a bug that can
62 # override the exit code of the script, so we need to use
63 # separate remove_docker_containers and remove_docker_containers_and_exit
64 # functions, while other platforms only need one remove_docker_container
65 # function.
66 EXITCODE=1
67 remove_docker_containers() { docker rm -f "${container_name}" || true; }
68 trap 'remove_docker_containers; exit $EXITCODE;' EXIT
69 remove_docker_containers
70
71 echo "Running HPU plugin v1 test"
72 docker run --rm --runtime=habana --name="${container_name}" --network=host \
73 -e HABANA_VISIBLE_DEVICES=all \
74 -e VLLM_SKIP_WARMUP=true \
75 -e PT_HPU_ENABLE_LAZY_COLLECTIVES=true \
76 -e PT_HPU_LAZY_MODE=1 \
77 "${image_name}" \
78 /bin/bash -c '
79 cd vllm; timeout 120s python -u examples/basic/offline_inference/generate.py --model facebook/opt-125m
80 '
81
82 EXITCODE=$?
83 if [ $EXITCODE -eq 0 ]; then
84 echo "Test with basic model passed"
85 else
86 echo "Test with basic model FAILED with exit code: $EXITCODE" >&2
87 fi
88
89 # The trap will handle the container removal and final exit.