<?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[RDNA3 福利區 - Inkling-2-Mini + 7900XTX => Prefill 3000 tok/s & AR 101 tok/s @4K & DSpark 265 tok/s]]></title><description><![CDATA[<blockquote>
<p dir="auto">先說明：這是自己一台機器上的實測，每項只跑一次或少數幾次，沒有大規模品質評測。引擎是我們自己改的 fork，數字是迭代過程中最後一輪的結果，不是同一時間窗口的嚴格對照。greedy 輸出每一步都有做 bit-exact token 流比對。所有數字請當量級參考。</p>
</blockquote>
<h2>TL;DR</h2>
<ul>
<li>把 Thinking Machines 的 <strong>Inkling-2-Mini</strong>（26B 總 / 3.4B 活躍、48 次 loop visit、128 experts top-8 的 MoE）在 <strong>RX 7900 XTX 24GB（gfx1100 / RDNA3，Windows 原生 HIP）</strong> 跑起來。原引擎是 Strata 為 NVIDIA 3090 寫的 ik2（PR#6506），我們移植 + 優化到 RDNA3，全開源：<code>https://github.com/liedwardtw/Strata</code>（commit <code>afed622e</code>）。</li>
<li><strong>Prefill 峰值 3021 tok/s（16K）</strong>、<strong>AR 直接解碼 101 tok/s @ 4K</strong>，結構化 prompt 上 <strong>DSpark 原生投機解碼 243–265 tok/s（accept 7.7/8）</strong>。</li>
<li><strong>640K（655360）上下文 + 8GB conversation cache 全塞進 24GB VRAM/RAM</strong>，128 專家常駐 0 miss；640K 滿載 KV 時 AR 降到 23 tok/s（8 次 full-attention visit 是 O(ctx)，誠實數據）。</li>
<li>全部 greedy bit-exact；所有提速都 env-gated + A/B token 流比對才留。</li>
<li>誠實結論：960GB/s 用不滿（HBM 只 13–38%）；雙路併發卡在 WDDM graph replay 只到 147.9；Lucebox Fast 模型「思考減半」在我們這邊未重現。</li>
<li>完整技術文件（7 篇）在 repo 的 <code>docs/XTX-7900XTX-*.md</code>，README 有連結。</li>
</ul>
<h2>1. 硬體與軟體</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>項目</th>
<th>內容</th>
</tr>
</thead>
<tbody>
<tr>
<td>GPU</td>
<td>AMD RX 7900 XTX 24GB（gfx1100 / RDNA3），HBM 峰值 ~960 GB/s</td>
</tr>
<tr>
<td>驅動</td>
<td>Adrenalin 32.0.32029.2010</td>
</tr>
<tr>
<td>系統 / RAM</td>
<td>Windows 11 原生 HIP（無 WSL / 雙系統），32GB DDR</td>
</tr>
<tr>
<td>SDK</td>
<td>ROCm Windows HIP SDK（clang ~24），VS 2022 Build Tools（manifest 要 mt.exe）</td>
</tr>
<tr>
<td>模型</td>
<td><code>Inkling-2-Mini-UD-Q4_K_XL.gguf</code> 16.42 GiB（NVFP4 專家 L0–19 + Q8_0 L20–23）</td>
</tr>
<tr>
<td>引擎</td>
<td>Strata ik2 fork（以 Niko1221/Strata PR#6506 為底），commit <code>afed622e</code></td>
</tr>
<tr>
<td>草稿器</td>
<td>模型原生 <code>mtp.safetensors</code> 635MB（DSpark 用）</td>
</tr>
</tbody>
</table>
<h2>2. 配置與一鍵操作</h2>
<p dir="auto">native serve（完整 OpenAI/Anthropic API + web chat + monitor + 工具呼叫），背景執行可關視窗：</p>
<pre><code class="language-bat">start.bat    :: 啟動原生 Strata serve port 8099，印一行 OK 後轉背景
stop.bat     :: 停止 serve + 引擎，保留 gpu_guard
</code></pre>
<p dir="auto"><code>ik2-native-640k.json</code> 重點：<code>--ctx 655360 --max-context 655360 --prefill 4096 --gpus 1 --cache-gb 60 --conversation-cache-mib 8192</code>、<code>reasoning_effort: "none"</code>（AR 直出，關掉 thinking pass）、<code>reasoning_budget_tokens: 256</code>（只有 client 明確要求 thinking 才生效）。</p>
<p dir="auto">關鍵 env：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>變數</th>
<th>值</th>
<th>作用</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>IK2_KV</code></td>
<td><code>int4</code></td>
<td>KV 用 int4（RDNA3 無 FP8 WMMA，int4 比 fp8 省一半頻寬）</td>
</tr>
<tr>
<td><code>IK2_INT4_LAYERS</code></td>
<td><code>24</code></td>
<td>24 層專家全部轉 int4</td>
</tr>
<tr>
<td><code>IK2_INT4_DIR</code> / <code>IK2_INT4_DENSE_DIR</code></td>
<td>轉換出的 sidecar 目錄</td>
<td>路徑錯會靜默退回 Q8 → 3.88 tok/s 災難</td>
</tr>
<tr>
<td><code>IK2_ATTN_GQA</code> / <code>IK2_ATTN_DPP</code></td>
<td><code>1</code></td>
<td>GQA 共用 K/V 讀取 + DPP warp reduce</td>
</tr>
<tr>
<td><code>IK2_FLASH_WMMA</code> / <code>IK2_FLASH_NW</code> / <code>IK2_FLASH_BN</code></td>
<td><code>1 / 8 / 32</code></td>
<td>RDNA3 版 WMMA flash attention</td>
</tr>
<tr>
<td><code>IK2_REPORT_BATCH</code></td>
<td>不設 (=0)</td>
<td>單流報 <code>batch_slots=0</code>，不然兩個請求同時送進單流引擎會死結</td>
</tr>
</tbody>
</table>
<p dir="auto">端點：web <code>http://127.0.0.1:8099/</code>、monitor <code>/api-monitor</code> 或 <code>/#monitor</code>、API <code>/v1/chat/completions</code>（model <code>inkling-2-mini</code>）。完整再現見 <a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-SETUP.md" rel="nofollow ugc">SETUP</a>。</p>
<h2>3. VRAM：640K + 8GB cache 怎麼塞進 24GB</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>項目</th>
<th style="text-align:right">大小</th>
<th>做法</th>
</tr>
</thead>
<tbody>
<tr>
<td>INT4 專家 24 層常駐</td>
<td style="text-align:right">~12.2 GiB</td>
<td>NVFP4/Q8_0 離線轉 rotated int4（Hadamard H256 + per-128 scale），0 miss</td>
</tr>
<tr>
<td>稠密投影</td>
<td style="text-align:right">~1.1 GiB</td>
<td>Q8 planar host-map，decode 走 int4 sidecar 不讀 host</td>
</tr>
<tr>
<td>KV 640K int4</td>
<td style="text-align:right">~5.4 GiB</td>
<td>每 token/visit 1056B（K+V code + per-head fp16 scale），比 fp8 省一半</td>
</tr>
<tr>
<td>ExpertCache + work buffer</td>
<td style="text-align:right">~2 GiB</td>
<td>chunk 4096，&gt;10240 會 thrash 把專家擠出 VRAM</td>
</tr>
<tr>
<td>conversation cache</td>
<td style="text-align:right">8 GiB host RAM</td>
<td>64 snapshots（41.2MiB each），只把滑動窗口/卷積歷史放 host</td>
</tr>
</tbody>
</table>
<p dir="auto">Monitor 實測：256 experts cached、Prompt reused 49%、Parked conversations 2/64、247/259 tokens reused。256K 下 KV 格式對比：fp8 42.2 / int8 46.5 / <strong>int4 47.6 tok/s</strong>，int4 又快又省一半 VRAM。細節見 <a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-VRAM.md" rel="nofollow ugc">VRAM</a>。</p>
<h2>4. 測試方法</h2>
<ul>
<li>速度字段從引擎 DONE 的純 decode wall 取；另用 <code>completion_tokens ÷ (總時間 − prefill)</code> 交叉核對（長輸出時引擎字段可能不可信）。</li>
<li>全深度：9 個固定 prompt 長度（1K→640K），每檔 gen48，<code>ctx=n+4096</code>，chunk 隨長度調整，確認 <code>resident=1 / 0 miss / graph captured</code> 才計。</li>
<li>品質：greedy token 流逐 token 比對（不看摘要），19 題 + 4 題多步推理算 first-divergence flip rate；工具呼叫另測。協定見 <a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-BENCHMARKS.md" rel="nofollow ugc">BENCHMARKS</a>。</li>
</ul>
<h2>5. 結果</h2>
<h3>5.1 全深度（長 prompt 填滿 KV，resident 0 miss）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>輸入</th>
<th style="text-align:right">1K</th>
<th style="text-align:right">4K</th>
<th style="text-align:right">16K</th>
<th style="text-align:right">32K</th>
<th style="text-align:right">64K</th>
<th style="text-align:right">128K</th>
<th style="text-align:right">256K</th>
<th style="text-align:right">512K</th>
<th style="text-align:right">640K</th>
</tr>
</thead>
<tbody>
<tr>
<td>Prefill tok/s</td>
<td style="text-align:right">818</td>
<td style="text-align:right">2121</td>
<td style="text-align:right"><strong>3021</strong></td>
<td style="text-align:right">2850</td>
<td style="text-align:right">2428</td>
<td style="text-align:right">1623</td>
<td style="text-align:right">819</td>
<td style="text-align:right">550</td>
<td style="text-align:right">472</td>
</tr>
<tr>
<td>Decode tok/s</td>
<td style="text-align:right"><strong>101.4</strong></td>
<td style="text-align:right"><strong>101.0</strong></td>
<td style="text-align:right">93.6</td>
<td style="text-align:right">90.6</td>
<td style="text-align:right">77.9</td>
<td style="text-align:right">61.6</td>
<td style="text-align:right">43.3</td>
<td style="text-align:right">27.6</td>
<td style="text-align:right">23.1</td>
</tr>
</tbody>
</table>
<h3>5.2 DSpark（結構化 prompt，greedy bit-exact）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt</th>
<th style="text-align:right">gen</th>
<th style="text-align:right">tok/s</th>
<th style="text-align:right">accept</th>
</tr>
</thead>
<tbody>
<tr>
<td>table-long</td>
<td style="text-align:right">256</td>
<td style="text-align:right">243–247</td>
<td style="text-align:right">7.7/8</td>
</tr>
<tr>
<td>table-long（單次最佳）</td>
<td style="text-align:right">64</td>
<td style="text-align:right"><strong>265</strong></td>
<td style="text-align:right">7.7/8</td>
</tr>
<tr>
<td>code-long</td>
<td style="text-align:right">256</td>
<td style="text-align:right">217</td>
<td style="text-align:right">7.5/8</td>
</tr>
</tbody>
</table>
<p dir="auto">accept 高度依賴 prompt 結構（table/code 7.5–7.7，散文 5.7，capital 2.25）；256K 下 accept 掉到 1.96 → 34 tok/s，反而輸給 AR（見 <a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-DSPARK.md" rel="nofollow ugc">DSPARK</a>）。</p>
<h3>5.3 品質</h3>
<ul>
<li>315 項 kernel parity（double reference）全過；greedy token 流與 llama.cpp V3 在 31–96 token bit-exact，跨 scalar / WMMA-flash / INT4 組態。</li>
<li>19 題品質 flip gate：唯一保留的非 baseline 槓桿 PRE_LOAD_V 0 flip（bit-exact, +1.3%）；EXP2 +4.9% 但 84% prompt flip，已捨棄（見 <a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-QUALITY.md" rel="nofollow ugc">QUALITY</a>）。</li>
</ul>
<h2>6. 我們做了什麼優化（核心）</h2>
<ol>
<li><strong>選引擎</strong>：sglang-radeon（gfx942-only wheel）、vllm-radiance（RDNA4 only）、hipfire（無 inkling 架構）、Avalon（llama.cpp fork、無 inkling）全淘汰；選 Strata ik2（NVIDIA 3090 上 120–124 tok/s bit-identical）移植 HIP。315 項 kernel parity 全過。</li>
<li><strong>gfx1100 WMMA flash attention</strong>：NVIDIA 版 LDS 88064B &gt; gfx1100 64KB，根本跑不起來；重寫 4-wave BN=32、20KB LDS、RDNA3 <code>wmma_f32_16x16x16_f16_w32</code>；16K prefill 1450→2661（+83%），最大 prefill 槓桿。</li>
<li><strong>INT4 權重</strong>：NVFP4/Q8_0 → rotated int4 sidecar，配 <code>k_gemm8w</code>（WMMA iu4）與 <code>k_mv_dense_rot</code>（matvec）；gfx1100 WMMA 支援 f16/bf16/int8/int4 但<strong>沒有 fp8</strong>。</li>
<li><strong>int4 KV + GQA + DPP</strong>：int4 每 token 1056B；GQA-shared decode（R=3 Q head 共用 K/V 讀）256K +28%；DPP warp reduce +6%；gate/rms fusion。</li>
<li><strong>DSpark</strong>：原生 mtp.safetensors、device-only verify（消除每步 48 次 D2H）、draft WMMA、slot-major MoE、argmax 改 per-Work scratch 修並發 race → 單流約 3×。</li>
<li><strong>bit-exact 紀律</strong>：所有提速 env-gated（預設關 = 原始路徑 byte-identical），A/B token 流比對才留。</li>
<li><strong>Serve / Monitor / App</strong>：補 INFO 欄位讓 monitor 顯示 256 experts cached / conversation cache；修 <code>reasoning_effort=none</code> 直出與 <code>batch_slots</code> 死結；Strata Desktop App 用 shape-engine component（<code>component:strata-inkling</code>）直接把引擎換成我們的，不是外部 provider。</li>
</ol>
<p dir="auto">完整逐項技術 + A/B 數字：<a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-OPTIMIZATIONS.md" rel="nofollow ugc">OPTIMIZATIONS</a>。</p>
<h2>7. 侷限（誠實）</h2>
<ul>
<li><strong>960GB/s 用不滿</strong>：全深度有效 BW 只 1.8–43 GB/s（0.2–4.5% peak）。6 個研究面向共識：瓶頸是 serial online-softmax 的 SFU expf、int4 dequant ALU、48 次 visit 的 RAW 串行依賴，不是 memory bandwidth。所有 bit-exact 槓桿合起來 0–5%。</li>
<li><strong>雙路併發</strong>：做到 147.9 tok/s（1.94× overlap、bit-exact），但卡在 WDDM/HIP graph per-node replay（~1.9µs/node × 1016 node ≈ 1.95ms/step）；目標 185–195 不可達（見 <a href="https://github.com/liedwardtw/Strata/blob/main/docs/XTX-7900XTX-LIMITS.md" rel="nofollow ugc">LIMITS</a>）。</li>
<li><strong>Fast 模型</strong>：Lucebox Inkling-2-Mini-Fast-IQ4_NL 宣稱「思考減半 2.01×」，8 題多步推理在 7900XTX/ik2 未重現（思考量相同或更長，品質相同），故維持原模型。</li>
<li>只有一台卡、單次或少數幾次；Prefill 峰值在 16K，更長反而下降（KV 讀取 + 分塊）。</li>
</ul>
<h2>8. 再現與原始碼</h2>
<ul>
<li>GitHub：<code>https://github.com/liedwardtw/Strata</code>（commit <code>afed622e</code>）</li>
<li>7 篇技術文件：<code>docs/XTX-7900XTX-{BENCHMARKS,OPTIMIZATIONS,SETUP,DSPARK,VRAM,QUALITY,LIMITS}.md</code>（README 有連結）</li>
<li>一鍵：<code>start.bat</code> / <code>stop.bat</code>；請求範例：</li>
</ul>
<pre><code class="language-sh">curl http://127.0.0.1:8099/v1/chat/completions -H "Content-Type: application/json" \
  -d '{"model":"inkling-2-mini","messages":[{"role":"user","content":"你好"}],"max_tokens":200}'
</code></pre>
<h2>9. 想請教</h2>
<ol>
<li>有人在 RDNA3 上試過更激進的 split-KV / persistent kernel 嗎？我們卡在 graph per-node replay，想知道有沒有不靠 WDDM 的加速法。</li>
<li>640K 滿載 23 tok/s 的下降，跟 NVIDIA 同架構差距多少？有沒有可參考對照。</li>
<li>Fast 模型在 Linux + luce_server 的 2.01× 有沒有人獨立重現？我們在 Windows/ik2 沒重現。</li>
</ol>
]]></description><link>https://lcz.me/topic/3378</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 03:12:02 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/3378.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Nov 2026 11:50:25 GMT</pubDate><ttl>60</ttl></channel></rss>