<?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[最終版 AMD RX 7900XTX 24GB 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄含雙卡]]></title><description><![CDATA[<p dir="auto"><img src="https://upload.lcz.me/uploads/97ea28df-49b3-480f-9280-6481f075cac7.jpg" alt="IMG_8340_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/e98feff1-5af0-48b4-8548-f7492ffdf0d8.jpg" alt="IMG_8346_compressed.jpg" class=" img-fluid img-markdown" /> # RX 7900 XTX 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄</p>
<p dir="auto">原本已經優化的差不了,看到大神Dflash60-80t/s我又折騰了快三天,出動codex cloude code 最終把dflash修成可以用hermes的版本,但速度最終提不上,最終棄坑,最後還是走最早之前的win11 +vulken的腳本 mtp投機,抄該腳本得到一個還不錯的結論,分享給大家,讓大家少走歪路,從中也學了許多,歡迎大家多分享發文,才會一起更懂這個新世界。</p>
<blockquote>
<p dir="auto">一張 7900 XTX、一個 27B 稠密模型、一個接 Telegram 的 Hermes agent，目標 45+ tok/s。<br />
這篇把<strong>所有試過的路、所有踩過的坑、所有真實數據</strong>攤出來分享。結論可能跟你想的相反：<br />
繞了一大圈、研究了 DFlash 等各種花招，最後<strong>贏在把設定拉回最樸素的「純 MTP n=3」</strong>。</p>
</blockquote>
<hr />
<h2>0. TL;DR（先給結論）</h2>
<ul>
<li><strong>可用解</strong>：<code>llama.cpp（HIP/ROCm）+ Qwen3.6-27B-Q4_K_M + 純 MTP 投機解碼（</code>--spec-type draft-mtp --spec-draft-n-max 3<code>）</code>。在真實 Hermes 加密分析 agent 上 <strong>decode 37–51 tok/s</strong>，工具調用尤其快。</li>
<li><strong>最大教訓</strong>：RDNA3 上 MTP 投機 <strong>n=3 是甜點，n=4 過度投機反而把接受率壓垮</strong>。這點被 Win11 報告、Lucebox DFlash 社群報告、跟我自己的真實 log <strong>三方獨立印證</strong>。</li>
<li><strong>走錯的路</strong>：(a) 疊 ngram 草稿器（對中文分析輸出沒貢獻還拉低整體接受率）；(b) 改用 DFlash（block-diffusion 草稿器，benchmark 數字漂亮但<strong>不適合長系統提示的 agent</strong>，詳見第 4 節）。</li>
<li><strong>戰略真相</strong>：ROCm 單卡相對 Win11 Vulkan <strong>是「側升」不是「提升」</strong>。而且<strong>實測兩張 7900 XTX 跑 llama.cpp 雙卡，generation 反而更慢</strong>（28 vs 單卡 37 t/s，無 NVLink、每步 decode 走 PCIe 同步）——雙卡只贏 prefill。要真的破 50–60 天花板，唯一沒測過的路是 <strong>vLLM tensor-parallel</strong>（理論 120–150，但那是跟 llama.cpp 雙卡完全不同的機制）。</li>
</ul>
<hr />
<h2>1. 硬體與目標</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>項目</th>
<th>內容</th>
</tr>
</thead>
<tbody>
<tr>
<td>GPU</td>
<td>撼訊 地獄犬 丐版 雙8Pin 以後比較好處理? 哈 AMD Radeon RX 7900 XTX 24GB <strong>×2</strong>（Navi 31 / gfx1100 / RDNA3），顯存帶寬 ~960 GB/s／卡；兩卡走 PCIe 4.0 x16、<strong>無 NVLink/fabric 直連</strong>。LLM 日常用單卡，另一張平時跑 ComfyUI</td>
</tr>
<tr>
<td>CPU</td>
<td>AMD Ryzen 9 7950X</td>
<td>照片是洋垃圾</td>
<td>最終的設備主板是 ASUS TUF X670E-PUS WIFI 可雙卡pcie-x8+x8</td>
<td>32G DDR5-6000</td>
</tr>
<tr>
<td>OS / 驅動</td>
<td>Ubuntu，ROCm 7.2.0（gfx1100 需 <code>HSA_OVERRIDE_GFX_VERSION=11.0.0</code>）</td>
</tr>
<tr>
<td>模型</td>
<td>Qwen3.6-27B 稠密 Q4_K_M（~16 GB），含 MTP 層</td>
</tr>
<tr>
<td>用途</td>
<td>Hermes Agent 接 Telegram，跑加密貨幣盤勢分析、工具調用</td>
</tr>
<tr>
<td>目標</td>
<td>decode ≥ 45 tok/s、context 32K→64K、工具調用要正常、不能 OOM</td>
</tr>
<tr>
<td>限制</td>
<td>第二張卡跑 ComfyUI（port 8188）不能動；既有 production fallback 腳本不能覆蓋</td>
</tr>
</tbody>
</table>
<hr />
<h2>2. 完整速度數據（最終可用配置：純 MTP n=3）</h2>
<p dir="auto">全部是 <strong>RX 7900 XTX 單卡、ROCm 7.2.0、Q4_K_M、KV q4_0、真實工作負載</strong>實測。</p>
<h3>2-1 Hermes agent（接 Telegram，含 6.6k token 系統提示 + 工具）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>請求類型</th>
<th>decode tok/s</th>
<th>MTP 接受率</th>
<th>備註</th>
</tr>
</thead>
<tbody>
<tr>
<td>工具調用（結構化 JSON 輸出）</td>
<td><strong>47–51</strong></td>
<td><strong>80–88%</strong></td>
<td>最快，JSON 超好預測</td>
</tr>
<tr>
<td>長篇中文盤勢分析（10k+ context）</td>
<td>36–37</td>
<td>54–56%</td>
<td>長 context + novel 輸出</td>
</tr>
<tr>
<td>prefill（冷啟動 9.5k tokens）</td>
<td>734 tok/s</td>
<td>—</td>
<td>~13s</td>
</tr>
<tr>
<td>prefill（checkpoint 復用）</td>
<td>~600 tok/s</td>
<td>—</td>
<td>新 token 才算，~2s</td>
</tr>
</tbody>
</table>
<h3>2-2 純模型回應速度（無工具、短提示、自由生成，各跑一次）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>內容</th>
<th>decode tok/s</th>
<th>接受率</th>
</tr>
</thead>
<tbody>
<tr>
<td>中文散文</td>
<td>38.9</td>
<td>56%</td>
</tr>
<tr>
<td>中文文章（區塊鏈介紹）</td>
<td>39.6</td>
<td>58%</td>
</tr>
<tr>
<td>中文條列清單</td>
<td>39.7</td>
<td>58%</td>
</tr>
<tr>
<td>中文對話問答</td>
<td>40.3</td>
<td>59%</td>
</tr>
<tr>
<td>中文翻譯改寫</td>
<td>43.7</td>
<td>67%</td>
</tr>
<tr>
<td>程式碼生成（Python + 測試）</td>
<td>42.2</td>
<td>64%</td>
</tr>
<tr>
<td>英文散文</td>
<td>41.7</td>
<td>62%</td>
</tr>
<tr>
<td>英文技術說明</td>
<td>41.1</td>
<td>61%</td>
</tr>
<tr>
<td><strong>平均</strong></td>
<td><strong>~41</strong></td>
<td><strong>56–67%</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>反直覺但真實的發現</strong>：純對話（~41）比工具調用（47–51）<strong>慢</strong>。原因是 MTP 投機解碼的速度跟「輸出可預測性」直接掛勾——固定格式的 JSON 工具調用接受率 80–88%，自由中文/英文散文只有 56–67%，所以反而慢。<strong>速度不是固定值，是隨輸出內容浮動的。</strong></p>
<h3>2-3 長 context 速度（重要：幾乎不掉速）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>context 長度</th>
<th>decode tok/s</th>
<th>接受率</th>
<th>prefill</th>
</tr>
</thead>
<tbody>
<tr>
<td>~10K</td>
<td>37–51</td>
<td>54–88%</td>
<td>734 tok/s</td>
</tr>
<tr>
<td><strong>~38K</strong></td>
<td><strong>37.5</strong></td>
<td><strong>69%</strong></td>
<td>578 tok/s</td>
</tr>
</tbody>
</table>
<p dir="auto">補一個更高的點（~60K context）：decode <strong>34.1 tok/s</strong>、接受率 70%——從 10K 到 60K 只掉約 8%，不是斷崖。推到 128K 滿載約 ~28–32 tok/s。</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>context</th>
<th>decode tok/s</th>
</tr>
</thead>
<tbody>
<tr>
<td>~10K</td>
<td>37–51</td>
</tr>
<tr>
<td>~38K</td>
<td>37.5</td>
</tr>
<tr>
<td>~60K</td>
<td>34.1</td>
</tr>
<tr>
<td>128K（推估）</td>
<td>~28–32</td>
</tr>
</tbody>
</table>
<p dir="auto">長 context decode 速度<strong>掉得很慢</strong>——Qwen3.6 是 hybrid SSM 架構，64 層裡只有 16 層有 attention（會隨長度變貴），其餘 48 層是 SSM 遞推（無 KV、成本與長度無關），加上 q4_0 KV 極省。<strong>因此 ctx-size 開到 128K 也只是極限長度才略降速。</strong></p>
<p dir="auto"><strong>VRAM 實測</strong>：<code>--ctx-size 131072</code>（128K）在 24GB 7900 XTX 上<strong>啟動佔用 21GB</strong>（含預配的 128K KV cache），留 ~3.5GB 餘裕，可行。跑超長對話時建議瞄 <code>rocm-smi</code>，逼近 24GB 就降到 96K（<code>--ctx-size 98304</code>）。這也呼應 Win11 當時「80K–128K 速度沒差多少」的觀察。</p>
<h3>2-4 實戰補充：128K 腳本多輪真實 session（telegram 加密 agent）</h3>
<p dir="auto">實際用 128K 腳本連續跑了 12 輪真實 Telegram 加密分析請求（ctx-size 設 128K，實際對話長度落在 13K–20K token）。<strong>體感很順</strong>，數據如下：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>輸出型態</th>
<th>接受率</th>
<th>decode tok/s</th>
<th>樣本</th>
</tr>
</thead>
<tbody>
<tr>
<td>工具調用 / 結構化</td>
<td>71–93%</td>
<td><strong>42–51</strong></td>
<td>51.0 / 48.7 / 47.2 / 46.2 / 41.8 …</td>
</tr>
<tr>
<td>自由中文分析（長文）</td>
<td>50–57%</td>
<td>34–36</td>
<td>34.7 / 34.0 / 34.5 / 36.2 …</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>prefill（後續輪次）</strong>：靠 llama-server 的 context-checkpoint 自動復用，後續每輪只 prefill 新 token（459–568 tok/s，約 1–7 秒），不是每次重算整個 prompt。每個 checkpoint ~158–172 MiB、隨位置緩慢長大，restore 僅 ~17–20 ms。</p>
<p dir="auto"><strong>三個結論</strong>：</p>
<ol>
<li><strong>128K ctx-size 在實際 13–20K 對話下完全不拖慢 decode</strong>——預先配置的 128K KV 不影響 decode 速度，decode 只付「實際 context 長度」的注意力成本（不是 ctx-size 上限）。設大 ctx-size 是免費的保險。</li>
<li><strong>速度雙峰、由輸出型態決定</strong>：工具調用 JSON 接受率 71–93% → 42–51 tok/s；自由中文分析接受率 50–57% → 34–36 tok/s。<strong>這就是「體感不錯」的原因——agent 互動主力是工具調用，正好落在快的那一檔。</strong></li>
<li><strong>context-checkpoint 讓多輪對話的首 token 延遲很低</strong>，這對 Telegram 即時互動比「純 decode 峰值速度」更重要。</li>
</ol>
<hr />
<h2>3. 時間線：每個階段做了什麼</h2>
<h3>階段 0 — 起點：Win11 + Vulkan，本來就有 50–80 tok/s</h3>
<p dir="auto">最早在 <strong>Windows 11 原生 + llama.cpp Vulkan</strong> 上就跑得很好，配置極簡：</p>
<pre><code>llama-server.exe -m Qwen3.6-27B-Q4_K_M-mtp.gguf（froggeric 版，含 MTP 層）
  --device Vulkan0 -ngl 999 -c 65536
  -ctk q4_0 -ctv q4_0 -np 1
  --spec-type draft-mtp --spec-draft-n-max 3   ← 關鍵：純 MTP，n=3
  --reasoning off -fa 1
</code></pre>
<p dir="auto">實測（Hermes 結構化輸出）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>場景</th>
<th>TG</th>
<th>MTP 接受率</th>
</tr>
</thead>
<tbody>
<tr>
<td>系統提示暖機（14k）</td>
<td>62.8</td>
<td>95.6%</td>
</tr>
<tr>
<td>Telegram 指令</td>
<td>60–74</td>
<td>72–98%</td>
</tr>
<tr>
<td>直接 API 短句</td>
<td><strong>79.9</strong></td>
<td>—</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>關鍵調參結論（當時就驗證過）</strong>：</p>
<ul>
<li>KV cache <strong>q8_0 → q4_0</strong>：Vulkan 後端 q8_0 有嚴重 prefill 瓶頸，q4_0 沒有（prefill 273→730 tok/s）。</li>
<li><strong>n=3 是甜點，n=4 過度投機反降</strong>（n=2→43.3、n=3→47.3、n=4→40.7）。</li>
<li><code>--reasoning off</code>：不關的話 Qwen3 thinking budget 預設無限，會生 8000+ token 卡死整個 queue。</li>
</ul>
<blockquote>
<p dir="auto">Hybrid SSM 架構（Qwen3.6）的 KV cache <strong>無法跨對話複用</strong>，每次都要重跑全部 prompt，這是正常現象。</p>
</blockquote>
<h3>階段 1 — 為何想搬到 ROCm（遷移研究）</h3>
<p dir="auto">當時想突破 50–80，做了 WSL2/ROCm/vLLM 升級研究。<strong>研究結論（事後看完全命中）</strong>：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>路線</th>
<th>速度預估</th>
<th>對 Hermes</th>
</tr>
</thead>
<tbody>
<tr>
<td>現狀 Vulkan + MTP 單卡</td>
<td>60–80</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /> 已夠用</td>
</tr>
<tr>
<td>ROCm llama.cpp 單卡 無 MTP</td>
<td>29</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /> 太慢</td>
</tr>
<tr>
<td>ROCm llama.cpp 單卡 有 MTP</td>
<td>67</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /> 當時有 context 只剩 4K 的 bug</td>
</tr>
<tr>
<td>vLLM ROCm 單卡</td>
<td>80–100</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/26a0.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--warning" style="height:23px;width:auto;vertical-align:middle" title="⚠" alt="⚠" />️ 64K 壓線、長對話 OOM 風險</td>
</tr>
<tr>
<td><strong>vLLM ROCm 雙卡 tensor-parallel</strong></td>
<td><strong>120–150</strong></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /> <strong>真正的提升</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>「WSL2/ROCm 單卡對 Hermes 是側升不是提升」</strong>——白紙黑字寫在研究裡。真正提升要雙卡 vLLM。</p>
<p dir="auto">ROCm 遷移的三個地雷（避免重蹈）：</p>
<ol>
<li>不設 <code>HSA_OVERRIDE_GFX_VERSION=11.0.0</code> → <code>No AMD GPUs found</code>（gfx1100 預設識別失敗）。</li>
<li>ROCm 版本要鎖，別讓 apt 亂升。</li>
<li>（WSL2）vLLM 的 amdsmi 不通，要改用 PyTorch 偵測 GPU；且絕不能在 WSL2 裡裝 amdgpu kernel driver。</li>
</ol>
<h3>階段 2 — 搬到 ROCm 後反而變慢：設定「漂移」</h3>
<p dir="auto">搬到 Ubuntu + ROCm 後，配置不知不覺從證明過的「純 MTP n=3」漂移成：</p>
<ul>
<li><code>--spec-type draft-mtp,ngram-mod,ngram-map-k4v</code>（疊了兩個 ngram 草稿器）</li>
<li><code>--spec-draft-n-max 4</code>（不是 3）</li>
</ul>
<p dir="auto">結果真實加密 agent 只剩 <strong>~22–25 tok/s</strong>。比 Win11 還慢。</p>
<h3>階段 3 — 一頭栽進 DFlash（漂亮的 benchmark，錯的方向）</h3>
<p dir="auto">詳見第 4 節。簡言之：DFlash 社群報告在 7900 XTX 上跑出 <strong>68.8 tok/s</strong>，看了手癢，花了大把時間在它身上 debug、改 code、修 bug……最後發現<strong>它的數字是短程式碼 benchmark，套到長系統提示的 hermes agent 上只有 ~23 tok/s</strong>。</p>
<h3>階段 4 — 找回速度：拉回 Win11 配方</h3>
<p dir="auto">翻出當年的 Win11 報告，發現答案一直都在：<strong>純 MTP n=3</strong>。把 ROCm 的設定拉回去（去掉 ngram、n=4→3），真實 agent 立刻從 ~22 跳到 <strong>~43 tok/s</strong>（工具調用 47–51），接受率從 36% 回到 54–88%。<strong>問題就是設定漂移，根因解決。</strong></p>
<hr />
<h2>4. DFlash 深入研究：為什麼社群的 68 tok/s 用不到 Hermes agent</h2>
<blockquote>
<p dir="auto">這節獻給所有看到 Reddit/論壇「DFlash 在 7900 XTX 跑 68 tok/s」而心動的人。</p>
</blockquote>
<h3>4-1 DFlash 是什麼</h3>
<p dir="auto">Lucebox DFlash 是一種投機解碼法，用<strong>輕量 block-diffusion 草稿模型</strong>並行起草，再用 DDTree 樹狀驗證。社群（<a href="http://lcz.me" rel="nofollow ugc">lcz.me</a> / Reddit）在 7900 XTX + Qwen3.6-27B 上實測：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>方案</th>
<th>tok/s</th>
<th>說明</th>
</tr>
</thead>
<tbody>
<tr>
<td>純自回歸基線</td>
<td>30.8</td>
<td>—</td>
</tr>
<tr>
<td>ROCm MTP n=3</td>
<td>47.3</td>
<td>純 MTP（就是我們最後用的）</td>
</tr>
<tr>
<td><strong>DFlash Q8 draft + budget=8</strong></td>
<td><strong>68.8</strong></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f3c6.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--trophy" style="height:23px;width:auto;vertical-align:middle" title="🏆" alt="🏆" /> 社群最佳</td>
</tr>
<tr>
<td>DFlash Q4 draft + budget=22</td>
<td>27.0</td>
<td>Q4 反量化拖慢 + 樹太大</td>
</tr>
</tbody>
</table>
<h3>4-2 致命前提：那 68.8 是怎麼測的</h3>
<p dir="auto">社群用 <code>bench_he.py</code>——<strong>10 道 HumanEval 程式題，prompt 只有 ~300 token，純解碼，binary 熱機</strong>。</p>
<ul>
<li>程式碼輸出<strong>超好預測</strong>（接受率 30–40%，AL 4.8）</li>
<li>prompt 短 → 草稿每步只處理 ~300 token、驗證 context 短</li>
<li>同一份報告也寫：用 <code>run.py</code> 單 prompt（含 prefill）只剩 <strong>56 tok/s</strong></li>
</ul>
<h3>4-3 為什麼套到 Hermes agent 就崩</h3>
<p dir="auto">Hermes agent 是<strong>三重不利</strong>，跟 HumanEval 完全相反：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>因素</th>
<th>HumanEval bench</th>
<th>Hermes 加密 agent</th>
</tr>
</thead>
<tbody>
<tr>
<td>系統提示</td>
<td>~300 token</td>
<td><strong>6,600 token</strong></td>
</tr>
<tr>
<td>輸出性質</td>
<td>程式碼（好預測）</td>
<td>中文盤勢分析（novel）</td>
</tr>
<tr>
<td>context</td>
<td>短</td>
<td>10k–14k</td>
</tr>
</tbody>
</table>
<p dir="auto">實測 DFlash daemon 在真實 agent 上：<strong>18–25 tok/s，接受率只有 11–18%</strong>。比純 MTP（~43）還慢一半。</p>
<h3>4-4 過程中挖出的 DFlash 真實 bug（修了也救不回）</h3>
<ul>
<li><strong><code>DFLASH27B_DRAFT_CTX_MAX=512</code> 從沒生效過</strong>：程式碼是 <code>min(ring_cap, max(2048, draft_ctx_max))</code>，那個 <code>max(2048,…)</code> 把任何 &lt;2048 的設定<strong>強制拉回 2048</strong>。改成讓明確設定值生效後，draft 每步成本下降，decode 從 13 拉到 23——但還是不到 45。</li>
<li><strong>長系統提示讓 draft 成本爆炸</strong>：DFlash 草稿每步處理 <code>min(committed, draft_ctx_max)</code> 個 token。6.6k 系統提示後就是每步重算數千 token，draft_compute 從 ~12ms（短 prompt）暴增到 ~160ms。這是 13.6× 差距的根源。</li>
<li><strong><code>DFLASH27B_CHUNKED=1</code> 是毒藥</strong>：號稱能並行 SSM 加速，實測造成 loopy/畸形輸出、接受率腰斬。別開。</li>
<li><strong>per-request 重載</strong>：用 Python 包的 server 每個請求都重新 spawn 進程、<code>--no-mmap</code> 重載 16GB 模型，互動式 Telegram 每則訊息付數十秒延遲——直接「沒回應」當掉。要用常駐 daemon。</li>
</ul>
<p dir="auto"><strong>結論：DFlash 適合「短 context + 程式碼/結構化」的 batch 工作，不適合「長系統提示 + 自由中文 + 即時互動」的 agent。</strong> 它的 block-diffusion 草稿在我們的場景反而是負擔。</p>
<hr />
<h2>5. 雙卡實驗（2× 7900 XTX）：為什麼日常還是用單卡</h2>
<p dir="auto">既然有兩張 7900 XTX，自然想用雙卡加速。花了最多時間做的就是「分割模式決戰」，結論<strong>非常反直覺</strong>。</p>
<h3>5-1 分割模式實測（128K context，tg = 生成速度）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>模式</th>
<th>tg（生成）</th>
<th>prefill（輸入）</th>
<th>備註</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>--split-mode layer --tensor-split 1,1</code></td>
<td>~30</td>
<td>~350</td>
<td>VRAM 分攤好，生成有跨 GPU 等待</td>
</tr>
<tr>
<td><code>--split-mode tensor --tensor-split 6,5</code></td>
<td>~32</td>
<td>~420</td>
<td>prefill 快，生成有 all-reduce 開銷</td>
</tr>
<tr>
<td><code>--device ROCm0,ROCm1 --tensor-split 6,5</code></td>
<td>~28</td>
<td><strong>~445</strong></td>
<td>prefill 最快，tg 最慢</td>
</tr>
<tr>
<td><strong>單卡（GPU0 only）</strong></td>
<td><strong>~37</strong></td>
<td>~380</td>
<td><strong>tg 最快</strong> <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
</tbody>
</table>
<h3>5-2 結論：雙卡贏 prefill、輸 generation</h3>
<p dir="auto"><strong>兩張 7900 XTX 沒有 NVLink / Infinity Fabric 直連，雙卡資料交換得走 CPU<img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2194.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--left_right_arrow" style="height:23px;width:auto;vertical-align:middle" title="↔" alt="↔" />PCIe。</strong> 每個 decode 步驟都要跨卡同步，所以：</p>
<ul>
<li><strong>prefill（一次處理整個 prompt）</strong>：雙卡能並行，445 vs 單卡 380，<strong>快 ~18%</strong>。</li>
<li><strong>generation（一個一個 token 出）</strong>：每步都被 PCIe 同步拖住，雙卡 28 vs 單卡 <strong>37</strong>，<strong>反而慢</strong>。</li>
</ul>
<p dir="auto">對 Hermes Agent 這種「長對話、逐 token 生成」的場景，<strong>generation 速度才是體感關鍵</strong>，所以日常 Telegram 用<strong>單卡</strong>。雙卡只在「貼超長文件、prefill 量極大」時才有意義。</p>
<blockquote>
<p dir="auto"><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/26a0.png?v=d348ca29232" class="not-responsive emoji emoji-android emoji--warning" style="height:23px;width:auto;vertical-align:middle" title="⚠" alt="⚠" />️ 這跟「vLLM 雙卡 tensor-parallel 120–150」不衝突：vLLM 的 TP 是<strong>每層矩陣同時拆兩卡再合併</strong>的真並行，機制跟 llama.cpp 的 layer/tensor-split（序列等待 / all-reduce）完全不同。llama.cpp 雙卡實測 tg 反降是事實；vLLM TP 是另一條沒測過的路。</p>
</blockquote>
<h3>5-3 腳本矩陣（按場景）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>腳本</th>
<th>GPU</th>
<th>context</th>
<th>tg</th>
<th>prefill</th>
<th>場景</th>
</tr>
</thead>
<tbody>
<tr>
<td>日常 Telegram</td>
<td>單卡</td>
<td>64K</td>
<td>~40</td>
<td>~377</td>
<td>對話（最常用）</td>
</tr>
<tr>
<td>長文穩定</td>
<td>單卡</td>
<td>128K</td>
<td>~36</td>
<td>~383</td>
<td>長文分析</td>
</tr>
<tr>
<td>長文快速（ub512）</td>
<td>單卡</td>
<td>128K</td>
<td>~36</td>
<td>~390</td>
<td>偶爾 OOM</td>
</tr>
<tr>
<td>雙卡高 prefill</td>
<td>雙卡</td>
<td>128K</td>
<td>~28</td>
<td><strong>~445</strong></td>
<td>超長 prompt 預填</td>
</tr>
</tbody>
</table>
<p dir="auto">（註：以上是 n=4+ngram 配置的歷史數據；本報告第 2 節的 n=3 純 MTP 在工具調用上更快，47–51。）</p>
<hr />
<h2>6. 完整踩坑清單（分享重點）</h2>
<h3>投機解碼 / 模型層</h3>
<ol>
<li><strong>RDNA3 上 MTP <code>n=3</code> 是甜點，<code>n=4</code> 過度投機反降。</strong> 三方印證。別抄 CUDA 的「n 越大越好」。</li>
<li><strong>ngram 草稿器疊加在中文/分析輸出上是死重</strong>：幾乎不命中（接受率貢獻 ~0），還拉低整體 acceptance。純 MTP 最快。</li>
<li><strong>MTP 速度隨輸出可預測性浮動</strong>：JSON 工具調用 47–51 tok/s（接受率 80–88%），自由散文只剩 ~40（56–67%）。報速度一定要講工作負載。</li>
<li><strong>DFlash 的 68 是短程式碼 benchmark，別當通用值</strong>（見第 4 節）。</li>
<li><strong><code>DFLASH27B_CHUNKED=1</code> 會造成畸形輸出</strong>，別開。</li>
<li><strong>Qwen3 thinking 要關，但 <code>--reasoning-budget 0</code> 沒用！</strong>（實測踩到）用 <code>--jinja</code> 載 Qwen3.6 內建 template 時 thinking 預設開；<code>--reasoning-budget 0</code> 只是把預算設 0，<strong>模型照樣生整段思考鏈</strong>（會跑進 <code>reasoning_content</code>，webui 看得到，白白浪費 token 拖慢速度）。<strong>必須用 <code>--reasoning off</code>（<code>-rea off</code>）才真正關閉</strong>。實測：budget 0 → <code>reasoning_content</code> 有整段思考；<code>--reasoning off</code> / <code>enable_thinking=false</code> → 思考清空。</li>
<li><strong>Hybrid SSM 架構 KV 無法跨對話複用</strong>，每次重跑 prompt 是正常現象；要靠 prefix-cache / context-checkpoint 省 prefill。</li>
</ol>
<h3>ROCm / RDNA3 後端</h3>
<ol start="8">
<li><strong>絕大多數網路上的「ROCm 優化參數」都是抄 CUDA 的，在 RDNA3 沒效甚至反效果。</strong> 實測：<code>--batch-size 1024</code>、<code>--flash-attn</code>、<code>MMVQ_MAX_BATCH</code> 全沒用或變慢；<code>--no-mmap</code> 在 ROCm 上甚至 OOM。</li>
<li><strong><code>ROCBLAS_USE_HIPBLASLT=1</code> 在 gfx1100 根本不支援</strong>（只給 MI200/MI300），設了無效還可能報警告。</li>
<li><strong>rocWMMA flash-attn 調優分支（曾宣稱長 context decode +136%）已被官方拒絕（PR #16827），且在 ROCm 7.2.x 是 regression</strong>，head_dim&gt;128 也打不贏現有 tile kernel。對 Qwen3 沒好處。</li>
<li><strong>KV cache 量化（q4_0 / tq3_0 / q8_0）對 decode 速度幾乎無影響</strong>，純粹是 VRAM/context 長度的取捨；q4_0 最省、能上 64K+。別把它當速度 fix。</li>
<li><strong><code>tq3_0</code> KV + 溫度&gt;0 的 AR decode 在 HIP 會 crash</strong>（VEC kernel 不支援 tq3_0），需 <code>kq_stride_pad=256</code> + 補 mask。</li>
</ol>
<h3>量測方法（最容易自欺）</h3>
<ol start="13">
<li><strong>合成 benchmark 一律會誤導</strong>：純散文低估、純 JSON 高估，兩次都讓我得到相反的調參結論。<strong>只有使用者真實工作負載的 log 才算數。</strong></li>
<li><strong>量測工具要對齊</strong>：<code>bench_he.py</code>（多 prompt 純解碼）vs <code>run.py</code>（單 prompt 含 prefill）差了 20%。對標別人一定要同款工具。</li>
<li><strong><code>--fa-window</code> 小於系統提示長度會切掉工具格式指令 → 工具調用失敗</strong>。6.6k 系統提示就別設 4096 以下（或直接 0）。</li>
</ol>
<h3>架構 / 戰略</h3>
<ol start="16">
<li><strong>ROCm 單卡相對 Win11 Vulkan+MTP 是「側升不是提升」</strong>。而且<strong>實測 llama.cpp 雙卡（layer/tensor/device split 都試過）generation 反而比單卡慢</strong>（28 vs 37 t/s，無 NVLink、每步 PCIe 同步；見第 5 節）。雙卡只贏 prefill。要破天花板只剩 vLLM tensor-parallel（真並行，機制不同，未實測）。</li>
<li><strong>雙卡的隱形坑</strong>：<code>cache-ram &gt; 0</code> 會讓部分 KV 在 RAM、PCIe 傳輸不一致 → 生成速度劇烈抖動，要 <code>--cache-ram 0</code> 全進 VRAM；<code>HIP_FORCE_DEV_KERNELS=1</code> 在 gfx1100 不生效（ROCm 7.2 已預編譯）；<code>batch 4096 / ubatch 2048</code> 在 128K 直接 OOM，單 user 場景用 512/256 就好。</li>
<li><strong>設定會「漂移」</strong>：一路調一路加，最後離當初證明過的配方越來越遠。<strong>留一份「黃金配方」隨時能退回。</strong></li>
</ol>
<hr />
<h2>7. 最終可用設定</h2>
<pre><code class="language-bash">#!/bin/bash
export HIP_VISIBLE_DEVICES=0
export ROCR_VISIBLE_DEVICES=0
export HSA_ENABLE_SDMA=0
export HSA_OVERRIDE_GFX_VERSION=11.0.0     # gfx1100 必設
export LLAMA_ARG_STOP="&lt;think&gt;,&lt;/think&gt;"

llama-server \
  --model Qwen3.6-27B-MTP-Q4_K_M.gguf \
  --device ROCm0 \
  --spec-type draft-mtp \                  # 純 MTP，不要疊 ngram
  --spec-draft-n-max 3 \                   # RDNA3 甜點，別用 4
  -b 512 -ub 512 \
  --ctx-size 131072 \                      # 128K；hybrid SSM 長 context 不掉速，OOM 就降 96K
  --flash-attn on \
  --n-gpu-layers 99 \
  --cache-type-k q4_0 --cache-type-v q4_0 \ # 省 VRAM，上 64K 的關鍵
  --reasoning off \                         # 關 thinking！必須用 reasoning off，不是 budget 0（見坑 #6）
  --prefix-cache-slots 4 \                  # 快取系統提示，省 prefill
  --host 0.0.0.0 --port 8080 --parallel 1 --jinja
</code></pre>
<p dir="auto">實測：Hermes 工具調用 47–51 tok/s、純對話 ~41 tok/s、長分析 ~37 tok/s，工具調用正常，達成 ≥45 目標。</p>
<hr />
<h2>8. 給想複製的人</h2>
<ul>
<li><strong>只想能用、省事</strong>：照第 6 節，純 MTP n=3，就到 40–50 tok/s 了。別碰 DFlash、別疊 ngram、別亂抄 CUDA flag。</li>
<li><strong>想衝更高</strong>：你已經到單卡 7900 XTX + 27B 的物理天花板附近（~50–60）。唯一沒測過、可能真正往上的路是 <strong>vLLM tensor-parallel 雙卡</strong>（真並行、理論 ~120–150；注意 llama.cpp 雙卡反而更慢，見第 5 節）。</li>
<li><strong>DFlash 想玩可以</strong>，但請認清它的舞台是短 context / 程式碼，不是長系統提示的即時 agent。</li>
</ul>
<hr />
<p dir="auto"><em>硬體：RX 7900 XTX 24GB ×1｜ROCm 7.2.0｜Qwen3.6-27B Q4_K_M｜2026-06</em></p>
<p dir="auto">9.附上128k長任務生產力<img src="https://upload.lcz.me/uploads/8da8caa9-5b47-4182-b32b-a7055443aa8c.jpg" alt="IMG_8520_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/c7e0ddd2-16a8-4c2a-8269-5a778c858193.jpg" alt="IMG_8518_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/f32c4548-268b-49d5-a161-f3318cc62bd8.jpg" alt="IMG_8523_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/1079b2fb-6e83-47db-9d0c-3c2eaa031ea0.jpg" alt="IMG_8524_compressed.jpg" class=" img-fluid img-markdown" /> 成功達成,附圖</p>
]]></description><link>https://lcz.me/topic/549/最終版-amd-rx-7900xtx-24gb-跑-qwen3.6-27b-hermes-agent-從-win11-vulkan-到-ubuntu-rocm-的完整實戰與踩坑全紀錄含雙卡</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 14:28:54 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/549.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Jun 2026 08:10:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 最終版 AMD RX 7900XTX 24GB 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄含雙卡 on Sat, 13 Jun 2026 10:23:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/agi" aria-label="Profile: AGI">@<bdi>AGI</bdi></a> 我平常分析幣價跟查詢新聞時事,目前用起來還夠用,剛剛幫親戚翻譯也做得不錯,長輩很滿意,其實可以到q8,但我的需求跑起來差不多</p>
]]></description><link>https://lcz.me/post/6652</link><guid isPermaLink="true">https://lcz.me/post/6652</guid><dc:creator><![CDATA[CHIA AN YANG]]></dc:creator><pubDate>Sat, 13 Jun 2026 10:23:23 GMT</pubDate></item><item><title><![CDATA[Reply to 最終版 AMD RX 7900XTX 24GB 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄含雙卡 on Sat, 13 Jun 2026 10:23:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chia-an-yang" aria-label="Profile: CHIA-AN-YANG">@<bdi>CHIA-AN-YANG</bdi></a> 1，LTX2.3模型，2，分辨率选择960*544，3，研究刘悦工作流，先使用内部Latent放大。4，它做不了太长的，但是十几秒没问题。xtx事能玩视频的，其实480P也行，足够清晰了。你在视频生成完毕之后，在专门做一次单独的高清放大，你问AI，效果不会太好，但绝对能看。</p>
]]></description><link>https://lcz.me/post/6651</link><guid isPermaLink="true">https://lcz.me/post/6651</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sat, 13 Jun 2026 10:23:06 GMT</pubDate></item><item><title><![CDATA[Reply to 最終版 AMD RX 7900XTX 24GB 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄含雙卡 on Sat, 13 Jun 2026 10:21:21 GMT]]></title><description><![CDATA[<p dir="auto">模型和kv都用q4 量化？影响大吗？</p>
]]></description><link>https://lcz.me/post/6650</link><guid isPermaLink="true">https://lcz.me/post/6650</guid><dc:creator><![CDATA[AGI]]></dc:creator><pubDate>Sat, 13 Jun 2026 10:21:21 GMT</pubDate></item><item><title><![CDATA[Reply to 最終版 AMD RX 7900XTX 24GB 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄含雙卡 on Sat, 13 Jun 2026 09:16:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry" aria-label="Profile: terry">@<bdi>terry</bdi></a> 我也是想多了,結果多買一張卡,現在想來玩comfyui老特有初學者可以抄的作業嗎?我目前只讓hermes配置好能出高清圖,但出短影片完全失敗,畫質太差了!</p>
]]></description><link>https://lcz.me/post/6644</link><guid isPermaLink="true">https://lcz.me/post/6644</guid><dc:creator><![CDATA[CHIA AN YANG]]></dc:creator><pubDate>Sat, 13 Jun 2026 09:16:51 GMT</pubDate></item><item><title><![CDATA[Reply to 最終版 AMD RX 7900XTX 24GB 跑 Qwen3.6-27B Hermes Agent — 從 Win11 Vulkan 到 Ubuntu ROCm 的完整實戰與踩坑全紀錄含雙卡 on Sat, 13 Jun 2026 09:02:30 GMT]]></title><description><![CDATA[<p dir="auto">非常好，我本来想入一个xtx跑上卡大模型的，现在看来想多了。</p>
]]></description><link>https://lcz.me/post/6642</link><guid isPermaLink="true">https://lcz.me/post/6642</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sat, 13 Jun 2026 09:02:30 GMT</pubDate></item></channel></rss>