<?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 + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark）]]></title><description><![CDATA[<p dir="auto">跟住 <a href="https://lcz.me/topic/1532">https://lcz.me/topic/1532</a> 同 <a href="https://lcz.me/topic/1567">https://lcz.me/topic/1567</a> 兩位前輩嘅路線，我喺自己部機由零行咗一次完整 setup，順便做咗全套 benchmark 同 HiCache 逐出/還原實測。有幾個新發現（尤其 HiCache 嗰 part）想還返俾社群。</p>
<h2>一、硬件</h2>
<ul>
<li>CPU：EPYC 7K62 48C（洋垃圾）</li>
<li>兩張 Sapphire PULSE 7900 XTX 24G，<strong>PCIe 4.0 x16 + x16</strong>（lspci LnkSta 實測）— EPYC lanes 夠，TP all-reduce 冇瓶頸，比 X670E x8/x8 爽</li>
<li>125GB RAM、Ubuntu 24.04.4、kernel 7.0.0-31</li>
<li>機入面另外兩張 4080 SUPER 行緊另一個 FP8 instance，兩邊並行唔相撞（ROCm 只見 AMD 卡）</li>
</ul>
<h2>二、軟件棧同安裝</h2>
<ul>
<li>ROCm 7.2.0 userspace：kernel 7.0 內核 amdgpu 直接用，唔使 dkms。注意 30.x 版 amdgpu-install 參數要等號：</li>
</ul>
<pre><code class="language-bash">sudo amdgpu-install -y --usecase=rocm --no-dkms --no-32
</code></pre>
<ul>
<li>Python 3.12 venv + torch 鎖死 2.11.0+rocm7.2（whl/rocm7.2 index），任何 pip 操作之後 check 返 torch.version.hip 有值</li>
<li>engine：StevenChenSE/sglang <code>gfx1100-support</code> 分支（f84475c），照 README：setup_rocm.py 編 19 個 kernels，成個 aot/python/sgl_kernel 目錄 copy 入 site-packages（要有 <strong>init</strong>.py 先至有 gptq_gemm）</li>
<li>自訂 all-reduce：scripts/rdna_ar/rdna_ar_ext.py + make（kfd_event_age_fix.so 用 LD_PRELOAD）</li>
</ul>
<h2>三、兩個必改嘅源碼 patch（今次分享重點之一）</h2>
<p dir="auto"><strong>Patch 1</strong>：all-reduce wrapper 入面 copy_sys_kernel 用咗 CDNA3 先有嘅 <code>__builtin_amdgcn_global_store_b128</code>，gfx1100 編唔過（要 gfx940-insts）。改做 RDNA3 安全嘅 128-bit volatile store（方向同 farmer-node 喺 <a href="https://lcz.me/topic/1640">https://lcz.me/topic/1640</a> 講嘅一致）：</p>
<pre><code class="language-cpp">// scripts/rdna_ar/rdna_custom_all_reduce.cu
-    __builtin_amdgcn_global_store_b128((sgl_v4u_gptr)(dst + i), v, "");
+    *(volatile sgl_v4u_gptr)(dst + i) = v;  // RDNA3: no b128 builtin
</code></pre>
<p dir="auto"><strong>Patch 2</strong>：custom_all_reduce_hip.cuh 入面 RankData 嘅 const void* <strong>restrict</strong> ptrs[8] 會令 clang 生成隱式 copy assignment 失敗（std::fill 需要），剷走 <strong>restrict</strong> 就得（純優化提示，零語義影響）：</p>
<pre><code class="language-cpp">-  const void* __restrict__ ptrs[8];
+  const void* ptrs[8];
</code></pre>
<p dir="auto">改完用 PYTORCH_ROCM_ARCH=gfx1100 行 rdna_ar_ext.py 一發過。</p>
<h2>四、模型</h2>
<p dir="auto">Vishva007/Qwen3.8-27B-W4A16-AutoRound-GPTQ（~19G，MTP 保持 bf16）。記得改 config.json：將 dynamic quantization rules 入面兩條 <code>+:.*mtp.*</code> 規則換成一條排除規則 <code>-:.*mtp.*</code>（bits 16、group 128），唔係嘅話 GPTQ loader 會喺 MTP tensor 上面炸。</p>
<h2>五、生產啟動配置（全套）</h2>
<pre><code class="language-bash">export SGL_DTYPE=bfloat16 SGLANG_RDNA_CUSTOM_AR=1 SGL_RDNA_NO_FUSED=1 \
       SGL_RDNA_GEMMA_TRITON=1 SGL_RDNA_VLLM_VERIFY=1
export LD_PRELOAD=~/sglang-gfx1100/sglang/scripts/rdna_ar/vendor/kfd_event_age_fix.so:$LD_PRELOAD

python3 -m sglang.launch_server \
  --model-path ~/models/Qwen3.8-27B-W4A16 --host 0.0.0.0 --port 30001 \
  --tp-size 2 --quantization gptq --dtype bfloat16 \
  --mamba-ssm-dtype bfloat16 --kv-cache-dtype auto \
  --attention-backend triton --triton-attention-num-kv-splits 16 \
  --context-length 196608 --mem-fraction-static 0.91 \
  --max-running-requests 4 --max-mamba-cache-size 20 \
  --speculative-algorithm NEXTN --speculative-num-steps 3 \
  --speculative-eagle-topk 1 --speculative-num-draft-tokens 4 \
  --cuda-graph-bs-decode 1 2 4 --chunked-prefill-size 2048 \
  --page-size 64 --schedule-policy lpm --sleep-on-idle \
  --reasoning-parser qwen3 --tool-call-parser qwen3_coder --enable-metrics \
  --enable-hierarchical-cache --hicache-ratio 2 \
  --hicache-io-backend direct --hicache-write-policy write_through \
  --default-chat-template-kwargs '{"reasoning_effort": "medium"}'
</code></pre>
<p dir="auto">KV pool 257,024 tokens（bf16），HiCache host pool 再加 514K（2×17.9G RAM + 1.6G mamba host）。</p>
<h2>六、Benchmark（2026-09-15，temp 0，串流 + usage 計數）</h2>
<p dir="auto"><strong>Decode vs 深度（MTP-3 單流）：</strong> 0 → <strong>78.4 tok/s</strong>（12.7ms/token）；16K → 71.7；32K → 64.9；65K → 61.3；131K → 42.0（23.8ms）</p>
<p dir="auto"><strong>併發：</strong> 1u 67.6 ／ 2u 合計 118.9 ／ 4u 合計 <strong>176 tok/s</strong></p>
<p dir="auto"><strong>Prefill（冷啟動）：</strong> 4K 峰值 1,869 tok/s；16K 1,715；32K 1,477（TTFT 22s）；65K 1,136；130K 777。4×32K 同時只有 1,469 — prefill 係計算飽和，排隊唔會快。</p>
<p dir="auto"><strong>快取：</strong> GPU radix 32K 冷 22s → 暖 <strong>0.41s</strong>（53.6×）；L2 還原見下節。</p>
<p dir="auto"><strong>MTP：</strong> accept length 2.725（/metrics 嘅 spec_accept_length）。</p>
<p dir="auto"><strong>同 2×4080S FP8 同日同方法對比：</strong> decode 78.4 vs 71.3（XTX +10%）；32K prefill 1,477 vs 1,914（4080S +29%）。同 #1532/#1640 嘅格局一致：XTX decode 勁、prefill 輸 NVIDIA 一截。</p>
<h2>七、HiCache 實測（新發現）</h2>
<p dir="auto">背景：fork 對混合架構（48 層 Gated DeltaNet + 16 層 full attention）有寫 mamba host cache，但作者都話未測過。我嘅逐出測試（載入 A → 灌爆 257K pool 逼 A 被逐出 → 再問 A）：</p>
<ol>
<li><strong>備份管線通</strong>：write-through 持續 backup（hicache_backup_tokens_total 上升，零 drop）</li>
<li><strong>純重複 prompt 觸發唔到還原</strong>（4.2s 全量 re-prefill）— 因為 mamba state 只會喺**請求完結點、prefill chunk 邊界（每 2048）、decode 追蹤點（每 256）**捐入 radix tree</li>
<li><strong>續接形態（下一輪 = 上一輪完整序列 + 新內容，即 agent 天然用法）完美還原</strong>：7.6K context 被逐出後 <strong>0.21s</strong> 由 RAM 還原（20×）；chat template 重 render 有時令 token 序列喺 thinking 位分歧，退落最近 2048-grid checkpoint 都有 2.66s（仍慳 37%）</li>
<li>分支形態（同 doc 唔同問題）只有部分著數 — 呢個先係真正嘅 hybrid 缺口（對應上游 sgl-project/sglang#12826）</li>
</ol>
<p dir="auto">結論：<strong>開住佢</strong>。有效容量 257K GPU + 514K host ≈ 771K，長 session agent 逐出後秒級恢復。io-backend 一定要 direct（kernel backend 對 hybrid mamba 會炸，sglang #24121）。</p>
<h2>八、陷阱清單</h2>
<ul>
<li><strong>千祈唔好數 SSE chunk 做 benchmark</strong>：MTP 下一個 chunk 載 2.6 個 token（= accept length），數 chunk 會低估 2.6 倍，要用 usage 計數</li>
<li>唔好 pkill -f sglang.launch_server — 會撈埋 Docker 入面其他 instance，用 port 搵 PID 精準殺</li>
<li>永遠唔好 rocm-smi --gpureset（gfx1100 鎖 PCIe root port，要冷開機）</li>
<li>pip 依賴要手動補：orjson、gguf、sentencepiece、dill、xgrammar、python-multipart、prometheus_client、openai、apache-tvm-ffi==0.1.11…</li>
<li>fork 冇 --max-consecutive-prefill-batches（上游 PR #34058 未併入），併發 prefill 打斷 decode 嘅卡頓暫時無解</li>
</ul>
<h2>致謝</h2>
<p dir="auto">StevenChenSE 嘅 fork、farmer-node 嘅 all-reduce 修法方向、以及 #1532 #1567 #1640 #1674 嘅前輩。mamba 分支還原嗰 part 如果有人焗到更深，歡迎交流。</p>
]]></description><link>https://lcz.me/topic/1714</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 01:16:46 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1714.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Sep 2026 04:56:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Wed, 16 Sep 2026 10:25:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stxpnet" aria-label="Profile: stxpnet">@<bdi>stxpnet</bdi></a> 正在想做什么视频，赶紧去看下，qwen还是要重视的。</p>
]]></description><link>https://lcz.me/post/18598</link><guid isPermaLink="true">https://lcz.me/post/18598</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Wed, 16 Sep 2026 10:25:46 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Wed, 16 Sep 2026 09:02:21 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> 改好了，完善了，QWEN 4.0又出来了，各种跑分又吊打这家那家。。。。。</p>
]]></description><link>https://lcz.me/post/18577</link><guid isPermaLink="true">https://lcz.me/post/18577</guid><dc:creator><![CDATA[stxpnet]]></dc:creator><pubDate>Wed, 16 Sep 2026 09:02:21 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 19:38:07 GMT]]></title><description><![CDATA[<p dir="auto">非常好的分享，这样就成了哥系列帖子，不断改善，等你们彻底改好了，我就抄作业，<img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f602.png?v=efcae6a46b1" class="not-responsive emoji emoji-android emoji--joy" style="height:23px;width:auto;vertical-align:middle" title="😂" alt="😂" /></p>
]]></description><link>https://lcz.me/post/18451</link><guid isPermaLink="true">https://lcz.me/post/18451</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Tue, 15 Sep 2026 19:38:07 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 13:52:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%E6%87%92%E4%BA%BA%E7%83%98%E5%9F%B9" aria-label="Profile: 懒人烘培">@<bdi>懒人烘培</bdi></a> 我設了300W 單卡上限</p>
]]></description><link>https://lcz.me/post/18390</link><guid isPermaLink="true">https://lcz.me/post/18390</guid><dc:creator><![CDATA[franklee006]]></dc:creator><pubDate>Tue, 15 Sep 2026 13:52:17 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 12:39:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/franklee006" aria-label="Profile: franklee006">@<bdi>franklee006</bdi></a> 我也是，放办公室。满载的时候我测试过，整机功耗992W，真是高。</p>
]]></description><link>https://lcz.me/post/18376</link><guid isPermaLink="true">https://lcz.me/post/18376</guid><dc:creator><![CDATA[懒人烘培]]></dc:creator><pubDate>Tue, 15 Sep 2026 12:39:41 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 07:54:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/geekyang" aria-label="Profile: Geekyang">@<bdi>Geekyang</bdi></a> 我放在辦公室</p>
]]></description><link>https://lcz.me/post/18317</link><guid isPermaLink="true">https://lcz.me/post/18317</guid><dc:creator><![CDATA[franklee006]]></dc:creator><pubDate>Tue, 15 Sep 2026 07:54:59 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 07:41:43 GMT]]></title><description><![CDATA[<p dir="auto">我一直好奇，这么大个头的东西，在家摆放在哪里？</p>
]]></description><link>https://lcz.me/post/18314</link><guid isPermaLink="true">https://lcz.me/post/18314</guid><dc:creator><![CDATA[Geekyang]]></dc:creator><pubDate>Tue, 15 Sep 2026 07:41:43 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 07:03:10 GMT]]></title><description><![CDATA[<p dir="auto">干货很足，尤其 HiCache 那段。补几条：</p>
<ol>
<li>
<p dir="auto">混合架构的 checkpoint 粒度是理解「純重複 prompt 還原唔到」的关键：48 层 GDN 的 mamba state 只在请求结束点、prefill chunk 边界、decode 追踪点落 radix tree。纯重复 prompt 若 token 串和上次完全一致，本应命中 GPU radix；你看到全量 re-prefill，多半是命中节点上没挂 mamba state，或 chat template 重 render 让 thinking 段 token 分叉。建议打日志看实际 match length，再决定是否在序列末尾加一个尾 token 把它变成「续接」形态——agent 负载本来就是续接，所以能用。</p>
</li>
<li>
<p dir="auto">L2 还原本建议按命中长度分层报。短前缀走 GPU radix（0.41s 那个），真正有价值的是 host pool 还原本。7.6K 的 0.21s 要标清是纯 host 命中还是 GPU+host 混合，否则和 2.66s 的 2048-grid 回退不好比。</p>
</li>
<li>
<p dir="auto">write_through 建议和 write_back 对一下首轮 prefill 吞吐，长 prefill 上写放大能吃回你 1,477 tok/s 的一部分。direct backend 对 hybrid 是必须的，这点同意。</p>
</li>
<li>
<p dir="auto">把 MTP accept length 2.725 和「不要数 SSE chunk」写在一起很关键，多数人 benchmark 就死在这。78.4 是 MTP 生效后的端到端，和单 forward 对比时要注明。</p>
</li>
</ol>
<p dir="auto">问一个：L2 还原到卡的路径是 pinned + PCIe 拷回，还是走了别的通道？EPYC 7K62 八通道 DDR4 带宽不缺，0.21s 是不是已经贴到 PCIe 上限，量一下 host 读带宽就知道还有没有空间。</p>
<p dir="auto">4080S prefill 领先 29% 不意外（FP8 + tile 调度），XTX 靠 decode 和显存容量打，方向是对的。</p>
]]></description><link>https://lcz.me/post/18308</link><guid isPermaLink="true">https://lcz.me/post/18308</guid><dc:creator><![CDATA[Xiaote]]></dc:creator><pubDate>Tue, 15 Sep 2026 07:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to 雙 7900XTX + SGLang 跑 Qwen3.8-27B 完整實戰：TP=2 由 ROCm 7.2 到 HiCache，decode 78 tok/s（附全套 benchmark） on Tue, 15 Sep 2026 06:01:19 GMT]]></title><description><![CDATA[<p dir="auto">支持，我也参考大神的文章，正在做双7900XTX卡单用户单任务的测试，目前等待配件中</p>
]]></description><link>https://lcz.me/post/18296</link><guid isPermaLink="true">https://lcz.me/post/18296</guid><dc:creator><![CDATA[懒人烘培]]></dc:creator><pubDate>Tue, 15 Sep 2026 06:01:19 GMT</pubDate></item></channel></rss>