<?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[自研RDNA高併發推論引擎 以AI Max+ 395為範例]]></title><description><![CDATA[<p dir="auto">趁Qwen4 27B出來前先開源分享這個<br />
連結分享 <a href="https://github.com/dardeaw/MBufo" rel="nofollow ugc">https://github.com/dardeaw/MBufo</a><br />
命名為MBufo：從gufo模改出的Mixed Batch推論引擎，支援主流的gguf</p>
<h2>雖然現在strata當紅，但strata並不具備高併發能力</h2>
<p dir="auto">我已有兩台strata主機，速度跟智商也不錯，但有個絕對致命傷 - <strong>只適合單流對話</strong><br />
一遇到多對話就得排隊，完全不適合做為服務，<br />
<strong>strata這種推論框架只建議用高性價方案去簡單拼湊就好</strong>，不要花大錢，多對話排隊的體驗不佳，<br />
真正的高併發，在於總吞吐量要隨著對話數量提高，並且不同對話之間不能有過久的等待，<br />
手上還有AI Max+395，為了展現他的價值，我開啟了手搓推論引擎之旅，<br />
兩個月前因Halogen的專用引擎效率很好，曾經試著<a href="https://lcz.me/topic/1723/16">魔改llama.cpp成自製引擎</a>想要跟Halogen比拚效能，拚了兩天就投降因為halogen確實先天上就贏llama.cpp太多了</p>
<h2>一直到了gufo的出現</h2>
<p dir="auto">gufo發布約晚halogen三週，但他開源呀!!<br />
我們先談談Halogen最大的缺點，要把他取代掉就得從這邊下手<br />
第一，它是黑盒。docker拉來跑，只能調環境變數，裡面長什麼樣全靠猜。想加模型？此路不通，想加功能？門都沒有。<br />
第二，它卡死的點是結構性的，排程的機制、KV的量化機制全部他說的算。<br />
第三，幾乎無高併發能力，除了預訂了四個slots做緩存增量快取與舊對話落盤SSD，其餘都是單對話思維做的設計。</p>
<p dir="auto">以 gufo為底進行改造。理由就一個：<strong>看得見、改得動</strong>，<br />
它的基底是半套高併發理由如下：<br />
1.它有batch但不是mixed batch，他有chunked prefill但不會左手prefill右手decode<br />
2.它的排程與插隊只有先進先出，跟llama.cpp、strata也一樣<br />
3.它的KV機制是fork的增量快取，類似較粗的radix tree，若把增量快取機制來比喻，SGlang是樹葉級、gufo是樹枝級、而llama.cpp、strata、halogen等都只是各別獨立的樹幹各自做增量快取。</p>
<h1>MBufo</h1>
<p dir="auto">針對以上經驗，專為 AMD Strix Halo 打造的 <a href="https://github.com/gufo-org/gufo" rel="nofollow ugc">gufo</a> 分支，<br />
定位為<strong>公平性＋高效低銷的推論引擎</strong>——排隊不插隊靠公平調度，花費少靠低精度計算。</p>
<p dir="auto">上游 gufo 負責單路極限效能；MBufo 真的做到服務端的問題：一台 Strix Halo 節點同時面對十六路請求時能跑多滿，每一路又能吃多長的上下文？三根支柱回答它——負載下公平的排程（§1）、更高壓縮的KV快取（§2）、一個 port 服務多顆模型的 GGUF覆蓋（§3）。底層引擎、核心與絕大部分程式碼都來自上游，在此致謝 gufo-org 及所有貢獻者。</p>
<p dir="auto">而同為RDNA3/4家族的7900XTX、R9700應該也能稍做修改就相容(但以VRAM為基準無法合併系統RAM使用)，<br />
甚至能魔改出雙卡TP，無奈我手上沒有設備能開發測試。</p>
<h2>MBufo 三個數字</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>數字</th>
<th>含義</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><strong>短請求 TTFT 0.7 秒</strong></td>
<td>被 25 萬 token prefill 卡住的短請求，原本要等 3.4 秒；公平排程後只要 0.7 秒（fairness-A 160 → 7.32、fairness-B 856 → 191，ITL 不變，貪婪輸出位元一致；v0.25.3）。</td>
</tr>
<tr>
<td>2</td>
<td><strong>KV 記憶體省一半</strong></td>
<td>blocked-Q8 快取讓 262144 token 的 session 從 6.44 GB 降到 3.42 GB（K4V4 為 1.81 GB），代價是量出來的、不是假設的（v0.25.2）。</td>
</tr>
<tr>
<td>3</td>
<td><strong>11 個 GGUF 家族</strong></td>
<td>一個 HTTP port 全數服務——v0.28.0 新增 8 個可用家族，加上 Flash-Next、27B、Gemma 4（見<a href="#%E6%94%AF%E6%8F%B4%E7%9A%84%E6%A8%A1%E5%9E%8Bv0280">§3 模型總表</a>），陸續新增中。</td>
</tr>
</tbody>
</table>
<h2>§1 高併發（架構差異）</h2>
<p dir="auto">併發不是一個數字。一台吃重的伺服器能不能用，是兩件事決定的，直接影響使用上的體感：</p>
<ul>
<li><strong>ITL（token 間延遲）</strong>——請求已經在串流之後，它前後兩個 token 之間的間隔。  批次效率再高，只要會讓一條會話凍住一整個 prefill 步驟，那就不叫服務，那叫排隊加上額外手續。</li>
<li><strong>公平性</strong>——沒有任何 session、客戶端或 prompt 可以讓別的對話等不到。一段 25 萬 token  的 prompt 插進對話中途，不該比十六路短對話得到更多資源。</li>
</ul>
<p dir="auto">原先gufo的排程器骨架已經是對的：prefill chunk 有上限、有待跑decoder 時先服務 decode 再做 prefill、admission 有每客戶端上限。它缺的是「便宜地同時兌現這三件事」：一個有上限的 chunk 仍然吃掉一整個 tick，而那個 tick 裡<strong>沒有任何</strong> decoder 產出 token——因為 chunk 與 decode 是兩趟分別掃過權重的計算。ITL 與公平性就是從這個 tick 漏掉的：每一輪，串流中的請求都要付一次與它無關的 prefill 步驟。</p>
<p dir="auto">MBufo 把兩者合併：chunk 與 decode 列共用同一個 <code>ForwardBatch</code>、同一個注意力核心，於是 prefill 的那個 tick 也順便把該出的 token 全部產出。合併沒有繞過公平政策；公平政策正是讓合併安全的前提。</p>
<h3>統一 mixed-batch 介面 統一KV量化介面</h3>
<p dir="auto">以物件導向(OOP)實作各模型的引擎，使得所有支援的模型都能享受到Mixed Batch的好處與支援各種KV量化</p>
<h3>公平性：排隊不插隊（SRTF＋飢餓 decode 優先搶佔＋near-done 閘門）</h3>
<p dir="auto">長 prefill 曾把短請求的 TTFT 擠爆（5 進 4 反飢餓場景）。三個機制修掉它，全程保持貪婪輸出位元一致（sha 比對通過：24K prefill 單跑與併發跑出相同 sha）：</p>
<ul>
<li><strong>SRTF prefill 選取</strong>——剩餘 ≤1 個 chunk 的 near-done prefill 排在長 prefill  續片前面（同級按 FIFO）。</li>
<li><strong>飢餓 decode 優先搶佔</strong>——有請求在排隊等 session 槽位時，長 prefill chunk 讓路，  先把常駐 decode 排空，好讓等待者一有常駐完成就被接納。</li>
<li><strong>near-done 閘門</strong>——只有當某個常駐 decoder 距 <code>token_limit</code> ≤64 token（槽位即將  空出）才觸發搶佔；若常駐全是長輸出 decoder，就不做無意義的 prefill 延遲。光是這個  閘門就把 fairness-A 從 76.5 拉回 7.32。</li>
</ul>
<h3>投機解碼（MTP / DFlash）</h3>
<ul>
<li><strong>Qwen Flash-Next MTP</strong>——併發寬度 2/3/4 的接受率 **  88.7/91.6/89.5%**。接受率不再隨 batch 衰減，本構建<br />
穩在 ~90%——各寬度總吞吐全面超過上游（97/111/133 對 70/105/112）。</li>
<li><strong>Qwen 27B DFlash2</strong>——支援 blocked-Q8 KV（verify 寫進 blocked sidecar，continuation快取與 serve 磁碟身分位元級攜帶）； decode（short/prose/code/json 22.9/19.5/56.2/52.3 tok/s）。</li>
<li><strong>Muse Glimmer DFlash</strong>——端到端投機草稿 <strong>~89%</strong>。</li>
<li><strong>Gemma 4 MTP</strong>——async-GPU 草稿重寫＋單 forward verify 之後，decode 達  <strong>74–86 tok/s</strong></li>
</ul>
<h3>多 sessions 生產配置範例 (以Strix Halo 128G搭配 Qwen Flash Next為例)</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>目標</th>
<th>設定</th>
</tr>
</thead>
<tbody>
<tr>
<td>16 路、高併發</td>
<td><code>--sessions 16 -c 65536 --kv-quant q8</code>（約 103 GB，餘 20 GB）</td>
</tr>
<tr>
<td>8 路、長對話</td>
<td><code>--sessions 8 -c 131072 --kv-quant q8</code>（約 101 GB，餘 21 GB）</td>
</tr>
<tr>
<td>單路、最大上下文</td>
<td><code>--sessions 1 -c 262144 --kv-quant q8</code></td>
</tr>
<tr>
<td>4 路、最大上下文</td>
<td><code>--sessions 4 -c 262144 --kv-quant q8</code>（約 101 GB，餘 21 GB——總位元組與 8×131072 相同）</td>
</tr>
<tr>
<td>單路、最快最精準 prefill</td>
<td><code>--sessions 1 -c 262144 --kv-quant f16</code>（全精度 KV；每位置最重，但單流裝得下）</td>
</tr>
<tr>
<td>還原上游排程</td>
<td>環境變數 <code>GUFO_MIXED_BATCH=0</code></td>
</tr>
</tbody>
</table>
<h3>排程器保證什麼</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>保證</th>
<th>機制</th>
</tr>
</thead>
<tbody>
<tr>
<td>待跑 decoder 絕不排在 prefill 之後</td>
<td>只有在沒有 decoder 待跑時（或正在湊第一批時）才進合併步驟，所以 prefill 只在空隙裡跑，永遠不會插隊到串流請求前面。</td>
</tr>
<tr>
<td>chunk 不能把 decoder 擠出輪替</td>
<td>每次合併或 prefill 步驟後，<code>MarkAllDecodersDue</code> 會把所有常駐 decoder 重新標記為待跑，下一步就全部服務。</td>
</tr>
<tr>
<td>任何 prompt 都無法獨佔裝置</td>
<td>chunk 是有上限的切片（<code>--prefill-chunk</code> 預設 512 token），25 萬 token 的 prompt 每輪只餵一片。</td>
</tr>
<tr>
<td>同等的 session 輪流</td>
<td>decode 佇列會輪替（<code>PopDecoder</code> 把服務過的請求移到隊尾），不是固定隊頭順序，所以沒有哪個 session 能一直贏得前排。</td>
</tr>
<tr>
<td>單一客戶端無法塞滿佇列</td>
<td><code>--max-pending-per-client</code> 限制單一客戶端的待處理請求（回 <code>client_quota</code>），出隊也跨客戶端輪流，一個客戶端爆量不會餓死別人。</td>
</tr>
<tr>
<td>某一層拒絕也不損失</td>
<td>每一層都可獨立降級；投機列被拒就退回原本路徑：正確，只是沒有加速。</td>
</tr>
</tbody>
</table>
<h3>多模型 router</h3>
<p dir="auto">一個 port、多顆模型。<code>serve llm --multi-model</code> 把伺服器變成模型 registry：啟動模型成為<strong>預設</strong>，每個請求依 <code>model</code> 欄位路由到對應模型。模型可在執行期增減（admin API）——不重啟、不斷線。</p>
<h1>§2 提供更多壓縮精度（成本差異）</h1>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>模式</th>
<th>狀態</th>
<th>說明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>f16</code></td>
<td>預設</td>
<td>基準數值。KV 快取不做量化。</td>
</tr>
<tr>
<td><code>q8</code></td>
<td>支援</td>
<td>Blocked 8-bit，每 32 個元素配一個 f16 尺度（34 位元組）。</td>
</tr>
<tr>
<td><code>q8</code> + <code>GUFO_KV_V4=1</code></td>
<td>手動開啟，K8V4</td>
<td>4-bit value 打包成 18 位元組，key 維持 8-bit。</td>
</tr>
<tr>
<td><code>q8</code> + <code>GUFO_KV_Q4=1</code></td>
<td>手動開啟，K4V8</td>
<td>4-bit key 打包成 18 位元組，value 維持 8-bit。</td>
</tr>
<tr>
<td><code>q8</code> + 兩者同時</td>
<td>手動開啟，K4V4</td>
<td>key 與 value 都是 4-bit。</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>建議使用 <code>q8</code>。</strong> blocked 模式在編解碼層級是位元精確的；<code>f16</code> 仍是預設與基準。4-bit 路徑是給「KV 記憶體成為瓶頸」的機器手動開啟的環境變數鉤子，不是<code>--kv-quant</code> 的格式選項，也不會改變任何預設值——未設定時引擎與不含這些路徑的版本位元相同（以 logit dump 雜湊比對驗證）。完整說明見 <a href="docs/KV-V4.md">docs/KV-V4.md</a>。</p>
<h4>佔用</h4>
<p dir="auto">每個 KV 位置的位元組數，以及 <code>-c 262144</code>、Qwen3.8 Flash-Next 12 個注意力層下單一 session 的總量：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>模式</th>
<th>每位置位元組</th>
<th>262144 單一 session</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>f16</code></td>
<td>2048</td>
<td>6.44 GB</td>
</tr>
<tr>
<td><code>q8</code></td>
<td>1088</td>
<td>3.42 GB</td>
</tr>
<tr>
<td>K8V4 / K4V8</td>
<td>832</td>
<td>2.62 GB</td>
</tr>
<tr>
<td>K4V4</td>
<td>576</td>
<td>1.81 GB</td>
</tr>
</tbody>
</table>
<h4>代價（量出來的）</h4>
<p dir="auto">以 <code>q8</code> 為基準的正確性：三個互不相關的 400-token 上下文、各 98 步matched-token decode、對三個上下文取平均：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>模式</th>
<th>decode KL</th>
<th>decode 最大 KL</th>
<th>貪婪 argmax 一致率</th>
</tr>
</thead>
<tbody>
<tr>
<td>K4V8</td>
<td>0.0214</td>
<td>0.258</td>
<td>90.5%</td>
</tr>
<tr>
<td>K8V4</td>
<td>0.0209</td>
<td>0.120</td>
<td>93.2%</td>
</tr>
<tr>
<td>K4V4</td>
<td>0.0335</td>
<td>0.411</td>
<td>89.8%</td>
</tr>
</tbody>
</table>
<h3>支援模型權重精度：W8A8／ROCmFP4／MXFP4／Q4_K</h3>
<h3>逐模型精度表</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>模型</th>
<th>權重精度</th>
<th>KV</th>
</tr>
</thead>
<tbody>
<tr>
<td>Qwen3.8 Flash-Next</td>
<td>ROCmFP4-FAST（4.25 bpw）或 UD-Q4_K_XL；decode Q4_1 拷貝（+17.4%）</td>
<td>blocked-Q8（<code>--kv-quant q8</code>）；MTP Q8_0 sidecar</td>
</tr>
<tr>
<td>Qwen3.8 27B</td>
<td>UD-Q4_K_XL（建議）或 ROCmFP4-FAST</td>
<td>blocked-Q8（含 DFlash2；<code>QWEN_KV_QUANT</code>、<code>--kv-quant</code> 覆寫）</td>
</tr>
<tr>
<td>Gemma 4 26B-A4B</td>
<td>Q4_0；Q4→Q8 dense 一次性預轉（每 chunk 省 210 次反量化啟動）</td>
<td>SWA 層共用 Q8（prefill −2.8%、decode −6.4%）</td>
</tr>
<tr>
<td>Qwen3.6-35B-A3B</td>
<td>Q6_K→Q8_0 載入；split-K router GEMV</td>
<td>僅引擎／bench 路徑</td>
</tr>
<tr>
<td>GPT-OSS 20B／120B</td>
<td>原生 MXFP4 routed GEMM</td>
<td>text 後端服務路徑</td>
</tr>
<tr>
<td>Muse Glimmer 30B</td>
<td>W8A8／Q8_0；MQB-first 注意力</td>
<td>serve 後端 <code>--kv-quant</code> 旗標</td>
</tr>
<tr>
<td>Llama-3.1-8B</td>
<td>dense GQA（見模型卡）</td>
<td>text 後端服務路徑</td>
</tr>
<tr>
<td>Qwen3-Embedding-0.6B</td>
<td>dense Qwen 注意力</td>
<td>prefill-only single-prefill Embed</td>
</tr>
<tr>
<td>bge-m3</td>
<td>Q4_K_M loader；逐形狀 autotune</td>
<td>prefill-only <code>/v1/embeddings</code></td>
</tr>
<tr>
<td>bge-reranker-v2-m3</td>
<td>共用 rerank 評分頭</td>
<td>padding ScoreBatch（超目標 <code>+15%</code>）</td>
</tr>
<tr>
<td>Qwen3-Reranker</td>
<td>yes/no head，Qwen 分派</td>
<td>純評分</td>
</tr>
</tbody>
</table>
<h3>對比 llama.cpp（v0.28.0，gfx1151）</h3>
<p dir="auto">同權重、release build、greedy；prefill＝冷 KV 單流 tok/s，decode＝開投機 tok/s。正數＝MBufo 較快。六格數字皆為 CHANGELOG 量測到的 v0.28.0 開發期數字原文重述。</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>負載</th>
<th>Prefill 差值</th>
<th>Decode 差值</th>
<th>條件／備註</th>
</tr>
</thead>
<tbody>
<tr>
<td>Flash-Next</td>
<td><strong>+52%</strong></td>
<td>持平或更好</td>
<td>冷 KV、greedy、開 MTP</td>
</tr>
<tr>
<td>Qwen3.6-35B-A3B</td>
<td><strong>+52.5%</strong></td>
<td>持平或更好</td>
<td>split-K router GEMV decode；greedy</td>
</tr>
<tr>
<td>bge-m3（長文件）</td>
<td><strong>+35~50%</strong></td>
<td>n/a（純 prefill）</td>
<td>長文件形狀、hipBLASLt autotune、快取執行器</td>
</tr>
<tr>
<td>Qwen3-Embedding-0.6B（長文件）</td>
<td><strong>+41~50%</strong></td>
<td>n/a（純 prefill）</td>
<td>長文件形狀、single-prefill Embed</td>
</tr>
<tr>
<td>Reranker（批次評分）</td>
<td>n/a</td>
<td><strong>超目標 +15%</strong></td>
<td>padding 多序列 ScoreBatch</td>
</tr>
<tr>
<td>GPT-OSS 120B</td>
<td><strong>+62%</strong></td>
<td><strong>-17%</strong></td>
<td>結構性差距，照實陳述：此路徑 decode 仍卡記憶體頻寬</td>
</tr>
</tbody>
</table>
<p dir="auto">此次版本推進未跑模型服務效能測試；上表為量測到的 v0.28.0 開發期數字重述，此處未重測。</p>
<h1>§3 GGUF 相容（覆蓋承諾）</h1>
<h3>支援的模型（v0.28.0）</h3>
<p dir="auto">將經典模型架構都做出支援，除了LLM並且能載入Embedding與Reranker<br />
Qwen3.8 Flash-Next、Qwen3.8 27B 、 Qwen3.6-35B-A3B 、Gemma 4、 GPT-OSS 20B／120B 、Muse Glimmer 30B、Llama-3.1、Qwen3-Embedding、bge-m3、bge-reranker-v2-m3、Qwen3-Reranker</p>
<h1>§4 效能測試 單對話基準（MBufo，以gfx1151 Strix Halo測試）</h1>
<p dir="auto">冷 KV（每請求唯一 prompt，<code>cached_tokens≈0</code>）、think off、<strong>F16 KV</strong>、<code>-j 1</code>、<br />
ctx 262144。四組設定：27B（UD-Q4_K_XL 對 ROCmFP4-FAST）＋ Flash-Next（ROCmFP4-FAST<br />
對 UD-Q4_K_XL）。投機：27B＝DFlash2、Flash-Next＝MTP。（註：舊中文版此節為 v0.24.1<br />
數字，已同步為與英文版一致的 v0.25.5。）</p>
<p dir="auto">這些是單流數字，用來隔離模型與建置版本的選擇；負載下改變的是同時能跑幾條，那是<br />
<a href="#1-%E9%AB%98%E4%BD%B5%E7%99%BC%E6%9E%B6%E6%A7%8B%E5%B7%AE%E7%95%B0">§1 高併發</a>的故事。</p>
<h3>Prefill（tok/s，越高越好）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="text-align:right">tokens</th>
<th style="text-align:right">27B Q4_K_XL</th>
<th style="text-align:right">27B ROCm FP4-FAST</th>
<th style="text-align:right">FN ROCmFP4</th>
<th style="text-align:right">FN Q4_K_XL</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">2K</td>
<td style="text-align:right">605</td>
<td style="text-align:right">455</td>
<td style="text-align:right"><strong>1739</strong></td>
<td style="text-align:right">1301</td>
</tr>
<tr>
<td style="text-align:right">8K</td>
<td style="text-align:right">615</td>
<td style="text-align:right">564</td>
<td style="text-align:right"><strong>1701</strong></td>
<td style="text-align:right">1549</td>
</tr>
<tr>
<td style="text-align:right">32K</td>
<td style="text-align:right">567</td>
<td style="text-align:right">551</td>
<td style="text-align:right">1598</td>
<td style="text-align:right"><strong>1618</strong></td>
</tr>
<tr>
<td style="text-align:right">64K</td>
<td style="text-align:right">508</td>
<td style="text-align:right">496</td>
<td style="text-align:right"><strong>1695</strong></td>
<td style="text-align:right">1678</td>
</tr>
<tr>
<td style="text-align:right">128K</td>
<td style="text-align:right">409</td>
<td style="text-align:right">407</td>
<td style="text-align:right"><strong>1504</strong></td>
<td style="text-align:right">1507</td>
</tr>
<tr>
<td style="text-align:right">250K</td>
<td style="text-align:right">—</td>
<td style="text-align:right">—</td>
<td style="text-align:right"><strong>1438</strong></td>
<td style="text-align:right">1415</td>
</tr>
</tbody>
</table>
<h3>Decode（tok/s，投機開）</h3>
<p dir="auto">標準：5 個冷 KV 情境（標明 temp）＋ 8 任務 ReAct 代理套件。</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>情境</th>
<th style="text-align:right">27B Q4_K_XL</th>
<th style="text-align:right">27B FP4-FAST</th>
<th style="text-align:right">FN ROCmFP4</th>
<th style="text-align:right">FN Q4_K_XL</th>
</tr>
</thead>
<tbody>
<tr>
<td>散文 (temp 0.4)</td>
<td style="text-align:right">23.5</td>
<td style="text-align:right">19.7</td>
<td style="text-align:right">43.3</td>
<td style="text-align:right"><strong>43.6</strong></td>
</tr>
<tr>
<td>費波那契 (temp 0.4)</td>
<td style="text-align:right">67.9</td>
<td style="text-align:right">56.2</td>
<td style="text-align:right"><strong>86.3</strong></td>
<td style="text-align:right">84.7</td>
</tr>
<tr>
<td>JSON 約束 (temp 0)</td>
<td style="text-align:right"><strong>55.1</strong></td>
<td style="text-align:right">46.5</td>
<td style="text-align:right">51.5</td>
<td style="text-align:right">51.7</td>
</tr>
<tr>
<td>貪心程式碼 /128 (temp 0)</td>
<td style="text-align:right">61.9</td>
<td style="text-align:right">55.3</td>
<td style="text-align:right">70.5</td>
<td style="text-align:right"><strong>73.2</strong></td>
</tr>
<tr>
<td>重複文本 /256 (temp 0)</td>
<td style="text-align:right">70.6</td>
<td style="text-align:right">60.8</td>
<td style="text-align:right">74.8</td>
<td style="text-align:right"><strong>75.3</strong></td>
</tr>
</tbody>
</table>
<h3>代理任務（agent_bench_v2，t1–t8，沙箱工具）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th style="text-align:right">27B Q4_K_XL</th>
<th style="text-align:right">27B FP4-FAST</th>
<th style="text-align:right">FN ROCmFP4</th>
<th style="text-align:right">FN Q4_K_XL</th>
</tr>
</thead>
<tbody>
<tr>
<td>通過</td>
<td style="text-align:right">8/8</td>
<td style="text-align:right">7/8</td>
<td style="text-align:right">7/8</td>
<td style="text-align:right">7/8</td>
</tr>
<tr>
<td>核爆（須為 0）</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
</tr>
<tr>
<td>生成 tps 區間</td>
<td style="text-align:right">9.1–31.1</td>
<td style="text-align:right">9.3–21.5</td>
<td style="text-align:right">16.7–56.6</td>
<td style="text-align:right">16.8–55.1</td>
</tr>
</tbody>
</table>
<h1>§5 效能測試 高併發測試</h1>
<h3>三引擎投機併發比較表 — Qwen3.8 Flash-Next</h3>
<blockquote>
<p dir="auto">引擎：A Halogen 0.18.1（FN v2, <code>.hgn</code>）／B gufo-upstream 0.21.0＋FN Q4_K_XL＋MTP／C MBufo <strong>v0.25.3</strong>＋FN ROCmFP4＋MTP。FN 投機器＝<strong>MTP</strong>。</p>
</blockquote>
<p dir="auto"><strong>① Decode 總吞吐 total_tps（N=1/2/3/4 併發）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>引擎</th>
<th>N1</th>
<th>N2</th>
<th>N3</th>
<th>N4</th>
</tr>
</thead>
<tbody>
<tr>
<td>A Halogen</td>
<td><strong>84.9</strong></td>
<td>81.6</td>
<td>75.3</td>
<td>87.8</td>
</tr>
<tr>
<td>B gufo+Q4</td>
<td>57.3</td>
<td>64.0</td>
<td>108.4</td>
<td>127.1</td>
</tr>
<tr>
<td>C MBufo+ROCmFP4</td>
<td>66.0</td>
<td><strong>82.8</strong></td>
<td><strong>110.2</strong></td>
<td><strong>128.5</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>② 平均每 session decode_tps</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>引擎</th>
<th>N1</th>
<th>N2</th>
<th>N3</th>
<th>N4</th>
</tr>
</thead>
<tbody>
<tr>
<td>A Halogen</td>
<td><strong>84.9</strong></td>
<td>41.3</td>
<td>25.4</td>
<td>22.3</td>
</tr>
<tr>
<td>B gufo+Q4</td>
<td>57.3</td>
<td>32.2</td>
<td>36.9</td>
<td>32.9</td>
</tr>
<tr>
<td>C MBufo+FP4</td>
<td>66.0</td>
<td>41.6</td>
<td><strong>38.2</strong></td>
<td><strong>32.8</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>③ MTP 接受率（batch_width 2/3/4，server 端）</strong>：Halogen<strong>只在單流時投機</strong>，多併發完全沒有增益<br />
<strong>④ Prefill 總吞吐（64K 冷，N=1/2/3/4）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>引擎</th>
<th>N1</th>
<th>N2</th>
<th>N3</th>
<th>N4</th>
</tr>
</thead>
<tbody>
<tr>
<td>A Halogen</td>
<td>840</td>
<td>1687</td>
<td>1662</td>
<td><strong>1714</strong></td>
</tr>
<tr>
<td>B gufo+Q4</td>
<td>1588</td>
<td>1545</td>
<td>1554</td>
<td>1559</td>
</tr>
<tr>
<td>C MBufo+FP4</td>
<td><strong>1612</strong></td>
<td><strong>1582</strong></td>
<td><strong>1570</strong></td>
<td>1572</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>⑤ Fairness 退化比（場景 A 混長文／場景 B 混 4K，越低越好）</strong>：A 322／1140｜B 15.3／399｜C <strong>18.9／187</strong></p>
<p dir="auto"><strong>⑥ ITL mean／p95／max（ms，注入 4K prefill）</strong>：A 83／341／738｜B 49／93／501｜C 43／68／459</p>
<p dir="auto"><strong>判讀</strong></p>
<ul>
<li><strong>單流 decode</strong>：A（halogen）最強 84.9（NPU＋獨占 MTP），但 halogen <strong>只在獨占時投機</strong>，一旦併發即關投機頭 → per-session 崩到 22–25、總吞吐停滯（75–88）。</li>
<li><strong>高併發 decode</strong>：<strong>C（MBufo）最佳</strong>——per-session 平穩 33–42、總吞吐線性到 128.5、N3–N4 反超 B；B 次之；A 最差（投機 off）。</li>
<li><strong>Fairness</strong>：<strong>MBufo 場景 B 187 最佳</strong></li>
<li><strong>結論</strong>：單發求極限速度選 Halogen；<strong>併發／代理／多工實戰選 MBufo</strong>。</li>
</ul>
<h1>§6 Qwen3.8 27B 高併發測試</h1>
<p dir="auto"><strong>① Decode 總吞吐 total_tps（N=1/2/3/4 併發）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>引擎</th>
<th>N1</th>
<th>N2</th>
<th>N3</th>
<th>N4</th>
</tr>
</thead>
<tbody>
<tr>
<td>A Halogen+dflash2</td>
<td>48.0</td>
<td>48.2</td>
<td>47.1</td>
<td>47.0</td>
</tr>
<tr>
<td>B gufo+DFlash2</td>
<td>60.4</td>
<td>73.0</td>
<td>73.4</td>
<td>84.0</td>
</tr>
<tr>
<td>C MBufo+DFlash2</td>
<td><strong>61.4</strong></td>
<td><strong>74.5</strong></td>
<td><strong>73.6</strong></td>
<td><strong>85.7</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>② 平均每 session decode_tps</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>引擎</th>
<th>N1</th>
<th>N2</th>
<th>N3</th>
<th>N4</th>
</tr>
</thead>
<tbody>
<tr>
<td>A Halogen+dflash2</td>
<td>48.0</td>
<td>24.1</td>
<td>15.7</td>
<td>11.75</td>
</tr>
<tr>
<td>B gufo+DFlash2</td>
<td>60.4</td>
<td>37.7</td>
<td>25.5</td>
<td>21.6</td>
</tr>
<tr>
<td>C MBufo+DFlash2</td>
<td><strong>61.4</strong></td>
<td><strong>38.4</strong></td>
<td><strong>25.6</strong></td>
<td><strong>22.0</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>③ Prefill 總吞吐（64K 冷，N=1/2/3/4）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>引擎</th>
<th>N1</th>
<th>N2</th>
<th>N3</th>
<th>N4</th>
</tr>
</thead>
<tbody>
<tr>
<td>A Halogen+dflash2</td>
<td>423</td>
<td>425</td>
<td>419</td>
<td>416</td>
</tr>
<tr>
<td>B gufo+DFlash2</td>
<td>462</td>
<td>449</td>
<td>447</td>
<td>452</td>
</tr>
<tr>
<td>C MBufo+DFlash2</td>
<td><strong>470</strong></td>
<td><strong>460</strong></td>
<td><strong>459</strong></td>
<td><strong>461</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>④ Fairness 退化比（場景 A 混長文／場景 B 混 4K，越低越好）</strong>：A 187／34.3｜B 200／1832｜C <strong>167／212</strong></p>
<p dir="auto"><strong>⑤ ITL mean／max（ms，注入 4K prefill）</strong>：A 49／144｜B 92／1437｜C 91／1408</p>
<p dir="auto"><strong>判讀</strong></p>
<ul>
<li><strong>結論</strong>：27B 投機態下 <strong>C（MBufo v0.25.6）綜合最佳</strong>——單流最快、高併發擴展最好、fairness 搶佔領先；A（halogen）僅單流 ITL 平順但高併發無擴展；B（上游）decode 接近 C 但 fairness 場景 B 差 8.6×。</li>
</ul>
<h1>結論</h1>
<p dir="auto">llama.cpp並沒有針對RDNA運算做到最佳的優化(預設完全沒用到wmma矩陣加速)<br />
sglang對gguf的支援太爛、用AWQ、GPTQ又造成較大的內存開銷，而且對A卡的性能釋放不利<br />
strata沒有高併發魔改的先天條件<br />
為改善使用體驗，以此自製做為範例，若有興趣的可以試著一起開發魔改下去</p>
]]></description><link>https://lcz.me/topic/2938</link><generator>RSS for Node</generator><lastBuildDate>Tue, 10 Nov 2026 00:20:12 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/2938.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Nov 2026 10:16:04 GMT</pubDate><ttl>60</ttl></channel></rss>