The patch only added timing/log lines around weight loading; it did not change any behaviour. Remove it so the image carries fewer build-time code edits, and keep the ixformer ops patch (still verified at build).
52 lines
1.9 KiB
Bash
Executable File
52 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
||
# 构建期脚本:把运行期文件装到 /opt,并做完「只能做一次」的补丁。
|
||
#
|
||
# 用法(Dockerfile):bash install_patch.sh /tmp
|
||
#
|
||
# 做三件事:
|
||
# 1. 安装运行期脚本到 /opt(entrypoint / launcher / 两个修复脚本 / head_size 检测);
|
||
# 2. 把 patched_ops 装到 /opt/patched_ops,再执行 patch_ops.py(给 ixformer 补 ops);
|
||
# 3. 校验:vllm 可执行文件存在、ops 补丁确实生效了,否则直接让构建失败
|
||
# (避免产出「打了补丁其实没打上」的镜像)。
|
||
#
|
||
# 构建期补丁失败一律 exit 1;这是故意的 —— 镜像要么是修好的,要么就不发。
|
||
|
||
set -euo pipefail
|
||
|
||
SRC_DIR="${1:-/tmp}"
|
||
CORE_PY=/usr/local/corex/lib64/python3/dist-packages
|
||
|
||
echo "[install_patch] installing runtime files to /opt"
|
||
install -m 0644 "$SRC_DIR/fix_tokenizer.py" /opt/fix_tokenizer.py
|
||
install -m 0644 "$SRC_DIR/swa_guard.py" /opt/swa_guard.py
|
||
install -m 0644 "$SRC_DIR/vllm_launch.py" /opt/vllm_launch.py
|
||
install -m 0644 "$SRC_DIR/detect_head_size.py" /opt/detect_head_size.py
|
||
install -m 0755 "$SRC_DIR/entrypoint.sh" /opt/entrypoint.sh
|
||
|
||
rm -rf /opt/patched_ops
|
||
mkdir -p /opt/patched_ops
|
||
cp -a "$SRC_DIR/patched_ops/." /opt/patched_ops/
|
||
|
||
echo "[install_patch] applying build-time patches"
|
||
python3 "$SRC_DIR/patch_ops.py"
|
||
|
||
echo "[install_patch] verifying"
|
||
if ! grep -rq "gelu_tanh_and_mul" "$CORE_PY/ixformer/functions/__init__.py"; then
|
||
echo "ERROR: ixformer ops patch did not take effect" >&2
|
||
exit 1
|
||
fi
|
||
if ! command -v vllm >/dev/null 2>&1; then
|
||
echo "ERROR: vllm executable not found on PATH" >&2
|
||
exit 1
|
||
fi
|
||
|
||
python3 -m py_compile \
|
||
/opt/fix_tokenizer.py \
|
||
/opt/swa_guard.py \
|
||
/opt/vllm_launch.py \
|
||
/opt/detect_head_size.py
|
||
|
||
rm -rf /opt/patched_ops/__pycache__ /opt/__pycache__
|
||
|
||
echo "[install_patch] done (vllm: $(command -v vllm))"
|