<?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[Qwen3.8 FlashNext運算組成 A卡與N卡在Strata對應的運算單元]]></title><description><![CDATA[<h1>Flash-Next 在 GPU 上到底在算什麼</h1>
<h2>基本概念</h2>
<p dir="auto">Qwen3.8-Flash-Next 是一個 125B 的 <strong>MoE（混合專家）模型</strong>。可以把它想像成一位超顧問：每處理一個字，都要走一趟「工廠」，廠內有五個工位。GPU 的硬體則分成兩種設備：<strong>矩陣專算機</strong>（tensor core / matrix core，只認 FP16/BF16/FP8 這幾種格式的整塊矩陣乘）和<strong>萬用計算台</strong>（CUDA core / wave ALU，什麼都能算，包括解壓縮）。</p>
<h2>五個工位</h2>
<p dir="auto"><strong>① 專家 FFN——主事件，佔 60-70%</strong></p>
<p dir="auto">MoE 的本體：模型沒有一個巨大的前饋網路，而是有<strong>幾百間專家工作室</strong>（code 專精、中文專精、數學專精……）。每個字進來，只點燃其中少數幾間（比如 128 間開 8 間）。每間工作室做的都是標準動作：輸入 × 權重矩陣 A → 激活 → × 權重矩陣 B，兩次大矩陣乘。</p>
<p dir="auto">關鍵：這 125B 參數<strong>絕大多數是這些專家的權重</strong>，而且為了塞進顯存都<strong>壓縮（量化）成 4/8-bit</strong> 存著。壓縮格式矩陣專算機不認，必須先在萬用計算台上<strong>解壓回 16-bit 再算</strong>——所以整個主事件全走萬用計算台，NVIDIA 的 CUDA core、AMD 的 wave ALU 都一样，tensor core 完全幫不上。</p>
<p dir="auto"><strong>② 密集 16-bit 層——固定小站，佔 10-15%</strong></p>
<p dir="auto">每個字都必經的「小工位」：<strong>router</strong>（總機，決定點燃哪些專家）、<strong>hyper-connection</strong>（層間資訊高速公路的切換）、<strong>PLE</strong>（位置查表）。它們體積小，所以<strong>不壓縮、保留完整 16-bit 精度</strong>——這正好是矩陣專算機吃的格式，所以這一站現代 GPU 都丟給 tensor core（NVIDIA）或調優 FP16 kernel（AMD）算。</p>
<p dir="auto"><strong>③ QSA 評分——先看目錄，佔 15-30% 的一部分</strong></p>
<p dir="auto">模型讀到新的字，要回頭參考前文——但前文可能長達十幾萬字，逐字看太慢。<strong>QSA（稀疏注意力）=「先看目錄，再讀相關章節」</strong>：把前文切成一段段，快速給每段打個相關分數，只挑分數高的段落進入下一步精讀。這個「打分管」本身是小型矩陣乘：NVIDIA 用 TF32 tensor core（Ampere 起），AMD 在 RDNA4 用 matrix core（WMMA，快 7 倍），其他卡都用萬用計算台硬算。</p>
<p dir="auto"><strong>④ Attention QK/PV + softmax——精讀相關段落，佔 15-30% 其餘</strong></p>
<p dir="auto">對挑出來的段落做三件事：<strong>QK</strong>＝拿當前字的「問題」和每段落的「標籤」比對，算出每段多相關；<strong>softmax</strong>＝把相關分數轉成加權比例（加總=1，像機率分布）——這步是純逐元素運算（max/exp/除），任何矩陣硬體都幫不上；<strong>PV</strong>＝按比例把各段落的「內容」混合成當前字的記憶摘要。整段用 flash-attention 做法：段落切塊處理、中間結果放暫存器，顯存裡永遠不需要那張巨大的 T×T 比對表。</p>
<p dir="auto"><strong>⑤ KV 讀寫 + 專家串流——物流，不佔算力但佔時間</strong></p>
<p dir="auto"><strong>KV cache</strong>＝模型對已讀文字寫的「筆記」（每個字的 K/V 向量），存在顯存裡；<strong>專家權重</strong>太大裝不下顯存，要從記憶體/SSD <strong>持續搬進搬出</strong>（串流）。這些是「搬東西」不是「算東西」，不花 FLOPs，但吃真實時間——<strong>decode 速度的瓶頸就是它</strong>（每生成一字都要翻一遍筆記、取一遍專家書）。</p>
<h2>兩種工作模式</h2>
<ul>
<li><strong>Prefill（讀題）</strong>：整段 prompt 一批處理，大矩陣乘火力全開→<strong>比的是算力</strong>（所以 tensor core 世代差在這裡顯現）</li>
<li><strong>Decode（寫答案）</strong>：一次一字，每字都要把筆記和權重讀一遍→<strong>比的是頻寬</strong>（所以同級卡 decode 差距小，VRAM 容量和記憶體頻寬才決定生死）</li>
</ul>
<h2>一句話總結</h2>
<blockquote>
<p dir="auto">這個模型的計算大頭（專家 FFN）是<strong>壓縮格式</strong>的，兩家 GPU 都只能用萬用計算台硬算；tensor core / matrix core 只服務小頭（密集層 + 稀疏注意力評分）。所以同價位的卡，<strong>prefill 差距看算力規格，decode 差距看頻寬和 VRAM 容量</strong>——規格表上的 tensor core TFLOPS 對這種 MoE 模型，沒有它看起來那麼決定性。</p>
</blockquote>
<p dir="auto">Strata最近爆火，最讓人興奮的是老卡也能跑頂級大模型<br />
但老卡優化的進度怎樣呢?<br />
以下是拆解原代碼比對各運算層對應的運算單元，以及github開源社群提出的PR待合併我標註#</p>
<h2>NVIDIA</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>組成</th>
<th>佔每 token 計算量</th>
<th>Volta（V100）</th>
<th>Turing（RTX 20）</th>
<th>Ampere（RTX 30）</th>
<th>Ada（RTX 40）</th>
<th>Blackwell（RTX 50）</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Expert FFN</strong>（量化 GEMM，O(T)）</td>
<td>~60-70%</td>
<td>純 CUDA core（dequant→FMAC）</td>
<td>同左</td>
<td>同左</td>
<td>同左</td>
<td>同左</td>
</tr>
<tr>
<td><strong>密集 16-bit 層</strong>（hc/router/PLE，O(T)）</td>
<td>~10-15%</td>
<td>FP16 Tensor Core（無 BF16，#655/#741 轉 FP16 救）</td>
<td>同左</td>
<td><strong>原生 BF16 Tensor Core</strong></td>
<td>原生 BF16/FP8 TensorCore</td>
<td>原生 BF16/FP8/FP4 Tensor Core</td>
</tr>
<tr>
<td><strong>QSA 評分</strong>（O(T²)）</td>
<td>剩餘15-30% 的一部分</td>
<td>FP32 SIMT warp kernel</td>
<td>同左（#742 加 FP32 tiled GEMM 救）</td>
<td><strong>TF32 Tensor Core scorer</strong></td>
<td>同左</td>
<td>同左</td>
</tr>
<tr>
<td><strong>Attention QK/PV + softmax</strong>（O(T²)）</td>
<td>15-30% 其餘</td>
<td>自訂 flash kernel，主要 CUDA core</td>
<td>同左</td>
<td>同左</td>
<td>同左</td>
<td>同左</td>
</tr>
<tr>
<td><strong>KV 讀寫 + expert 串流</strong></td>
<td>佔壁鐘時間</td>
<td>HBM / PCIe</td>
<td>GDDR6 / PCIe</td>
<td>GDDR6 / PCIe</td>
<td>GDDR6(X) / PCIe</td>
<td>GDDR7 / PCIe</td>
</tr>
</tbody>
</table>
<h2>AMD</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>組成</th>
<th>佔每 token 計算量</th>
<th>RDNA1（RX 5000）</th>
<th>RDNA2（RX 6000）</th>
<th>RDNA3（RX 7000）</th>
<th>RDNA4（RX 9000）</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Expert FFN</strong>（量化 GEMM，O(T)）</td>
<td>~60-70%</td>
<td>wave ALU（dequant→FMAC）</td>
<td>同左＋int8 片段走 dp4a</td>
<td>同左（WMMA 有 int8/int4 能力但 Strata 没用）</td>
<td>同左</td>
</tr>
<tr>
<td><strong>密集 16-bit 層</strong>（O(T)）</td>
<td>~10-15%</td>
<td>rocBLAS FP16 kernel（無 WMMA 硬體）</td>
<td>#835 前 generic fallback；#835 後 rocBLAS 調優 FP16 kernel</td>
<td>rocBLAS/hipBLASLt 調優 kernel</td>
<td>同左</td>
</tr>
<tr>
<td><strong>QSA 評分</strong>（O(T²)）</td>
<td>剩餘15-30% 的一部分</td>
<td>FP32 default kernel</td>
<td>FP32 default kernel（#849 pre75+DPP，bit-exact）</td>
<td>WMMA 硬體閒置、pre75 可手動開（STRATA_ATTN_PRE75=1）但沒人驗證過</td>
<td><strong>WMMA</strong>（opt-in，7.2-7.5x）</td>
</tr>
<tr>
<td><strong>Attention QK/PV + softmax</strong>（O(T²)）</td>
<td>15-30% 其餘</td>
<td>自訂 flash kernel，wave ALU</td>
<td>同左（shuffle/reduction 綁 LDS，#849 實測）</td>
<td>同左</td>
<td>同左</td>
</tr>
<tr>
<td><strong>KV 讀寫 + expert 串流</strong></td>
<td>佔壁鐘時間</td>
<td>GDDR6 / PCIe</td>
<td>同左</td>
<td>GDDR6 / PCIe</td>
<td>GDDR6 / PCIe</td>
</tr>
</tbody>
</table>
<p dir="auto">看起來接下來github上PR更新的重點<br />
查完了——<strong>沒變，兩張表不用更新</strong>：</p>
<h2>現況（剛查的）</h2>
<ul>
<li><strong>最新版還是 v0.1.39</strong>（10/04 發布），沒有 v0.1.40</li>
<li>關鍵 PR <strong>全部還是 open、未合併</strong>：</li>
</ul>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>PR</th>
<th>內容</th>
<th>狀態</th>
</tr>
</thead>
<tbody>
<tr>
<td>#835</td>
<td>RDNA2 FP16 in/out GEMM（prefill ~2x）</td>
<td>open，可合併（clean）</td>
</tr>
<tr>
<td>#849</td>
<td>RDNA2 pre75+DPP attention（bit-exact）</td>
<td>open，可合併（clean）</td>
</tr>
<tr>
<td>#741</td>
<td>Volta/Turing BF16→FP16 tensor core（2080 Ti +8-17%）</td>
<td>open，<strong>有衝突（dirty）</strong>——落後 main，最難生</td>
</tr>
<tr>
<td>#742</td>
<td>Turing FP32 tiled QSA（2080 Ti +22-33%）</td>
<td>open，可合併（clean）</td>
</tr>
<tr>
<td>#854</td>
<td>雙卡 helper PCIe share 修復（6900 XT decode 40→66）</td>
<td>open</td>
</tr>
</tbody>
</table>
<p dir="auto">看來近期更新優化會是在RDNA2與Turing等老卡，尤其是RDNA2會讓prefill翻倍(原本低到可憐)<br />
維持觀察，等 v0.1.40 出來再更新表。</p>
]]></description><link>https://lcz.me/topic/2128</link><generator>RSS for Node</generator><lastBuildDate>Sun, 25 Oct 2026 18:24:02 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/2128.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Oct 2026 03:21:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qwen3.8 FlashNext運算組成 A卡與N卡在Strata對應的運算單元 on Tue, 06 Oct 2026 03:57:58 GMT]]></title><description><![CDATA[<p dir="auto">這推論框架也不是完美，比較失望的是高併發能力 比llama.cpp還要殘，就個人單會話使用限定，要當服務器別想太多</p>
]]></description><link>https://lcz.me/post/22748</link><guid isPermaLink="true">https://lcz.me/post/22748</guid><dc:creator><![CDATA[dardeaw feng]]></dc:creator><pubDate>Tue, 06 Oct 2026 03:57:58 GMT</pubDate></item></channel></rss>