- sliding-window guard: add --disable-sliding-window only when the model really has sliding_window and the xformers backend lacks make_local_attention; cap --max-model-len to the window size; skip models whose rope_scaling is not supported by this vLLM (yarn, ...) - tokenizer fix: rewrite tokenizer_class / extra_special_tokens / from_slow, keep auto_map + copied repo code; every candidate is verified with AutoTokenizer.from_pretrained, all-fail falls back to starting vLLM unchanged - head_size patch + ixformer ops patch + weight-load progress log kept - selftests for tokenizer, sliding window and final argv
58 lines
2.2 KiB
Bash
Executable File
58 lines
2.2 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. 执行 patch_vllm_load_progress.py(给权重加载加进度日志);
|
||
# 4. 校验:vllm 可执行文件存在、两个构建期补丁确实生效了,否则直接让构建失败
|
||
# (避免产出「打了补丁其实没打上」的镜像)。
|
||
#
|
||
# 构建期补丁失败一律 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"
|
||
python3 "$SRC_DIR/patch_vllm_load_progress.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 ! grep -q "VLLM_LOAD_PROGRESS" "$CORE_PY/vllm/model_executor/model_loader/weight_utils.py"; then
|
||
echo "ERROR: vLLM load-progress 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))"
|