Files
vLLM-Kunlunxin_p-800-tokeni…/README.md
2026-06-30 13:57:38 +08:00

59 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# xc-llm-kunlun-fix-tokenizer
基于 `harbor-contest.4pd.io/sunjichen/xc-llm-kunlun:latest` 的 tokenizer 自动修复镜像。
## 问题背景
部分模型的 `tokenizer_config.json` 存在以下问题,导致 vLLM 服务启动失败:
| 错误 | 原因 |
|---|---|
| `ValueError: Tokenizer class TokenizersBackend does not exist` | `tokenizer_class` 不是 transformers 合法类名 |
| `AttributeError: 'list' object has no attribute 'keys'` | `extra_special_tokens` 为 list 格式transformers 要求 dict |
## 修复方式
构建时将镜像内的 `vllm` 二进制替换为同名 wrapper 脚本,原二进制重命名为 `vllm_real`
容器启动时 wrapper 自动检测 `tokenizer_config.json`
- 存在问题 → 将 tokenizer 文件复制到 `/tmp/fixed_tokenizer/` 并修复,追加 `--tokenizer /tmp/fixed_tokenizer` 参数后调用 `vllm_real`
- 无问题 → 直接调用 `vllm_real`,行为与原镜像完全一致
原始模型目录不做任何修改。
## 使用方式
**原始 docker run 命令只需替换镜像名,其他参数不变:**
```bash
# 原镜像
harbor-contest.4pd.io/sunjichen/xc-llm-kunlun:latest
# 替换为
<this-image>
```
示例:
```bash
docker run -dit --name <container_name> \
-p 44825:8000 \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--tmpfs /dev/shm:rw,nosuid,nodev,exec,size=64g \
--ulimit memlock=-1 \
--device=/dev/xpu0:/dev/xpu0 \
--device=/dev/xpuctrl:/dev/xpuctrl \
-v /path/to/model:/model \
--entrypoint vllm <this-image> \
serve /model --port 8000 --served-model-name llm \
--max-model-len 2048 --gpu-memory-utilization 0.9 \
--enforce-eager --trust-remote-code -tp 1
```
## 构建
```bash
docker build -t xc-llm-kunlun-fix-tokenizer:latest .
```
CI 通过推送 `v*` tag 自动触发构建并推送镜像。