Files
vLLM-Biren_166m-opt/README.md
4paradigm d03f1d2ccb
All checks were successful
Docker Build and Push / docker (push) Successful in 1m3s
fix tokenizer
2026-07-20 10:47:42 +08:00

60 lines
1.9 KiB
Markdown
Raw Permalink 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.

# vllm-biren-fix-tokenizer
基于 `harbor.4pd.io/modelhubxc/enginex/xc-llm-biren166m:26.01` 的 tokenizer 自动修复镜像,面向 Biren 166M GPU。
## 问题背景
部分模型的 `tokenizer_config.json` 存在以下问题,导致 vLLM 0.11.0 服务启动失败:
| 错误 | 原因 |
|---|---|
| `ValueError: Tokenizer class TokenizersBackend does not exist` | `tokenizer_class` 不是 transformers 合法类名,环境中缺少 `tokenizers` 包 |
| `AttributeError: 'list' object has no attribute 'keys'` | `extra_special_tokens` 为 list 格式transformers 要求 dict |
## 修复方式
构建时将镜像内的 `vllm` 二进制(`/usr/local/bin/vllm`)替换为同名 wrapper 脚本,原二进制重命名为 `vllm_real`
容器启动时 wrapper 自动检测 `tokenizer_config.json`
- 存在问题 → 将 tokenizer 文件复制到 `/tmp/fixed_tokenizer/` 并修复,追加 `--tokenizer /tmp/fixed_tokenizer` 参数后调用 `vllm_real`
- 无问题 → 直接调用 `vllm_real`,行为与原镜像完全一致
原始模型目录不做任何修改。
## 使用方式
**原始 docker run 命令只需替换镜像名,其他参数不变:**
```bash
# 原镜像
harbor.4pd.io/modelhubxc/enginex/xc-llm-biren166m:26.01
# 替换为
<this-image>
```
示例:
```bash
docker run -dit --name biren_sut_submit_task_<task_id> \
--ipc=host \
-v /dev:/dev \
-v /lib/modules:/lib/modules \
--privileged \
--pid=host \
-v /path/to/model:/model \
-p 35055:8000 \
-e MAX_MODEL_LEN=2048 \
-e SUPA_VISIBLE_DEVICES=2 \
--entrypoint /bin/bash \
<this-image> \
-ic 'vllm serve /model --port 8000 --served-model-name llm --max-model-len 2048 --gpu-memory-utilization 0.9 --enforce-eager --trust-remote-code -tp 1 --host 0.0.0.0'
```
## 构建
```bash
docker build -t vllm-biren-fix-tokenizer:latest .
```
CI 通过推送 `v*` tag 自动触发构建并推送镜像。