<?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[7900XTX双卡跑VLLM跑 Qwen3.8 27b实录]]></title><description><![CDATA[<h1>双 RX 7900 XTX（RDNA3）跑 vLLM + Qwen3.8-27B 实录</h1>
<h2>动机（为什么折腾这个）</h2>
<p dir="auto">今年四月左右看了lcz版主的视频，在家弄了双卡 vLLM 这套主机有一阵了。今天看到lcz视频里提到a卡双卡支持很差，有点小不服，所以贴一下这几天捣鼓的经验。首先说，能跑肯定是能跑，但是短上下文体验远远不如LLaMA.cpp （尤其是mtp聊胜于无），但是如果有agent多并发需求还是可以尝试一下。</p>
<p dir="auto">起因是之前主力用 llama.cpp：<br />
启动快、跑得稳，但<strong>多路并发的缓存重用很差</strong>——几个 agent / harness 同时<br />
跑的时候，各自的上下文来回反复预填充，很容易陷入"refill 怪圈"：看起来在<br />
干活，实际大量时间耗在重复 prefill 上，实际体验一般。所以想试试 vLLM 的<br />
前缀缓存（prefix caching）能不能把这摊事理顺。折腾下来发现 vLLM 在 RDNA3<br />
上能跑，但坑是真不少，整理成这篇实录。</p>
<p dir="auto">先感谢 vLLM 社区这几个让 Qwen 系模型在 RDNA3 上真正能跑的 PR，没有它们<br />
这个帖子不存在：</p>
<ul>
<li><strong><a href="https://github.com/vllm-project/vllm/pull/41394" rel="nofollow ugc">vllm-project/vllm#41394</a> — RDNA3 W4A16 原生 HIP 线性内核</strong>（<code>RDNA3W4A16LinearKernel</code>）。<br />
W4A16 GPTQ 模型在 gfx1100 上流畅推理的基石。没有它只能走 Triton JIT 回退，<br />
冷启动编译一次能等到怀疑人生。</li>
<li><strong><a href="https://github.com/vllm-project/vllm/pull/48816" rel="nofollow ugc">vllm-project/vllm#48816</a> / <a href="https://github.com/vllm-project/vllm/pull/47828" rel="nofollow ugc">#47828</a> — Qwen3.5 MTP drafter BF16 权重加载修复</strong>。<br />
官方 AutoRound GPTQ 仓库把 MTP 张量存成纯 BF16，量化配置却声明 4-bit，<br />
加载器直接报错。这两个 PR（配合本地把规则改成 <code>-:.*mtp.*</code> 排除）让 MTP<br />
能正常加载运行。</li>
</ul>
<p dir="auto">顺便提了一下，有些大神已经开始搞sglang的7900xtx的支持了，过几天我也试一下：<a href="https://github.com/sgl-project/sglang/issues/30599" rel="nofollow ugc">https://github.com/sgl-project/sglang/issues/30599</a></p>
<p dir="auto">下面是完整实录。</p>
<hr />
<h2>硬件</h2>
<p dir="auto">应版主要求，先上图：<img src="https://img.cdn1.vip/i/6a885ae768c7e_1787321063.webp" alt="替代文字" class=" img-fluid img-markdown" /></p>
<ul>
<li>主板：ASRock X670E Taichi Carrara（AM5；双卡时 CPU 的 PCIe 4.0 x16 拆成<br />
两个 PCIe 4.0 x8，每卡约 16 GB/s，对推理完全够用）</li>
<li>CPU：Ryzen 5 9600X（6C12T）</li>
<li>内存：32 GB DDR5</li>
<li>GPU：2× RX 7900 XTX（gfx1100，24 GB 单卡）</li>
<li>ROCm 7.14（HIP 7.14.60850）</li>
</ul>
<h2>安装</h2>
<pre><code class="language-bash">uv venv --python 3.12 --seed --managed-python
uv pip install vllm --extra-index-url https://wheels.vllm.ai/rocm/ --upgrade
</code></pre>
<p dir="auto">装出来：<strong>vllm 0.27.1+rocm723</strong>、torch 2.11.0+rocm、triton 3.6.0、<br />
transformers 5.15.1、Python 3.12.13。</p>
<h2>最大的坑：amdsmi 引导（不解决这个根本起不来）</h2>
<p dir="auto">ROCm 上如果 torch 是第一个 import amdsmi 的库，torch 的 <code>_amdsmi_cdll_hook</code><br />
会加载一份冲突的 <code>libamd_smi.so</code>，结果 <code>torch.cuda.device_count()</code> 返回 0<br />
（HIP 明明能看到两张卡），vLLM 直接报 <code>Failed to infer device type</code>。</p>
<p dir="auto">解法：<strong>在 import torch 之前先 import amdsmi</strong>。我们写了 <code>serve-bootstrap.py</code><br />
做这件事，每次都通过它启动 vLLM，原样贴出来：</p>
<pre><code class="language-python">#!/usr/bin/env python
"""Bootstrap for native vLLM serve on ROCm.

Pre-imports `amdsmi` BEFORE torch so that torch's `_amdsmi_cdll_hook`
(torch/cuda/__init__.py) reuses this already-loaded module instead of loading
a second, conflicting copy of libamd_smi.so. Without the pre-import, amdsmi
reports 0 GPUs after torch loads (ODR violation), torch.cuda.device_count()
returns 0, and vLLM fails platform detection with
"Failed to infer device type".

Usage: serve-bootstrap.py &lt;vllm-subcommand&gt; [args...]
   e.g. serve-bootstrap.py serve --model ... --port 8080
"""
import sys

import amdsmi  # noqa: F401  -- must be imported before torch

from vllm.entrypoints.cli.main import main

if __name__ == "__main__":
    sys.exit(main())
</code></pre>
<p dir="auto">用法：</p>
<pre><code class="language-bash">python serve-bootstrap.py serve --model &lt;model_dir&gt; --port 8080 ...其它参数
</code></pre>
<h2>启动（当前生产：非 MTP，fp8 KV，TP2）</h2>
<pre><code class="language-bash">export HSA_OVERRIDE_GFX_VERSION=11.0.0
export HSA_ENABLE_IPC_MODE_LEGACY=0
export FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE
export VLLM_ROCM_USE_AITER=1
export HSA_FORCE_FINE_GRAIN_AMDGPU=1
export VLLM_ENGINE_READY_TIMEOUT_S=1800
export VLLM_ENGINE_ITERATION_TIMEOUT_S=1800
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=1800

python serve-bootstrap.py serve \
  --model ~/Documents/vllm-serving/qwen3.8-27b-mtp-fixed \
  --tensor-parallel-size 2 \
  --host 0.0.0.0 --port 8080 \
  --kv-cache-dtype fp8 \
  --max-model-len 262144 \
  --max-num-seqs 8 \
  --max-num-batched-tokens 2048 \
  --attention-backend TRITON_ATTN \
  --enable-prefix-caching --enable-chunked-prefill \
  --performance-mode interactivity
</code></pre>
<p dir="auto">几个为什么：</p>
<ul>
<li><strong><code>--kv-cache-dtype fp8</code>：跑 MTP 时是必须的</strong>（模型 FP16，drafter 的<br />
<code>context_attention_fwd</code> 在 bf16 KV 下会报 <code>fp16 × bf16</code> dot 断言）。但<strong>非<br />
MTP + TRITON_ATTN 下 bf16 KV 实测完全可用</strong>（0/16k 上下文 64.7/50.8 tok/s，<br />
与 fp8 相当甚至略好）。用 fp8 的实际理由是 KV 内存减半——<code>--max-model-len 262144</code> 下 bf16 KV 会很吃显存。</li>
<li>**<code>--max-num-seqs 8</code> 单人使用 大部分harness都够了</li>
<li><strong>超时别设超过 1800</strong>：设成 3600000 会撑爆 zmq int32，vLLM 陷入重启死循环。</li>
<li><strong>启动后先 warmup</strong>：第一批请求会吃 Triton JIT 编译的卡顿，脚本里发个<br />
"hi" 请求把 JIT 吃掉。</li>
</ul>
<h3>想开 MTP？怎么改、以及为什么我们没开</h3>
<p dir="auto">MTP（多 token 预测投机解码）在短上下文确实能白嫖提速（pp=32 时 +32%）。<br />
想开的话，在<strong>上面那个命令基础上改三处</strong>：</p>
<pre><code class="language-bash"># 1) 加投机解码配置（spec=3 实测最优，1/2 不够摊成本，4 过犹不及）
  --speculative-config '{"method":"mtp","num_speculative_tokens":3}' \
# 2) performance-mode 必须换成 throughput（interactivity 会触发
#    MTP drafter 的 inductor 编译 bug）
  --performance-mode throughput \
# 3) KV 缓存保持 fp8（MTP 下 bf16 KV 必崩：drafter 的 context_attention_fwd
#    会报 fp16 x bf16 dot 断言）
  --kv-cache-dtype fp8 \
</code></pre>
<p dir="auto">前提是模型检查点已经打过 MTP 量化规则补丁（见"踩坑速览"第 1 条）。</p>
<p dir="auto"><strong>但我们最终默认没开 MTP，原因就一句话：长上下文惨不忍睹。</strong></p>
<ul>
<li>MTP 的 drafter 每步都要把<strong>整个 KV 缓存</strong>重新 attention 一遍，上下文越<br />
长越慢：pp=2048 时已经变成负收益（46.2 vs 51.2 tok/s）；到 16k 深度直接<br />
崩到 <strong>13.8 tok/s</strong>，同期非 MTP 还有 45.7。</li>
<li>我们的主要场景是跑 agent / harness，上下文只会越滚越长，MTP 属于开局<br />
猛、后面拖后腿，所以干脆默认关掉。短对话 / 数学 / 代码类任务想开就开，<br />
收益 +32% ~ +13%。</li>
</ul>
<p dir="auto">所以当前生产是<strong>非 MTP + fp8 KV</strong>，深度表现反而更稳。</p>
<h2>性能速览</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>场景</th>
<th>数字</th>
</tr>
</thead>
<tbody>
<tr>
<td>非 MTP 并发 8</td>
<td>272 tok/s（ns=8）</td>
</tr>
<tr>
<td>非 MTP 单流短上下文</td>
<td>52–64 tok/s</td>
</tr>
<tr>
<td>16k 深度解码（非 MTP）</td>
<td>~48 tok/s</td>
</tr>
<tr>
<td>32k 深度解码（非 MTP）</td>
<td>~42 tok/s</td>
</tr>
<tr>
<td>冷 prefill 1k / 16k / 32k</td>
<td>1757 / 955 / 623 tok/s</td>
</tr>
<tr>
<td>MTP 短上下文（pp=32）</td>
<td>+32%（70.2 vs 53.2）</td>
</tr>
<tr>
<td>MTP 16k 深度</td>
<td>13.8 tok/s（崩了，别用）</td>
</tr>
</tbody>
</table>
<h2>踩坑速览（详情都在这篇里的链接和注释里）</h2>
<ol>
<li>
<p dir="auto"><strong>本地 model config 改动：MTP 的量化规则从 <code>+:</code> 改成 <code>-:</code></strong>（可复现）。<br />
HF 官方 <code>Vishva007/Qwen3.8-27B-W4A16-AutoRound-GPTQ</code> 的 <code>config.json</code> /<br />
<code>quantization_config.json</code> 里 <code>dynamic</code> 有 98 条规则，其中 MTP 是两条<br />
<strong>正向包含</strong>：<code>+:.*mtp.*</code> 和 <code>+:.*mtp\.fc.*</code>（按 4-bit 处理 MTP）。<br />
我们本地（<code>qwen3.8-27b-mtp-fixed/</code>，连同 HF cache 快照里的 config）把它<br />
改成 97 条：删掉两条 <code>+:</code>，加一条 <strong><code>-:.*mtp.*</code></strong> 排除。其余 96 条<br />
linear_attn 规则及所有字段零差异。</p>
<p dir="auto">为什么这么改：<code>model_extra_tensors.safetensors</code> 里 15 个 MTP 张量其实是<br />
<strong>纯 BF16</strong>（实测 dtype 全为 bfloat16），不是 4-bit。<code>+:</code> 规则会让 GPTQ<br />
加载器要求 MTP 提供 <code>qweight</code>，直接报<br />
<code>ValueError: no module or parameter named 'layers.0.mlp.down_proj.weight'</code>；<br />
改成 <code>-:</code> 排除后，vLLM 的 <code>qwen3_5_mtp.py</code> 检测到排除规则自动让 MTP 走<br />
非量化（BF16）加载（对应<br />
<a href="https://github.com/vllm-project/vllm/pull/48816" rel="nofollow ugc">#48816</a> /<br />
<a href="https://github.com/vllm-project/vllm/pull/47828" rel="nofollow ugc">#47828</a> 的修复路径）。<br />
注意 <code>mtp-fixed</code> 目录里 config 两件是实体文件，权重文件是软链指向<br />
HF 缓存。</p>
</li>
<li>
<p dir="auto"><strong>MTP 只适合短上下文</strong>：dense drafter 每步要整上下文 attention，深度一<br />
上去直接崩。数学/代码类 +32%~+13%，创意写作是负收益。深度任务用非 MTP。</p>
</li>
<li>
<p dir="auto"><strong>AITER attention 别选</strong>：<code>--attention-backend ROCM_AITER_UNIFIED_ATTN</code><br />
在这套环境上（amd_aiter 0.1.19 + gfx1100）会无声卡死，<code>import aiter</code><br />
直接死锁，严重时把 amdgpu 驱动搞挂，只能重启机器。</p>
</li>
<li>
<p dir="auto"><strong>为什么 llama.cpp MTP 深度给力而 vLLM 不行</strong>：内核效率问题。vLLM 的<br />
Triton attention 在 16k 上下文每行 query 要 24–27 ms，llama.cpp 的 ggml<br />
FA 只要 4–5 ms。MTP 就是把这整上下文的行数乘了倍，vLLM 自然崩。</p>
</li>
<li>
<p dir="auto"><strong>#45916 的 split-KV 我们试过</strong>：它改的 <code>kernel_paged_attention_2d</code> 在这<br />
套栈上根本不会执行（dense 解码走 GDN 融合的 <code>kernel_unified_attention</code>），<br />
属于改了用不上，已回滚。</p>
</li>
<li>
<p dir="auto"><strong>改过 wheel 后务必清编译缓存</strong>：<code>rm -rf ~/.cache/vllm/torch_compile_cache</code>，<br />
否则各种灵异现象（性能骤降、MTP inductor 报错）。</p>
</li>
</ol>
<h2>结语</h2>
<p dir="auto">双 7900 XTX 跑 vLLM 是完全可行的，当前非 MTP 配置在短上下文有 52–64 tok/s<br />
单流、并发可到 270+ tok/s，深度解码也稳。MTP 想深度用就得上 llama.cpp。<br />
有同样硬件配置的朋友欢迎交流。</p>
]]></description><link>https://lcz.me/topic/1252/7900xtx双卡跑vllm跑-qwen3.8-27b实录</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 23:02:15 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1252.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 21 Aug 2026 14:07:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 7900XTX双卡跑VLLM跑 Qwen3.8 27b实录 on Fri, 21 Aug 2026 14:30:33 GMT]]></title><description><![CDATA[<p dir="auto">你的经验我也有过，rdna只能用W4A16量化的模型，其他模型均无pre compiled kernel 奇慢无比。你可以和试试我这个量化模型</p>
]]></description><link>https://lcz.me/post/13343</link><guid isPermaLink="true">https://lcz.me/post/13343</guid><dc:creator><![CDATA[flyer666]]></dc:creator><pubDate>Fri, 21 Aug 2026 14:30:33 GMT</pubDate></item><item><title><![CDATA[Reply to 7900XTX双卡跑VLLM跑 Qwen3.8 27b实录 on Fri, 21 Aug 2026 14:13:42 GMT]]></title><description><![CDATA[<p dir="auto">勇气可嘉！我在R9700上面折腾过，体验不太好，太慢了，可能vLLM对7900XTX的支持更好些吧。我当时折腾下来是PP速度大概是llamacpp的一半，TP直接个位数，几乎没法用<img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f613.png?v=60716d54ab2" class="not-responsive emoji emoji-android emoji--sweat" style="height:23px;width:auto;vertical-align:middle" title="😓" alt="😓" /></p>
]]></description><link>https://lcz.me/post/13342</link><guid isPermaLink="true">https://lcz.me/post/13342</guid><dc:creator><![CDATA[fcme]]></dc:creator><pubDate>Fri, 21 Aug 2026 14:13:42 GMT</pubDate></item></channel></rss>