Skip to content

Qwen2.5-14B-Instruct-AWQ 部署记录

日期: 2026-08-18 模型: Qwen/Qwen2.5-14B-Instruct-AWQ (4-bit AWQ 量化) GPU: AMD Radeon RX 7900 XTX 24GB (gfx1100) 节点: szb122009 (192.168.122.9) 框架: vLLM v0.6.6 + ROCm 6.3.2


一、部署成果

1.1 VRAM 分配详情

组件大小
总 GPU 内存23.98 GiB
可用内存 (90% util)21.59 GiB
模型权重 (AWQ 4-bit)9.38 GiB
非 PyTorch 开销0.27 GiB
PyTorch 激活峰值3.95 GiB
KV Cache7.99 GiB
GPU Blocks2726
CPU Blocks1365
最大 32K 并发1.33x

1.2 推理测试结果

  • ✅ 英文测试: "15 * 37 = 555" (数学正确)
  • ✅ 中文测试: 量子计算原理 (高质量回答, 202 tokens)
  • ✅ 启动耗时: ~110 秒 (含模型加载 + KV Cache 初始化)

1.3 vLLM 启动参数

bash
python3 -m vllm.entrypoints.openai.api_server \
  --model /models/huggingface/Qwen/Qwen2.5-14B-Instruct-AWQ \
  --served-model-name qwen2.5-14b \
  --host 0.0.0.0 --port 8000 \
  --quantization awq \
  --gpu-memory-utilization 0.90 \
  --max-model-len 32768 \
  --dtype float16 \
  --enforce-eager \
  --enable-auto-tool-choice \
  --tool-call-parser hermes \
  --disable-frontend-multiprocessing

二、模型下载与传输

2.1 下载策略

由于 GPU 节点 (192.168.122.9) 外网速度极慢 (<0.5 MB/s),采用 Master 下载 + kubectl cp 方案:

Master (192.168.122.37)                    GPU Node (szb122009)
  curl hf-mirror.com ──► /tmp/model-14b/     /opt/models/huggingface/
  ~10 MB/s                   │                      │
                             └─ kubectl cp ─────────┘
                              (K8s API, ~100 MB/s)

2.2 模型文件清单

文件大小
model-00001-of-00003.safetensors3.8 GB
model-00002-of-00003.safetensors3.7 GB
model-00003-of-00003.safetensors1.9 GB
config.json841 B
generation_config.json243 B
merges.txt1.6 MB
model.safetensors.index.json105 KB
tokenizer.json6.8 MB
tokenizer_config.json7.2 KB
vocab.json2.7 MB
LICENSE12 KB
总计~9.4 GB

2.3 传输 Pod 配置

yaml
apiVersion: v1
kind: Pod
metadata:
  name: transfer-qwen14b
spec:
  nodeName: szb122009
  containers:
  - name: transfer
    image: 192.168.122.156:30000/cnrancher/vllm-rocm:v0.6.6
    command: ["sleep", "infinity"]
    volumeMounts:
    - name: models
      mountPath: /models
  volumes:
  - name: models
    hostPath:
      path: /opt/models
      type: DirectoryOrCreate

传输命令:

bash
kubectl cp /tmp/model-14b/model-00001-of-00003.safetensors \
  default/transfer-qwen14b:/models/huggingface/Qwen/Qwen2.5-14B-Instruct-AWQ/model-00001-of-00003.safetensors

三、关键配置与环境变量

3.1 ROCm 适配

yaml
env:
- name: HSA_OVERRIDE_GFX_VERSION
  value: "11.0.0"          # RX 7900 XTX (gfx1100) 伪装为 gfx1100
- name: VLLM_TARGET_DEVICE
  value: rocm
- name: PYTORCH_ROCM_ARCH
  value: gfx1100
- name: VLLM_USE_TRITON_FLASH_ATTN
  value: "0"               # 使用 CK Flash Attention 替代 Triton

3.2 运行时补丁 (initContainer 内)

  1. tokenizer.py: 移除 all_special_tokens_extended 引用 (transformers 兼容)
  2. multiprocessing/client.py: 修复 property 对象不可调用错误
  3. init.py: 修复 torch._inductor.config.compile_threads 属性缺失

四、已知警告与限制

警告影响处理
AWQ + ROCm 未充分优化推理速度可能慢于非量化模型可接受, 功能正常
SWA 不支持 Triton Flash AttentionSliding Window Attention 不可用设置 VLLM_USE_TRITON_FLASH_ATTN=0 使用 CK 后端
enforce-eager + 无 CUDA Graphasync output 不可用已设置, 不影响功能
custom all-reduce 不支持 AMD单 GPU 无需 all-reduce自动禁用

五、deploy.sh 更新记录

  • 新增 qwen14b 选项到模型切换
  • 默认启动模型改为 qwen14b (qwen7b 缩容到 0)
  • Open WebUI 环境变量和 SQLite DB 更新指向 qwen14b
  • 修复 qwen7b switch case 中 URL 错误

六、操作命令速查

bash
# 启动 qwen14b
kubectl scale deployment vllm-qwen14b --replicas=1

# 停止 qwen14b (释放 GPU)
kubectl scale deployment vllm-qwen14b --replicas=0

# 切换模型
./deploy.sh switch qwen14b

# 查看日志
kubectl logs -f deployment/vllm-qwen14b

# 测试推理
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen2.5-14b","messages":[{"role":"user","content":"你好"}]}'