<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[在 Proxmox VE 虚拟机 上，用AMD 官方 MXFP4 版与社区实测 INT4（AutoRound）版，vLLM 部署 Qwen3.8-27B 量化模型的选择。]]></title><description><![CDATA[<h1>AMD R9700 单卡部署 vLLM + Qwen3.8-27B 教程（一）</h1>
<hr />
<blockquote>
<p dir="auto">场景：在 Proxmox VE 虚拟机 102（Ubuntu 24.04 + AMD Radeon AI PRO R9700 直通）上，用 vLLM 部署 Qwen3.8-27B 量化模型，提供 OpenAI 兼容的本地大模型 API 服务。</p>
</blockquote>
<hr />
<h2>1. 环境</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项目</th>
<th>值</th>
</tr>
</thead>
<tbody>
<tr>
<td>虚拟机</td>
<td>102（Ubuntu 24.04，kernel 7.0.0-31-generic）</td>
</tr>
<tr>
<td>GPU</td>
<td>AMD Radeon AI PRO R9700（gfx1201 / RDNA4，32GB）</td>
</tr>
<tr>
<td>ROCm</td>
<td>10.0（宿主机已装）</td>
</tr>
<tr>
<td>Docker</td>
<td>29.1.3</td>
</tr>
<tr>
<td>vLLM 镜像</td>
<td><code>stilldeadcode/vllm-radiance:0.9.3</code>（vLLM 0.27.1，ROCm 7.14）</td>
</tr>
<tr>
<td>模型</td>
<td><code>devan-carlin/Qwen3.8-27B-int4-AutoRound</code>（INT4 多模态）</td>
</tr>
<tr>
<td>最终显存占用</td>
<td>17.65 GiB</td>
</tr>
</tbody>
</table>
<hr />
<h2>2. 方案与选型</h2>
<hr />
<h3>2.1 AMD 官方方案</h3>
<ul>
<li>AMD 官方为 R9700 主推 <strong>OpenClaw</strong>（本地 AI 智能体平台），官方 ROCm 文档推 <strong>vLLM</strong> 做推理服务。</li>
<li>Qwen3.8-27B 是<strong>原生视觉语言模型</strong>（<code>image-text-to-text</code>，支持图片和视频理解），AMD 提供 Day-0 支持。</li>
</ul>
<h3>2.2 为什么不用 AMD 官方 MXFP4 版？</h3>
<p dir="auto">AMD 官方发布了 <code>amd/Qwen3.8-27B-Quark-AWQ-MXFP4</code> 量化版，但社区实测发现：</p>
<ol>
<li>其 <strong>MTP 头是 BF16 未量化</strong>，vLLM 加载时会报错（<code>asserts on a half-width parameter</code>），需要额外脚本预处理。</li>
<li>社区实测 <strong>INT4（AutoRound）版质量反而更好</strong>，且无需预处理。</li>
</ol>
<blockquote>
<p dir="auto">结论：单卡 32GB 场景，选用 <strong>INT4（AutoRound）</strong> 量化版更稳、质量更好。</p>
</blockquote>
<h3>2.3 显存计算（27B 参数 vs 32GB）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>格式</th>
<th>权重体积</th>
<th>32GB 单卡</th>
</tr>
</thead>
<tbody>
<tr>
<td>FP16/BF16</td>
<td>~54GB</td>
<td>装不下</td>
</tr>
<tr>
<td>FP8</td>
<td>~27GB+开销</td>
<td>极紧张</td>
</tr>
<tr>
<td><strong>INT4 / MXFP4</strong></td>
<td><strong>~14GB+开销≈17.7GB</strong></td>
<td>轻松</td>
</tr>
</tbody>
</table>
<hr />
<h2>3. 准备</h2>
<h3>3.1 扩容磁盘（模型 + 镜像约需 30GB+）</h3>
<pre><code class="language-bash">sudo lvextend -L +100G /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
df -h /    # 确认扩容
</code></pre>
<h3>3.2 安装 Docker</h3>
<pre><code class="language-bash">sudo apt-get install -y docker.io
docker --version
</code></pre>
<h3>3.3 安装 huggingface_hub（用于下载模型）</h3>
<pre><code class="language-bash">sudo apt-get install -y python3-pip
# 注意 --ignore-installed 解决 typing_extensions 冲突
sudo pip3 install --break-system-packages --ignore-installed typing_extensions huggingface_hub
hf --version   # 或 python3 -c "import huggingface_hub; print(huggingface_hub.__version__)"
</code></pre>
<hr />
<h2>4. 拉取 vLLM 镜像</h2>
<p dir="auto">先查最新标签：</p>
<pre><code class="language-bash">wget -qO- "https://hub.docker.com/v2/repositories/stilldeadcode/vllm-radiance/tags?page_size=10" \
  | python3 -c "import sys,json; [print(t['name']) for t in json.load(sys.stdin)['results']]"
</code></pre>
<p dir="auto">拉取（后台，约 13.7GB）：</p>
<pre><code class="language-bash">nohup bash -c 'echo "密码" | sudo -S -p "" docker pull stilldeadcode/vllm-radiance:0.9.3' \
  &gt; /tmp/docker-pull.log 2&gt;&amp;1 &amp;
</code></pre>
<blockquote>
<p dir="auto">说明：<code>stilldeadcode/vllm-radiance</code> 是社区维护、专为 R9700（gfx1201）打包的 vLLM 镜像，内置了 RDNA4 专属内核 + AITER + Triton。官方 <code>rocm/vllm</code> 对 Radeon gfx1201 支持不全。</p>
</blockquote>
<hr />
<h2>5. 下载模型</h2>
<pre><code class="language-bash">mkdir -p ~/models
# 国内可走 hf-mirror 加速
export HF_ENDPOINT=https://hf-mirror.com
nohup hf download devan-carlin/Qwen3.8-27B-int4-AutoRound \
  --local-dir ~/models/qwen3.8-27b-autoround &gt; /tmp/model-download.log 2&gt;&amp;1 &amp;
</code></pre>
<p dir="auto">下载完成后（约 18GB，8 个 safetensors 分片）：</p>
<pre><code class="language-bash">ls ~/models/qwen3.8-27b-autoround/*.safetensors | wc -l   # 应为 8
du -sh ~/models/qwen3.8-27b-autoround                      # 约 18G
</code></pre>
<hr />
<h2>6. 模型 config.json 补丁（注意）</h2>
<blockquote>
<p dir="auto"><strong>不补丁会静默出错</strong>：原 checkpoint 的 <code>quantization_config.quant_method</code> 是 <code>auto-round</code>，vLLM 会<strong>忽略量化、以未量化方式加载</strong>（54GB → 32GB 卡直接 OOM），且<strong>不报错</strong>。</p>
</blockquote>
<pre><code class="language-bash">cd ~/models/qwen3.8-27b-autoround
cp -n config.json config.json.autoround-orig   # 备份原文件

python3 -c "
import json
p = 'config.json'
c = json.load(open(p))
q = c['quantization_config']
q['quant_method'] = 'auto_gptq'
q.setdefault('desc_act', False)
q.setdefault('lm_head', False)
q.setdefault('modules_in_block_to_quantize', [
    'self_attn.q_proj', 'self_attn.k_proj', 'self_attn.v_proj', 'self_attn.o_proj',
    'mlp.gate_proj', 'mlp.up_proj', 'mlp.down_proj',
    'linear_attn.in_proj_qkv', 'linear_attn.in_proj_z', 'linear_attn.out_proj',
])
json.dump(c, open(p, 'w'), indent=2)
print('补丁已应用')
"
</code></pre>
<p dir="auto">验证：</p>
<pre><code class="language-bash">python3 -c "import json; q=json.load(open('config.json'))['quantization_config']; print(q['quant_method'], len(q.get('modules_in_block_to_quantize',[])))"
# 输出: auto_gptq 10
</code></pre>
<hr />
<h2>7. 内核补丁准备</h2>
<blockquote>
<p dir="auto"><strong>必须挂载内核补丁</strong>：GPTQ 格式的 AutoRound checkpoint 有「对称零点」问题，官方内核会崩溃（<code>assert zp.shape == ...</code>）。</p>
</blockquote>
<p dir="auto">克隆 launcher 仓库获取内核补丁文件：</p>
<pre><code class="language-bash">cd /tmp
git clone --depth 1 https://github.com/zzpanic/qwen3.6-vllm-gfx1201-launchers.git launchers
ls launchers/patches/rdna_hybrid_w4a16.py   # 确认文件存在
</code></pre>
<hr />
<h2>8. 启动 vLLM 服务</h2>
<h3>8.1 准备缓存目录</h3>
<pre><code class="language-bash">mkdir -p ~/.cache/vllm
</code></pre>
<h3>8.2 完整启动命令（本机为例）</h3>
<pre><code class="language-bash">cat &gt; /tmp/run-vllm.sh &lt;&lt; 'EOF'
#!/bin/bash
sudo docker run --rm --name vllm102 \
  --device /dev/kfd --device /dev/dri \
  --group-add 44 --group-add 992 \
  --shm-size 4g --cap-add SYS_PTRACE --security-opt seccomp=unconfined \
  -v /home/Magic629/models/qwen3.8-27b-autoround:/model:ro \
  -v /tmp/launchers/patches/rdna_hybrid_w4a16.py:/opt/vllm/lib/python3.12/site-packages/vllm/model_executor/kernels/linear/mixed_precision/rdna_hybrid_w4a16.py:ro \
  -v /home/Magic629/.cache/vllm:/cache \
  -p 8000:8000 \
  -e HIP_VISIBLE_DEVICES=0 \
  -e VLLM_ROCM_USE_AITER=1 -e VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION=1 \
  -e VLLM_ROCM_USE_AITER_MHA=0 -e VLLM_ROCM_USE_AITER_MLA=0 -e VLLM_ROCM_USE_AITER_MOE=0 \
  -e VLLM_ROCM_USE_AITER_LINEAR=0 -e VLLM_ROCM_USE_AITER_FP8BMM=0 -e VLLM_ROCM_USE_AITER_FP4BMM=0 -e VLLM_ROCM_USE_AITER_RMSNORM=0 \
  -e RADIANCE_PRESHUFFLE=1 -e RADIANCE_ATTN_TUNE=1 -e RADIANCE_GDN_WMMA=1 \
  -e RADIANCE_VIT_FLASH=1 -e RADIANCE_FUSE_RMS_QUANT=1 -e RADIANCE_DYNAMIC_DRAFT=1 \
  -e RADIANCE_SKINNY_GEMM=all \
  -e VLLM_CACHE_ROOT=/cache/vllm -e TORCHINDUCTOR_CACHE_DIR=/cache/inductor \
  -e TRITON_CACHE_DIR=/cache/triton -e AITER_ROOT_DIR=/cache/aiter \
  -e TRITON_CACHE_AUTOTUNING=1 \
  stilldeadcode/vllm-radiance:0.9.3 \
  /model \
  --served-model-name qwen3.8-27b-int4 \
  --quantization auto_gptq \
  --kv-cache-dtype fp8 \
  --tensor-parallel-size 1 \
  --gpu-memory-utilization 0.97 \
  --max-model-len 204800 \
  --max-num-seqs 2 \
  --max-num-batched-tokens 4854 \
  --attention-backend R4D \
  --enable-prefix-caching --mamba-cache-mode align \
  --reasoning-parser qwen3 \
  --tool-call-parser qwen3_xml --enable-auto-tool-choice \
  --trust-remote-code \
  --host 0.0.0.0 --port 8000
EOF
chmod +x /tmp/run-vllm.sh
</code></pre>
<h3>8.3 后台启动</h3>
<pre><code class="language-bash">nohup bash -c 'echo "密码" | sudo -S -p "" bash /tmp/run-vllm.sh' &gt; /tmp/vllm-run.log 2&gt;&amp;1 &amp;
</code></pre>
<h3>8.4 关键参数说明</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>参数</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>--group-add 44 992</code></td>
<td>44=video 组、992=render 组（数字 GID，避免名称解析失败）</td>
</tr>
<tr>
<td><code>--device /dev/kfd /dev/dri</code></td>
<td>显卡计算接口 + 渲染节点</td>
</tr>
<tr>
<td><code>--quantization auto_gptq</code></td>
<td>必须与 config.json 补丁后一致</td>
</tr>
<tr>
<td><code>--tensor-parallel-size 1</code></td>
<td>单卡</td>
</tr>
<tr>
<td><code>--kv-cache-dtype fp8</code></td>
<td>KV 缓存用 FP8</td>
</tr>
<tr>
<td><code>--max-model-len 204800</code></td>
<td>上下文长度 200K</td>
</tr>
<tr>
<td><code>--attention-backend R4D</code></td>
<td>RDNA4 专用注意力内核</td>
</tr>
</tbody>
</table>
<hr />
<h2>9. 验证推理</h2>
<h3>9.1 确认启动成功（日志）</h3>
<pre><code class="language-bash">tail -20 /tmp/vllm-run.log
# 关键日志：
#   "Model loading took 17.65 GiB memory"        ← INT4 正确加载
#   "Application startup complete."              ← 服务就绪
</code></pre>
<h3>9.2 发送测试请求</h3>
<pre><code class="language-bash">python3 - &lt;&lt; 'PYEOF'
import urllib.request, json, time
data = {
    "model": "qwen3.8-27b-int4",
    "messages": [{"role": "user", "content": "用一句话介绍你自己"}],
    "max_tokens": 200,
    "temperature": 0.6
}
req = urllib.request.Request("http://127.0.0.1:8000/v1/chat/completions",
    data=json.dumps(data).encode(), headers={"Content-Type": "application/json"})
t0 = time.time()
r = json.loads(urllib.request.urlopen(req, timeout=180).read().decode())
print(r["choices"][0]["message"]["content"])
print("速度 %.1f tok/s" % (r["usage"]["completion_tokens"] / (time.time()-t0)))
PYEOF
</code></pre>
<h3>9.3 实测结果</h3>
<ul>
<li>显存占用：<strong>17.65 GiB</strong></li>
<li>推理速度：<strong>26.3 tok/s</strong>（基线，未开投机解码）</li>
<li>API：<code>http://192.168.67.202:8000/v1</code>（Ubuntu24.04推理机IP）</li>
</ul>
<hr />
<h2>10. 常见问题</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>坑</th>
<th>现象</th>
<th>解决</th>
</tr>
</thead>
<tbody>
<tr>
<td>config.json 未补丁</td>
<td>静默以未量化加载 → OOM</td>
<td>改 <code>quant_method=auto_gptq</code> + 量化模块列表</td>
</tr>
<tr>
<td>内核补丁未挂载</td>
<td>GPTQ 对称零点 <code>assert</code> 崩溃</td>
<td>挂载 <code>rdna_hybrid_w4a16.py</code></td>
</tr>
<tr>
<td><code>--group-add render</code> 报错</td>
<td>"Unable to find group render"</td>
<td>用数字 GID：<code>--group-add 44 --group-add 992</code></td>
</tr>
<tr>
<td>huggingface_hub 装不上</td>
<td>typing_extensions RECORD 错误</td>
<td><code>pip install --ignore-installed</code></td>
</tr>
<tr>
<td>首次启动 OOM</td>
<td>torch.compile 冷启动 +2.28GiB</td>
<td>重跑一次即可（缓存已生成）</td>
</tr>
<tr>
<td><a href="http://huggingface.co" rel="nofollow ugc">huggingface.co</a> 不通</td>
<td>国内网络</td>
<td>加 <code>HF_ENDPOINT=https://hf-mirror.com</code></td>
</tr>
</tbody>
</table>
<pre><code>
**后续可选优化**：
1. 开启投机解码（DFlash2 草稿模型），速度可再提升 1.5~2 倍
2. 测试多模态（图片输入）
3. 接入 OpenClaw / Ollama 作为后端</code></pre>
]]></description><link>https://lcz.me/topic/1753</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 19:58:49 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1753.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Sep 2026 11:50:57 GMT</pubDate><ttl>60</ttl></channel></rss>