main
sh 54 lines 2.2 KB
Raw
1 #!/bin/bash
2
3 # This script build the CPU docker image and run the offline inference inside the container.
4 # It serves a sanity check for compilation and basic model usage.
5 set -ex
6
7 # Setup cleanup
8 remove_docker_container() {
9 if [[ -n "$container_id" ]]; then
10 podman stop --all -t0
11 podman rm -f "$container_id" || true
12 fi
13 podman system prune -f
14 }
15 trap remove_docker_container EXIT
16 remove_docker_container
17
18 # Try building the docker image
19 podman build -t cpu-test-ubi9-ppc -f docker/Dockerfile.ppc64le .
20
21 # Run the image
22 container_id=$(podman run -itd --entrypoint /bin/bash -v /tmp/:/root/.cache/huggingface --privileged=true --network host -e HF_TOKEN cpu-test-ubi9-ppc)
23
24 function cpu_tests() {
25
26 # offline inference
27 podman exec -it "$container_id" bash -c "
28 export TORCH_COMPILE_DISABLE=1
29 set -xve
30 python3 examples/basic/offline_inference/generate.py --model facebook/opt-125m" >> "$HOME"/test_basic.log
31
32 # Run basic model test
33 podman exec -it "$container_id" bash -c "
34 export TORCH_COMPILE_DISABLE=1
35 set -evx
36 pip install pytest pytest-asyncio einops peft Pillow soundfile transformers_stream_generator matplotlib
37 pip install sentence-transformers datamodel_code_generator tblib
38
39 # Note: disable Bart until supports V1
40 # pytest -v -s tests/models/language/generation/test_bart.py -m cpu_model
41 pytest -v -s tests/models/language/generation/test_common.py::test_models[False-False-5-32-openai-community/gpt2]
42 pytest -v -s tests/models/language/generation/test_common.py::test_models[False-False-5-32-facebook/opt-125m]
43 pytest -v -s tests/models/language/generation/test_common.py::test_models[False-False-5-32-google/gemma-1.1-2b-it]
44 pytest -v -s tests/models/language/pooling/test_classification.py::test_models[float-jason9693/Qwen2.5-1.5B-apeach]
45 # TODO: Below test case tests/models/language/pooling/test_embedding.py::test_models[True-ssmits/Qwen2-7B-Instruct-embed-base] fails on ppc64le. Disabling it for time being.
46 # pytest -v -s tests/models/language/pooling/test_embedding.py -m cpu_model" >> "$HOME"/test_rest.log
47 }
48
49 # All of CPU tests are expected to be finished less than 40 mins.
50
51 export container_id
52 export -f cpu_tests
53 timeout 120m bash -c cpu_tests
54