<?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[Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论]]></title><description><![CDATA[<h1>Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论</h1>
<blockquote>
<p dir="auto">平台：Ubuntu 26.04.1 LTS / Strata 0.2.22 (build 0.1.69) / hy4 引擎 0.1.67<br />
模型：Hy4-Flash-SQ-64 + Engram-Q8 + Vision<br />
测试时间：2026-11-26<br />
测试方法：OpenAI 兼容接口流式请求，每点两遍取第二遍（热态），盘读用 <code>/proc/&lt;pid&gt;/io</code> 的 <code>read_bytes</code></p>
</blockquote>
<hr />
<h2>0. 先说结论</h2>
<ol>
<li><strong>在这套 MoE + CPU/GPU 混合推理上，决定 decode 速度的唯一变量是「显存里能装多少个每 token 必用的热专家」。</strong> 显存容量够了，带宽多 50%、CU 多 50% 都不体现；显存不够，再多带宽也救不回来。</li>
<li><strong>两台机器的同显存对照下 decode 打平（12.7 vs 12.2）</strong>，说明 RDNA4 与 RDNA3 的架构差异在这类负载上不是主要因素，真正拉开 2 倍差距的是 32GB 与 24GB。</li>
<li><strong>32GB 卡可以跑到 256K 上下文</strong>（28 分钟读完，decode 保留 60%）；<strong>24GB 卡的上限是 128K</strong>，256K 会把 KV 挤进主机内存并卡死。</li>
<li><strong><code>--ram-experts-gb</code> 是双向开关，不是越大越好</strong>。给少了专家落盘（每请求读 19–21 GB 硬盘）；给多了会把显存里的热专家挤进内存，速度直接减半。</li>
<li><strong>CPU 不是瓶颈</strong>：把 CPU 线程从 4 砍到 1，decode 速度不掉。换更强的 CPU 没有意义。</li>
<li><strong>投机解码默认开着，但在这套配置上几乎无效</strong>（accept 率 0.28–0.40），关掉速度不变。</li>
</ol>
<hr />
<h2>1. 测试平台</h2>
<h3>1.1 硬件</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项</th>
<th>A 机（32GB）</th>
<th>B 机（24GB）</th>
</tr>
</thead>
<tbody>
<tr>
<td>GPU</td>
<td>Radeon AI PRO R9700</td>
<td>Radeon RX 7900 XTX</td>
</tr>
<tr>
<td>芯片</td>
<td>Navi 48（gfx1201，RDNA4）</td>
<td>Navi 31（gfx1100，RDNA3）</td>
</tr>
<tr>
<td>显存</td>
<td><strong>31.86 GiB</strong></td>
<td><strong>24 GiB</strong></td>
</tr>
<tr>
<td>显存带宽</td>
<td>640 GB/s</td>
<td><strong>960 GB/s（+50%）</strong></td>
</tr>
<tr>
<td>CU 数</td>
<td>64</td>
<td><strong>96（+50%）</strong></td>
</tr>
<tr>
<td>CPU</td>
<td>Core i3-14100F（4C8T，睿频 4.7 GHz，L3 12 MB）</td>
<td>Core i5-12490F（6C12T，睿频 4.6 GHz，L3 20 MB）</td>
</tr>
<tr>
<td>内存</td>
<td>64 GB DDR4-2400（4×16 GB）</td>
<td>64 GB DDR4-2667（4×16 GB）</td>
</tr>
<tr>
<td>主板</td>
<td>MS-Terminator B760M D4（铭瑄）</td>
<td>UN-B760M ARGB PRO 2.5G（双敏）</td>
</tr>
<tr>
<td>系统</td>
<td>Ubuntu 26.04.1 LTS，内核 7.0.0-44-generic</td>
<td>同左</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>CPU 刻意对齐</strong>：B 机虽然是 6C12T，但用 <code>AllowedCPUs=0-7</code> 加 <code>HY4_CPU_THREADS=4</code> 限制到 4C8T，与 A 机同构。两机的 <code>cpu0–7</code> 正好都对应 <code>core0–3</code>，属于同一种拓扑。</p>
<p dir="auto">这样做的目的：把「CPU 差异」这个变量从对照里排除掉，让表里剩下的差异只有显卡。</p>
<h3>1.2 软件栈</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>组件</th>
<th>版本</th>
</tr>
</thead>
<tbody>
<tr>
<td>Strata control</td>
<td><code>strata 0.2.22 (build 0.1.69)</code>，内置 Python 3.12.15</td>
</tr>
<tr>
<td>主引擎</td>
<td><code>strata-engine 0.1.69</code> —— A 机 <code>hip-rx9070</code>，B 机 <code>hip-rx7900</code></td>
</tr>
<tr>
<td>Hy4 形状引擎</td>
<td><code>strata-hy4 0.1.67</code> —— 同样按架构分档</td>
</tr>
<tr>
<td>系统 ROCm</td>
<td><strong>未安装</strong>（<code>/opt/rocm</code> 不存在）</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>关于系统 ROCm</strong>：引擎包自带完整运行时（<code>libamdhip64.so.7</code>、<code>libhipblaslt.so.1</code>、<code>libamd_comgr.so.3</code>、<code>libLLVM.so.*</code>），整个包 1.1–2.2 GB，启动时不查 <code>/opt/rocm</code>。内核驱动 <code>amdgpu.ko</code> 是系统的，两机都加载了 13 个模块。也就是说：<strong>没装 ROCm ≠ 没装 AMD 驱动</strong>，用户态库由引擎包托管。</p>
<p dir="auto">一个能说明「为什么必须按卡选包」的细节：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th>A 机（gfx1201）</th>
<th>B 机（gfx1100）</th>
</tr>
</thead>
<tbody>
<tr>
<td>引擎包体积</td>
<td>2.2 GB</td>
<td>1.1 GB</td>
</tr>
<tr>
<td>自带 LLVM</td>
<td><code>libLLVM.so.23.0git</code></td>
<td><code>libLLVM.so.22.0git</code></td>
</tr>
</tbody>
</table>
<p dir="auto">RDNA4 需要更新的 LLVM 才认 gfx1201，所以包大一倍。同一个引擎版本，不同架构是不同编译产物，混用跑不起来。</p>
<h3>1.3 模型</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>文件</th>
<th>字节</th>
<th>大小</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Hy4-Flash-SQ-64.strata</code>（主权重）</td>
<td>62,030,467,072</td>
<td>57.8 GiB</td>
</tr>
<tr>
<td><code>Hy4-Flash-Engram-Q8.strata</code>（Engram）</td>
<td>67,584,905,216</td>
<td>63.0 GiB</td>
</tr>
<tr>
<td><code>Hy4-Flash-Vision.strata</code>（视觉）</td>
<td>934,092,800</td>
<td>0.87 GiB</td>
</tr>
</tbody>
</table>
<p dir="auto">注意 Engram 权重（63 GiB）<strong>比整机内存还大</strong>，所以它不可能全驻内存，只能按行读取 + LRU 缓存。这一点后面会量化。</p>
<h3>1.4 启动方式</h3>
<pre><code class="language-bash">strata serve \
  --profile ~/.local/share/strata/terminal/current/strata-hy4-flash-sq-64.json \
  --host 0.0.0.0 --port 8086
</code></pre>
<p dir="auto">profile 里的关键参数（32K 生产配置）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>参数</th>
<th>A 机</th>
<th>B 机</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>--max-context</code></td>
<td>32768</td>
<td>32768</td>
</tr>
<tr>
<td><code>--vram-experts-gb</code></td>
<td>24.0</td>
<td>20.0</td>
</tr>
<tr>
<td><code>--ram-experts-gb</code></td>
<td>39.5</td>
<td>39.5</td>
</tr>
<tr>
<td><code>--vision</code></td>
<td>有</td>
<td>有</td>
</tr>
</tbody>
</table>
<hr />
<h2>2. 显存分层：速度从哪里来</h2>
<p dir="auto">引擎会把 MoE 专家分成三层：</p>
<ul>
<li><strong>static VRAM</strong>：每 token 必用的热专家，常驻显存</li>
<li><strong>adaptive VRAM</strong>：按需换入换出的槽位</li>
<li><strong>RAM（CPU）</strong>：冷专家，放主机内存</li>
<li><strong>SSD</strong>：更冷的，放硬盘（最慢）</li>
</ul>
<p dir="auto">32K 配置下的实际分层：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th>A 机</th>
<th>B 机</th>
</tr>
</thead>
<tbody>
<tr>
<td>static VRAM</td>
<td><strong>3795</strong>（13.63 GB）</td>
<td><strong>3171</strong>（11.77 GB）</td>
</tr>
<tr>
<td>adaptive VRAM</td>
<td>3124（8.83 GB）</td>
<td>972（3.61 GB）</td>
</tr>
<tr>
<td>显存专家合计</td>
<td><strong>22.46 GB</strong></td>
<td><strong>15.37 GB</strong></td>
</tr>
<tr>
<td>RAM 专家</td>
<td>17197（42.41 GB）</td>
<td>16989（42.41 GB）</td>
</tr>
<tr>
<td>SSD 专家</td>
<td><strong>0</strong></td>
<td><strong>832（1.86 GB）</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">B 机的 24 GB 装不下全部专家，有 832 个被扔到 SSD。代价立刻体现在盘读上（见 §4）。</p>
<hr />
<h2>3. 同显存对照：架构差异到底有多大</h2>
<p dir="auto">这是整套测试里最关键的一组。把两台机器的<strong>显存专家量强制拉到同一水平</strong>：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th>A 机（vram 14 / ram 45）</th>
<th>B 机（vram 20 / ram 45）</th>
</tr>
</thead>
<tbody>
<tr>
<td>static VRAM</td>
<td><strong>2080</strong>（7.72 GB）</td>
<td><strong>2081</strong>（7.72 GB）</td>
</tr>
<tr>
<td>adaptive</td>
<td>1970（7.31 GB）</td>
<td>2052（7.61 GB）</td>
</tr>
<tr>
<td>RAM 专家</td>
<td>18910（48.32 GB）</td>
<td>18911（48.32 GB）</td>
</tr>
<tr>
<td><strong>decode</strong></td>
<td><strong>12.7 t/s</strong>（12.7 / 13.4 / 12.5）</td>
<td><strong>12.2 t/s</strong>（12.2 / 11.6 / 12.7）</td>
</tr>
<tr>
<td><strong>prefill（26K）</strong></td>
<td><strong>705 t/s</strong></td>
<td>605 t/s</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>解码打平（差 4%，在噪声内），prefill 反而 24GB 卡慢 17%。</strong></p>
<p dir="auto">7900 XTX 的 +50% 带宽、+28% 标称 FP16、+50% CU，在这个负载上<strong>一点都没体现</strong>。原因很直白：MoE decode 是访存型负载，每 token 只激活少量专家，真正的限制是「热专家在不在显存里」，而不是「显存有多快」。</p>
<p dir="auto">所以两机各自最优配置下那 2 倍差距（31.7 vs 15.7），<strong>100% 来自显存容量</strong>。</p>
<hr />
<h2>4. 上下文长度全扫描</h2>
<p dir="auto">这是本文的主体数据。每台机器在三种 <code>--max-context</code> 配置下各扫一遍。</p>
<h3>4.1 A 机（32GB）</h3>
<p dir="auto"><strong>配置：ctx 32768，vram 24.0 / ram 39.5（static 3795，0 落盘）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>TTFT</th>
<th>prefill</th>
<th>输出</th>
<th>decode</th>
<th>总时长</th>
<th>盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>184</td>
<td>2.12 s</td>
<td>87 t/s</td>
<td>210</td>
<td>31.3 t/s</td>
<td>8.8 s</td>
<td>40 MB</td>
</tr>
<tr>
<td>1,042</td>
<td>2.85 s</td>
<td>366</td>
<td>224</td>
<td>31.6</td>
<td>9.9 s</td>
<td>48 MB</td>
</tr>
<tr>
<td>2,032</td>
<td>3.37 s</td>
<td>602</td>
<td>225</td>
<td>28.7</td>
<td>11.2 s</td>
<td>42 MB</td>
</tr>
<tr>
<td>4,045</td>
<td>4.46 s</td>
<td>908</td>
<td>224</td>
<td>29.1</td>
<td>12.2 s</td>
<td>32 MB</td>
</tr>
<tr>
<td>8,038</td>
<td>6.66 s</td>
<td>1,206</td>
<td>266</td>
<td>27.4</td>
<td>16.4 s</td>
<td>36 MB</td>
</tr>
<tr>
<td>16,024</td>
<td>11.62 s</td>
<td>1,379</td>
<td>225</td>
<td>27.9</td>
<td>19.7 s</td>
<td>21 MB</td>
</tr>
<tr>
<td>24,043</td>
<td>16.69 s</td>
<td>1,440</td>
<td>217</td>
<td>24.0</td>
<td>25.7 s</td>
<td>23 MB</td>
</tr>
<tr>
<td>28,036</td>
<td>19.23 s</td>
<td>1,458</td>
<td>257</td>
<td>28.9</td>
<td>28.1 s</td>
<td>42 MB</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>配置：ctx 131072（static 3795，adaptive 2414，仍 0 落盘）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>TTFT</th>
<th>prefill</th>
<th>输出</th>
<th>decode</th>
<th>总时长</th>
<th>盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>32,029</td>
<td>22.00 s</td>
<td>1,456 t/s</td>
<td>221</td>
<td>24.5 t/s</td>
<td>31.1 s</td>
<td>69 MB</td>
</tr>
<tr>
<td>48,034</td>
<td>32.64 s</td>
<td>1,472</td>
<td>225</td>
<td>25.2</td>
<td>41.5 s</td>
<td>47 MB</td>
</tr>
<tr>
<td>64,006</td>
<td>43.61 s</td>
<td>1,468</td>
<td>198</td>
<td>22.8</td>
<td>52.3 s</td>
<td>44 MB</td>
</tr>
<tr>
<td>96,016</td>
<td>66.85 s</td>
<td>1,436</td>
<td>212</td>
<td>22.1</td>
<td>76.4 s</td>
<td>38 MB</td>
</tr>
<tr>
<td>127,993</td>
<td>91.74 s</td>
<td>1,395</td>
<td>253</td>
<td>22.7</td>
<td>102.9 s</td>
<td>49 MB</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>配置：ctx 262144（static 3611，adaptive 1420，233 个专家落 SSD 0.52 GB）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>TTFT</th>
<th>prefill</th>
<th>输出</th>
<th>decode</th>
<th>总时长</th>
<th>盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>160,003</td>
<td>130.80 s</td>
<td>1,223 t/s</td>
<td>246</td>
<td>19.6 t/s</td>
<td>143.3 s</td>
<td>247 MB</td>
</tr>
<tr>
<td>191,980</td>
<td>160.88 s</td>
<td>1,193</td>
<td>255</td>
<td>20.8</td>
<td>173.2 s</td>
<td>247 MB</td>
</tr>
<tr>
<td>255,967</td>
<td>226.39 s</td>
<td>1,131</td>
<td>218</td>
<td>18.9</td>
<td><strong>237.9 s</strong></td>
<td>219 MB</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>256K 能跑通</strong>：读完 256K 上下文约 3.8 分钟（226 s prefill），带 218 token 输出总耗时 238 s。KV 实测 5.44 GB，能留在显存。</p>
<h3>4.2 B 机（24GB）</h3>
<p dir="auto"><strong>配置：ctx 32768，vram 20.0 / ram 39.5（static 3171，832 落盘 1.86 GB）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>TTFT</th>
<th>prefill</th>
<th>输出</th>
<th>decode</th>
<th>总时长</th>
<th>盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>184</td>
<td>4.00 s</td>
<td>46 t/s</td>
<td>200</td>
<td>17.5 t/s</td>
<td>15.4 s</td>
<td><strong>6.2 GB</strong></td>
</tr>
<tr>
<td>1,042</td>
<td>5.27 s</td>
<td>198</td>
<td>239</td>
<td>18.1</td>
<td>18.4 s</td>
<td><strong>7.6 GB</strong></td>
</tr>
<tr>
<td>2,032</td>
<td>6.08 s</td>
<td>334</td>
<td>220</td>
<td>18.2</td>
<td>18.3 s</td>
<td><strong>7.6 GB</strong></td>
</tr>
<tr>
<td>4,045</td>
<td>7.83 s</td>
<td>516</td>
<td>241</td>
<td>17.6</td>
<td>21.5 s</td>
<td><strong>8.4 GB</strong></td>
</tr>
<tr>
<td>8,038</td>
<td>13.46 s</td>
<td>597</td>
<td>281</td>
<td>16.5</td>
<td>30.4 s</td>
<td><strong>9.4 GB</strong></td>
</tr>
<tr>
<td>16,024</td>
<td>25.74 s</td>
<td>622</td>
<td>237</td>
<td>16.5</td>
<td>40.0 s</td>
<td><strong>11.2 GB</strong></td>
</tr>
<tr>
<td>24,043</td>
<td>29.61 s</td>
<td>812</td>
<td>253</td>
<td>16.7</td>
<td>44.7 s</td>
<td><strong>12.6 GB</strong></td>
</tr>
<tr>
<td>28,036</td>
<td>34.06 s</td>
<td>823</td>
<td>234</td>
<td>17.5</td>
<td>47.4 s</td>
<td><strong>12.2 GB</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>配置：ctx 131072（static 3171，adaptive 972）</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>TTFT</th>
<th>prefill</th>
<th>输出</th>
<th>decode</th>
<th>总时长</th>
<th>盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>48,034</td>
<td>56.75 s</td>
<td>846 t/s</td>
<td>246</td>
<td>15.4 t/s</td>
<td>72.7 s</td>
<td><strong>15.5 GB</strong></td>
</tr>
<tr>
<td>96,016</td>
<td>112.48 s</td>
<td>854</td>
<td>214</td>
<td>14.1</td>
<td>127.7 s</td>
<td><strong>21.6 GB</strong></td>
</tr>
<tr>
<td>127,993</td>
<td>151.07 s</td>
<td>847</td>
<td>223</td>
<td>13.2</td>
<td>168.0 s</td>
<td><strong>26.1 GB</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>配置：ctx 262144 → 不可用</strong></p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项</th>
<th>实测</th>
</tr>
</thead>
<tbody>
<tr>
<td>static VRAM</td>
<td>3075（11.41 GB）</td>
</tr>
<tr>
<td>SSD 专家</td>
<td>991（2.22 GB）</td>
</tr>
<tr>
<td>启动后 <code>device free</code></td>
<td><strong>1.3 GiB</strong></td>
</tr>
<tr>
<td>KV 需求（262144 positions）</td>
<td><strong>5.44 GB</strong></td>
</tr>
<tr>
<td>引擎行为</td>
<td><code>sparse KV + IndexPool **moved to pinned host memory** (5.44 GB)</code></td>
</tr>
<tr>
<td>160K 请求结果</td>
<td><strong>25 分钟无任何输出，日志零新增 → 判定卡死</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>结论：24GB 卡的实用上下文上限是 128K。</strong> 256K 虽然能启动，但显存装不下 KV，引擎自动把整块 KV 搬到主机内存，每次 decode 都要过 PCIe，实际已不可用。</p>
<h3>4.3 上下文长度带来的规律</h3>
<p dir="auto"><strong>prefill 在 8K 以上进入平台期</strong>：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>长度</th>
<th>A 机 prefill</th>
</tr>
</thead>
<tbody>
<tr>
<td>184</td>
<td>87 t/s</td>
</tr>
<tr>
<td>4K</td>
<td>908</td>
</tr>
<tr>
<td>8K</td>
<td>1,206</td>
</tr>
<tr>
<td>16K</td>
<td>1,379</td>
</tr>
<tr>
<td>28K–64K</td>
<td>1,458–1,468（峰值）</td>
</tr>
<tr>
<td>128K</td>
<td>1,395</td>
</tr>
<tr>
<td>256K</td>
<td>1,131</td>
</tr>
</tbody>
</table>
<p dir="auto">短 prompt 的 prefill 数字低<strong>不是缺陷</strong>，而是固定开销（调度、首层装载）被短分母放大——184 token 时绝对值只有 2.1 s。</p>
<p dir="auto"><strong>decode 随长度缓慢衰减，没有悬崖</strong>：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>长度</th>
<th>A 机 decode</th>
</tr>
</thead>
<tbody>
<tr>
<td>184</td>
<td>31.3 t/s</td>
</tr>
<tr>
<td>8K</td>
<td>27.4</td>
</tr>
<tr>
<td>28K</td>
<td>28.9</td>
</tr>
<tr>
<td>128K</td>
<td>22.7</td>
</tr>
<tr>
<td>256K</td>
<td>18.9</td>
</tr>
</tbody>
</table>
<p dir="auto">从最短到 256K，decode 保留约 60%。</p>
<h3>4.4 支持 256K 的代价（A 机同长度对照）</h3>
<p dir="auto">同一台机器，只改 <code>--max-context</code>：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>长度</th>
<th>32K 配置 prefill / decode</th>
<th>256K 配置 prefill / decode</th>
<th>代价</th>
</tr>
</thead>
<tbody>
<tr>
<td>184</td>
<td>87 / 31.3</td>
<td>75 / 25.6</td>
<td>−14% / −18%</td>
</tr>
<tr>
<td>4,045</td>
<td>908 / 29.1</td>
<td>751 / 23.3</td>
<td>−17% / −20%</td>
</tr>
<tr>
<td>16,024</td>
<td>1,379 / 27.9</td>
<td>1,168 / 22.6</td>
<td>−15% / −19%</td>
</tr>
<tr>
<td>28,036</td>
<td>1,458 / 28.9</td>
<td>1,247 / 20.5</td>
<td>−14% / <strong>−29%</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">原因：KV 从 0.68 GB 涨到 5.44 GB，多占的 4.76 GB 只能从 adaptive 槽位和 static 专家里抠，于是 233 个专家落盘（盘读从 42 MB 涨到 205 MB）。</p>
<p dir="auto"><strong>所以 256K 不是白给的</strong>：日常用 32K 配置更快，256K 适合「需要的时候单独开」。</p>
<hr />
<h2>5. 参数调优：几个反直觉的结论</h2>
<h3>5.1 <code>--ram-experts-gb</code> 是双向开关</h3>
<p dir="auto"><strong>给少了 → 专家落盘，速度崩</strong></p>
<p dir="auto">A 机，默认 28：</p>
<pre><code>[load] RAM budget 28.0 GB for the host experts (39.0 GB wanted):
       4004 experts (8.95 GB, the coldest ranks) stay on the SSD
</code></pre>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>指标</th>
<th>ram 28（4004 落盘）</th>
<th>ram 39.5（0 落盘）</th>
</tr>
</thead>
<tbody>
<tr>
<td>每请求盘读</td>
<td><strong>19.0–21.7 GB</strong></td>
<td><strong>3.7–5.1 MiB</strong></td>
</tr>
<tr>
<td>5 条请求合计盘读</td>
<td><strong>103.4 GB</strong></td>
<td>21.4 MiB</td>
</tr>
<tr>
<td>prefill</td>
<td>136–176 t/s</td>
<td>1,021–1,365 t/s</td>
</tr>
<tr>
<td>中文 decode</td>
<td><strong>5.7 t/s</strong></td>
<td><strong>26.9–32.4 t/s</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">盘读差 <strong>4,800 倍</strong>，速度差 5 倍。</p>
<p dir="auto"><strong>给多了 → 热专家被挤出显存，速度也崩</strong></p>
<p dir="auto">A 机，vram 固定 24：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>ram</th>
<th>0 落盘</th>
<th>static</th>
<th>decode</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>39.5</strong></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
<td><strong>3795</strong></td>
<td><strong>31.7 t/s</strong></td>
</tr>
<tr>
<td>45</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
<td><strong>2081</strong></td>
<td><strong>16.7 t/s</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">同一张卡、同样的显存总量，RAM 预算从 39.5 提到 45，static 掉了 1714 个，<strong>速度直接减半</strong>。引擎会把专家往内存里挪，把显存留给 KV——但热专家一旦不在显存，每个 token 都要走慢速路径。</p>
<p dir="auto">B 机（24GB）同样规律：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>vram/ram</th>
<th>SSD 专家</th>
<th>static</th>
<th>decode</th>
</tr>
</thead>
<tbody>
<tr>
<td>20 / 39.5</td>
<td>832（1.86 GB）</td>
<td><strong>3171</strong></td>
<td><strong>15.7 t/s</strong></td>
</tr>
<tr>
<td>20 / 42</td>
<td>0</td>
<td>2949</td>
<td>12.4</td>
</tr>
<tr>
<td>20 / 45</td>
<td>0</td>
<td>2081</td>
<td>11.6</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>B 机的正确取值是 39.5，宁可让 832 个专家落盘，也要保住 static。</strong> 「加内存消除落盘」在这台机器上是错方向。</p>
<h3>5.2 <code>--vram-experts-gb</code> 是上限，不是分配量</h3>
<p dir="auto">A 机把它从 24 提到 25.5，专家分层<strong>一字未变</strong>（3795 + 3124 = 22.46 GB，<code>device free 2.7 GiB</code> 不变）。引擎自己算 22.46 GB 就是最优，剩下 2.7 GiB 主动留给 KV 增长和激活。</p>
<p dir="auto">但往下调就掉悬崖：切到 16/47.5 时 static 从 3795 掉到 1357，decode 从 32.8 掉到 13.9，GPU 频率从 3,300 MHz 掉到 1,740 MHz、功耗从 220 W 掉到 85 W。</p>
<h3>5.3 CPU 不是瓶颈：砍到单核也不掉速</h3>
<p dir="auto">A 机，同一条提示词，只改 <code>HY4_CPU_THREADS</code>：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>CPU 线程</th>
<th>decode</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>30.5 t/s</td>
</tr>
<tr>
<td>2</td>
<td>29.5 t/s</td>
</tr>
<tr>
<td>4（默认）</td>
<td>29.9–32.8 t/s</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>把 CPU 算力砍到剩一个核，速度都不掉。</strong> 引擎默认已经是「4 个物理核 pin 住、优先物理核」，本身就到顶了。</p>
<p dir="auto">推论：换 6C12T 或更强的 CPU 不会更快。之前 16/47.5 那组掉 58% 也不是 CPU 算不动，而是显存里的热专家变少、每 token 的串行链变长。</p>
<h3>5.4 投机解码开着，但几乎无效</h3>
<p dir="auto">日志显示默认在跑：</p>
<pre><code>[spec] K=7 adaptive tree=1 early=0.04: 202 tokens in 183 iterations
       (59 spec + 124 plain), 1.10 tokens/iteration
[spec] verify steps 59: accepted drafts per step 0.288
</code></pre>
<p dir="auto">accept 率 0.28–0.40，也就是 7 个候选只中 2–3 个。实测关掉（<code>--draft off</code>）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置</th>
<th>decode</th>
</tr>
</thead>
<tbody>
<tr>
<td>dfly2（默认）</td>
<td>29.9 / 32.8 t/s</td>
</tr>
<tr>
<td>off</td>
<td>30.2 / 31.7 t/s</td>
</tr>
</tbody>
</table>
<p dir="auto">没有差别。省下的那点又被验证开销吃回去了。</p>
<h3>5.5 Engram 缓存加大没有收益，但盘读全部来自它</h3>
<p dir="auto">Engram 权重 63 GiB，比整机内存还大，无法全驻留。用 <code>--no-engram</code> 做归因：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置</th>
<th>5 条请求总盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>关闭 engram</td>
<td><strong>0.00 MiB</strong></td>
</tr>
<tr>
<td>带 engram（冷态）</td>
<td>83.6 MiB</td>
</tr>
<tr>
<td>带 engram（热态）</td>
<td>21.4 MiB</td>
</tr>
<tr>
<td>带 engram（重复同批请求）</td>
<td>47.0 MiB</td>
</tr>
</tbody>
</table>
<p dir="auto">热态约<strong>每 1,000 prompt token 读 1.1 MiB</strong>，一条 30K token 的请求约 33 MiB。量级不影响响应时间。</p>
<p dir="auto">而缓存从 512 MiB 提到 2048 MiB（覆盖 63 GiB 的 0.8%→3.2%）实测是 <strong>21.4 → 24.9 MiB，反而略高</strong>。要真正见效得设到 32 GB 量级，但那需要 128 GB 内存才放得下。</p>
<h3>5.6 专家锁页走不通</h3>
<p dir="auto">引擎有 <code>HY4_CPUEXP_MLOCK=1</code> 开关，但系统 <code>ulimit -l</code> 硬限只有 8 MB，而专家要 42 GB。<code>LimitMEMLOCK=infinity</code> 被内核拒绝，日志始终 <code>mlock=no</code>。这条路在当前权限下不通。</p>
<hr />
<h2>6. 参数配方（可直接抄）</h2>
<h3>A 机（32GB，日常 32K）</h3>
<pre><code class="language-json">{
  "args": [
    "--max-context", "32768",
    "--vram-experts-gb", "24.0",
    "--ram-experts-gb", "39.5"
  ]
}
</code></pre>
<h3>A 机（32GB，需要长上下文时切 128K）</h3>
<pre><code class="language-json">{
  "args": [
    "--max-context", "131072",
    "--vram-experts-gb", "24.0",
    "--ram-experts-gb", "39.5"
  ]
}
</code></pre>
<p dir="auto">256K 也能跑，但日常不建议常开（短请求慢 15–29%）。</p>
<h3>B 机（24GB，上限 128K）</h3>
<pre><code class="language-json">{
  "args": [
    "--max-context", "131072",
    "--vram-experts-gb", "20.0",
    "--ram-experts-gb", "39.5"
  ]
}
</code></pre>
<p dir="auto"><strong>不要</strong>给 B 机设 <code>--max-context 262144</code>：KV 会进主机内存，实测卡死。</p>
<hr />
<h2>7. 两个操作注意事项</h2>
<ol>
<li><strong>重启后的第一条长请求要读 57.8 GiB 盘</strong>。arena 的页面首次缺页，要把整个权重过一遍；热态之后每条只有几 MB。所以别频繁改参数重启——每次重启的第一次长请求都要付这个冷启动代价。</li>
<li><strong>跑 Hy4 时不要同时叠视频生成</strong>。A 机跑 Hy4 时内存 44/61 GB、可用只剩 15–17 GB，专家页一旦被挤出去就退回 19 GB/条的盘读。</li>
</ol>
<hr />
<h2>8. 附带发现</h2>
<p dir="auto"><strong>视觉是能用的</strong>，虽然 <code>--plan</code> 的输出写着 <code>this engine does not read images yet</code>。用两张完全不同的几何图测试（一张白底红圆+蓝三角，一张黑底紫方块+白椭圆+橙条），形状、颜色、位置、底色全部答对。代价是图片被压成极少 token（约 20 个）。这可能解释了为什么论坛上有人说「视觉残废」——压缩率这么高，复杂图必然丢细节。</p>
<p dir="auto"><strong>引擎有个内置的自动降级</strong>：显存不够时会把 KV 搬到主机内存（<code>moved to pinned host memory</code>）。设计上是「保证能跑」，但在 24GB 卡上 256K 这个量级，实际结果是从「慢」变成「卡死」，不如直接不支持。</p>
<hr />
<h2>9. 汇总表</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项目</th>
<th>A 机 32GB</th>
<th>B 机 24GB</th>
</tr>
</thead>
<tbody>
<tr>
<td>32K 配置 decode</td>
<td><strong>31.7 t/s</strong></td>
<td>15.7 t/s</td>
</tr>
<tr>
<td>32K 配置 prefill（26K）</td>
<td><strong>1,322 t/s</strong></td>
<td>753 t/s</td>
</tr>
<tr>
<td>同显存对照 decode</td>
<td>12.7</td>
<td>12.2</td>
</tr>
<tr>
<td>同显存对照 prefill</td>
<td><strong>705</strong></td>
<td>605</td>
</tr>
<tr>
<td>static 热专家（最优配置）</td>
<td><strong>3795</strong></td>
<td>3171</td>
</tr>
<tr>
<td>32K 配置盘读（每请求）</td>
<td>20–50 MB</td>
<td><strong>6–12 GB</strong></td>
</tr>
<tr>
<td>可用最大上下文（实用）</td>
<td><strong>256K</strong></td>
<td><strong>128K</strong></td>
</tr>
<tr>
<td>256K decode</td>
<td>18.9</td>
<td>不可用</td>
</tr>
<tr>
<td>256K 读完全文耗时</td>
<td>238 s</td>
<td>不可用</td>
</tr>
</tbody>
</table>
<hr />
<p dir="auto"><em>测试脚本：流式请求统计 TTFT 与 decode 斜率；盘读取 <code>/proc/&lt;pid&gt;/io</code> 的 <code>read_bytes</code>（块设备实际读取，含 mmap 缺页）。每次测量前先跑一遍同长度丢弃，取第二次的热态值。</em></p>
<hr />
<h1>更新：24G 卡上两个环境变量叠出 +24.5%，以及一个「盘读降 390 倍但速度不动」的反例</h1>
<blockquote>
<p dir="auto">本文是《Hy4-Flash-SQ-64 双卡上下文长度与资源配置实测》的补充更新，只讲三件事：三个未公开的环境变量、24G 卡的天花板核算、以及一个容易被误读的「盘读下降」现象。<br />
平台、模型、软件版本与前帖相同：Ubuntu 26.04.1 LTS / 内核 7.0.0-44 / Strata control 0.1.69 / engine 0.1.69 / hy4 0.1.67 / Hy4-Flash-SQ-64 + Engram-Q8 + Vision。<br />
机型沿用前帖：<strong>A 机 = R9700 32GB，B 机 = 7900XTX 24GB</strong>。两机均限 4C8T 对齐。</p>
</blockquote>
<hr />
<h2>0. 先说结论</h2>
<ol>
<li><strong>B 机（24GB）有两个环境变量可以叠</strong>：<code>STRATA_CPUEXP_COLD_CACHE_MB=2048</code> 与 <code>HY4_DEC_PCIE_SHARE=0</code>。基线 16.16 → 18.93（+17%）→ <strong>20.12 t/s（+24.5%）</strong>，每请求盘读 14.37 GiB → 0.14 GiB。</li>
<li><strong>但缓存不是越大越好</strong>：832 个落盘专家 × 2.13 MB = 1.86 GB，<strong>2048 MB（960 槽）刚好全驻</strong>；给 8192 MB 一点额外收益都没有（20.03 vs 20.12），白占 6 GB 内存。</li>
<li><strong>同一个变量在另一台机器上没有效果，在第三台机器上甚至有害</strong>。<code>HY4_DEC_PCIE_SHARE=0</code>：B 机 +11%、A 机 0%、A 机 256K 地形 <strong>−19%</strong>。它不是通用优化。</li>
<li><strong>盘读降了不代表变快</strong>。长上下文下盘读降了 <strong>390 倍</strong>，decode 一点没动（12.8 vs 13.2）。判「有没有收益」要看对的是哪一层。</li>
<li><strong>B 机的 20 t/s 基本就是天花板</strong>，不是调参没调到位。显存账在 §5 算给你看。</li>
</ol>
<hr />
<h2>1. 测试条件</h2>
<ul>
<li>B 机配方不变：<code>--vram-experts-gb 20.0 --ram-experts-gb 39.5 --max-context 32768</code>，832 个专家落盘（1.86 GB），static 3171。</li>
<li>每个开关都<strong>重启实例</strong>（环境变量只在启动时读一次），并回读分层日志确认参数真的进去了——这一步不做，很容易把「变量没生效」当成「无效」。</li>
<li>脚本：流式请求、拆 TTFT 算 decode；盘读取 <code>/proc/&lt;pid&gt;/io</code> 的 <code>read_bytes</code>（块设备真实读取，含 mmap 缺页）。</li>
<li>每配置先跑一条预热（丢弃），再跑 3 条正式取均值。同一配置换引擎重跑，基线两次 16.16 / 16.30，<strong>重复性 0.9%</strong>。</li>
</ul>
<hr />
<h2>2. 九组对照（B 机 24GB，同脚本、同提示词、热态）</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>组</th>
<th>配置</th>
<th>decode 三点</th>
<th>均值</th>
<th>相对基线</th>
<th>每请求盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>基线：<code>O_DIRECT</code> + 256 MB 缓存</td>
<td>16.34 / 17.42 / 14.71</td>
<td><strong>16.16</strong></td>
<td>—</td>
<td>14.37 GiB</td>
</tr>
<tr>
<td>A2</td>
<td>基线重复</td>
<td>15.35 / 17.03 / 16.51</td>
<td>16.30</td>
<td>+0.9%</td>
<td>13.05 GiB</td>
</tr>
<tr>
<td>B</td>
<td><code>COLD_CACHE_MB=2048</code></td>
<td>18.52 / 18.38 / 19.89</td>
<td><strong>18.93</strong></td>
<td>+17.1%</td>
<td>0.15 GiB</td>
</tr>
<tr>
<td>C</td>
<td><code>COLD_CACHE_MB=1024</code></td>
<td>17.37 / 16.34 / 17.65</td>
<td>17.12</td>
<td>+5.9%</td>
<td>0.19 GiB</td>
</tr>
<tr>
<td>D</td>
<td><code>COLD_IO=buffered</code> + 256 MB</td>
<td>16.82 / 16.18 / 17.05</td>
<td>16.68</td>
<td>+3.2%</td>
<td>0.14 GiB</td>
</tr>
<tr>
<td>E</td>
<td><code>buffered</code> + 2048 MB</td>
<td>17.72 / 17.85 / 19.28</td>
<td>18.28</td>
<td>+13.1%</td>
<td>0.18 GiB</td>
</tr>
<tr>
<td>F</td>
<td><code>PCIE_SHARE=0</code> + 256 MB</td>
<td>18.63 / 18.24 / 17.13</td>
<td><strong>18.00</strong></td>
<td>+11.4%</td>
<td>10.17 GiB</td>
</tr>
<tr>
<td>G</td>
<td><code>PCIE_SHARE=0</code> + 8192 MB</td>
<td>20.29 / 19.92 / 19.89</td>
<td>20.03</td>
<td>+24.0%</td>
<td>0.15 GiB</td>
</tr>
<tr>
<td>H</td>
<td><code>PCIE_SHARE=0</code> + 2048 MB</td>
<td>20.06 / 19.72 / 20.58</td>
<td><strong>20.12</strong></td>
<td><strong>+24.5%</strong></td>
<td>0.14 GiB</td>
</tr>
</tbody>
</table>
<p dir="auto">H 组三点全部 ≥19.7，与基线区间（14.7–17.4）不重叠，所以 +24.5% 不是噪声。</p>
<p dir="auto"><strong>启动参数</strong>（两个环境变量即可，profile 不用改）：</p>
<pre><code class="language-bash">HY4_DEC_PCIE_SHARE=0 \
STRATA_CPUEXP_COLD_CACHE_MB=2048 \
strata serve --profile ~/.local/share/strata/terminal/current/strata-hy4-flash-sq-64.json \
             --host 0.0.0.0 --port 8086
</code></pre>
<hr />
<h2>3. 三个反直觉的地方</h2>
<h3>3.1 冷专家缓存的收益，与「落盘占比」成正比，与「盘读降多少倍」无关</h3>
<p dir="auto">同一个开关，两台机器差 5 倍：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th>落盘专家</th>
<th>落盘大小</th>
<th>占全部专家</th>
<th>基线 decode</th>
<th>缓存开大后</th>
<th>倍数</th>
</tr>
</thead>
<tbody>
<tr>
<td>A 机（ram 压到 28，人为逼落盘）</td>
<td>4004</td>
<td>8.95 GB</td>
<td>19%</td>
<td>4.20</td>
<td>24.78</td>
<td><strong>5.9×</strong></td>
</tr>
<tr>
<td>B 机（ram 39.5，自然溢出）</td>
<td>832</td>
<td>1.86 GB</td>
<td>4%</td>
<td>16.16</td>
<td>18.93</td>
<td><strong>1.17×</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">判据在这里：<strong>每 token 撞上冷专家的概率</strong>。19% 的专家在盘上时，几乎每一层都要走冷路径；4% 时大部分层不碰。所以「盘读从 83 GiB 降到 0.58 GiB」看起来更猛，但只有前者是真被 IO 拖死了。</p>
<p dir="auto"><strong>给参数的正确算法</strong>：<code>缓存 MB = 落盘专家数 × 槽位大小（2.13 MB）× 1.2</code>。B 机 832 × 2.13 × 1.2 ≈ 2.1 GB，取 2048 MB。别照着「8 GB 一口全驻」抄，那会白吃 6 GB 内存——而且 6 GB 在 64 GB 机器上，就是你要不要同时跑视频生成的差别。</p>
<h3>3.2 把 <code>O_DIRECT</code> 换成 <code>buffered</code>，单独用几乎没用</h3>
<p dir="auto">D 组：缓存仍是 256 MB，只把 IO 模式换成 buffered。页缓存接住了那 1.86 GB 落盘专家，盘读从 14.37 GiB 掉到 0.14 GiB——<strong>降了 100 倍，decode 只涨 3%</strong>。</p>
<p dir="auto">结论：<strong>B 机上 <code>O_DIRECT</code> 不是罪魁</strong>。它的读是异步的（8 readers）、每 token 撞冷路径的频率低，IO 本来就被流水线盖住了。真正起作用的是缓存容量，不是这个 flag。</p>
<p dir="auto">顺带一个反证：<code>buffered</code> 与 2048 MB 缓存叠加反而更低（18.28 vs 18.93），说明页缓存和显式缓存在抢同一块内存，没有叠加收益。</p>
<h3>3.3 <code>HY4_DEC_PCIE_SHARE=0</code>：收益符号看机型，别当通用开关</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th>地形</th>
<th>基线</th>
<th><code>PCIE_SHARE=0</code></th>
<th>结果</th>
</tr>
</thead>
<tbody>
<tr>
<td>A 机 R9700 32G</td>
<td>0 落盘</td>
<td>32.14 / 32.03</td>
<td>32.16</td>
<td><strong>0%</strong></td>
</tr>
<tr>
<td>B 机 7900XTX 24G</td>
<td>832 落盘</td>
<td>16.16 / 16.30</td>
<td>18.00</td>
<td><strong>+11%</strong></td>
</tr>
<tr>
<td>A 机 256K 地形</td>
<td>233 落盘（0.52 GB）</td>
<td>23.9</td>
<td><strong>19.4</strong></td>
<td><strong>−19%</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">三台地形三个结果，机制也清楚：这个开关是在「冷专家由 CPU 直算」与「走 PCIe 搬上卡算」之间选路。</p>
<ul>
<li>0 落盘 ⇒ 没有冷 miss ⇒ 根本没有路可选，开关空转（A 机 32K 实测 0%）。</li>
<li>有落盘 + CPU 相对够用 ⇒ 选 CPU 直算划算（B 机 +11%）。</li>
<li>有落盘 + CPU 较弱 ⇒ 直算更慢，还是搬上去快（A 机 256K 地形 −19%）。</li>
</ul>
<p dir="auto">所以如果你的机器是 24G 显存、桌面级 4 核 CPU，这个开关值得试，量级 +10% 上下；如果你是 32G 显存、0 落盘，别浪费时间。</p>
<hr />
<h2>4. 反例：长上下文里，盘读降 390 倍，速度一点没动</h2>
<p dir="auto">B 机，<code>--max-context 131072</code> + 两个开关全开：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>prefill</th>
<th>decode</th>
<th>盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>32,029</td>
<td>654 t/s</td>
<td>15.2</td>
<td>128.8 MB</td>
</tr>
<tr>
<td>64,006</td>
<td>888</td>
<td>15.0</td>
<td>56.8 MB</td>
</tr>
<tr>
<td>127,993</td>
<td>886</td>
<td><strong>12.8</strong></td>
<td>66.9 MB</td>
</tr>
</tbody>
</table>
<p dir="auto">对照同机基线（只缓存 256 MB、开关默认）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>prompt tokens</th>
<th>基线 decode</th>
<th>基线盘读</th>
<th>本次 decode</th>
<th>本次盘读</th>
</tr>
</thead>
<tbody>
<tr>
<td>48,034</td>
<td>15.4</td>
<td>15.5 GB</td>
<td>≈15.0（64K）</td>
<td>56.8 MB</td>
</tr>
<tr>
<td>96,016</td>
<td>14.1</td>
<td>21.6 GB</td>
<td>—</td>
<td>—</td>
</tr>
<tr>
<td>127,993</td>
<td>13.2</td>
<td><strong>26.1 GB</strong></td>
<td>12.8</td>
<td><strong>66.9 MB</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">盘读从 26.1 GB 掉到 66.9 MB（<strong>390 倍</strong>），decode 反而低 3%（噪声内）。</p>
<p dir="auto">原因：落盘的那 1.86 GB 专家在一条请求里<strong>只会被读一遍</strong>，读完就进缓存了；而 KV 是<strong>每 token 都要过一遍</strong>（128K 时 2.7 GB）。所以给 24G 卡开大缓存，在长上下文里是「省 SSD 寿命」而不是「省时间」。</p>
<p dir="auto">如果你的观察口径只有 tok/s，这条会被判成「无效」；如果看的是 <code>/proc/&lt;pid&gt;/io</code>，它是 390 倍。</p>
<hr />
<h2>5. 为什么 24GB 卡的 20 t/s 是天花板</h2>
<p dir="auto"><code>--vram-experts-gb 20.0</code> 从来没绑住过。启动日志把 25.8 GB 显存分得干干净净：</p>
<pre><code>[plan] ctx 32768 (init 16384, kv=fp16) chunk 4096:
       buffers ~1.78 GB, KV+idx 0.34 GB, dfly 0.28 GB, floor 1.07 GB,
       trunk 5.54 GB (embed in RAM) on 25.7/25.8 GB -&gt; host mask 0; reserve 4.03 GiB
[runner] kv cache 0.39 GB, device free 1.5 GiB
</code></pre>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项</th>
<th>占用</th>
</tr>
</thead>
<tbody>
<tr>
<td>trunk（主干权重）</td>
<td>5.54 GB</td>
</tr>
<tr>
<td>buffers</td>
<td>1.78 GB</td>
</tr>
<tr>
<td>hybrid KV + index</td>
<td>0.34 GB</td>
</tr>
<tr>
<td>dfly 草稿头</td>
<td>0.28 GB</td>
</tr>
<tr>
<td>floor</td>
<td>1.07 GB</td>
</tr>
<tr>
<td>引擎主动留空</td>
<td>1.5 GiB</td>
</tr>
<tr>
<td><strong>剩给专家（25.8 − 9.0 − 1.5）</strong></td>
<td><strong>15.3 GB（实测 15.37）</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">static 3171 就是这么算出来的，把 <code>--vram-experts-gb</code> 提到 25 不会有任何变化（A 机已证：25.5 时分层的数字一字未改）。</p>
<p dir="auto"><strong>推论</strong>：24GB + 官方引擎 + SQ-64 权重，短 prompt 上限约 20 t/s，本次已经摸到。要到 40 得让 static 翻倍到 7000+，只有两条路——更小的量化（SQ-32 一类）或更大的显存（32GB 卡实测 31.7，见前帖）。靠调开关、调 IO、换 CPU 都到不了。</p>
<hr />
<h2>6. 对前帖两处说法的更正</h2>
<ol>
<li><strong>「冷缓存 256MB→8GB = 5.9×」是条件收益，不是普适值。</strong> 那次是在「ram 预算被压到 28、逼出 4004 个专家落盘」的坏配置上测的。正常配置（落盘 4% 的专家）只有 +17%。<strong>5.9× 应标注为「重落盘地形」。</strong></li>
<li><strong>8 GB 这个数值偏大。</strong> B 机 832 个专家只需 1.86 GB，2048 MB 就全驻，8192 与 2048 实测等值（20.03 vs 20.12）。按落盘量的 1.2 倍给缓存即可。</li>
</ol>
<hr />
<h2>7. 还没验的一条</h2>
<p dir="auto"><code>HY4_KV_Q8</code>。长上下文唯一的真变量：128K 时 KV 占 2.7 GB、256K 时 5.44 GB。如果 Q8 能压掉一半，24GB 卡 128K 的 decode 有机会从 12.8 上到 15–16，也可能让 192K 变成可用区间。这条没测，测完再补。</p>
<hr />
<p dir="auto"><em>测试脚本：流式请求统计 TTFT 与 decode 斜率；盘读取 <code>/proc/&lt;pid&gt;/io</code> 的 <code>read_bytes</code>。每配置先跑一条预热丢弃，取热态值；基线重复两次确认波动 0.9%。所有开关均通过回读启动日志确认生效。</em></p>
<p dir="auto"><img src="https://upload.lcz.me/uploads/f564db66-c7ec-4565-b2f7-519f6fc4cc87.jpg" alt="微信图片_20261126182814_8_26.jpg" class="img-markdown  img-fluid" /></p>
]]></description><link>https://lcz.me/topic/3347</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 03:11:59 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/3347.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Nov 2026 10:24:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:50:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/applejuice" aria-label="Profile: applejuice">@<bdi>applejuice</bdi></a> Q4没测，使用IQ3不行后，我就直接上了Q5。我128G内存，所以按能放下的装了。</p>
]]></description><link>https://lcz.me/post/36247</link><guid isPermaLink="true">https://lcz.me/post/36247</guid><dc:creator><![CDATA[oopsdump]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:50:30 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:48:51 GMT]]></title><description><![CDATA[<p dir="auto">q5 跟q4 很大差别吗？<br />
我记得之前27b 都是用q4 是最平衡的</p>
]]></description><link>https://lcz.me/post/36246</link><guid isPermaLink="true">https://lcz.me/post/36246</guid><dc:creator><![CDATA[applejuice]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:48:51 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:47:32 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%E4%BC%8A%E6%98%8E" aria-label="Profile: 伊明">@<bdi>伊明</bdi></a> <a href="/post/36147">说</a>:</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/he-wanga" aria-label="Profile: he-wanga">@<bdi>he-wanga</bdi></a> 也没错，我手里的双通道家用主板，也就这样了。就是纯吃内存带宽。</p>
</blockquote>
<p dir="auto">家用主板 基本上都是双通道   100来G的带宽</p>
]]></description><link>https://lcz.me/post/36245</link><guid isPermaLink="true">https://lcz.me/post/36245</guid><dc:creator><![CDATA[张光璞]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:47:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:42:10 GMT]]></title><description><![CDATA[<p dir="auto">DDR5目前太贵了。200B这种模型也是要精度的，我测下来Qwen3.8 flash next 的IQ3不稳，Q5相对好很多。所以DDR5至少上128G，价格可不低。而且本地模型不太稳，刚刚还和我嘴硬说表格里算出来6+6+1+32=44，还得我纠正过来。我在考虑双模型互审，内存需求就更大了。</p>
]]></description><link>https://lcz.me/post/36244</link><guid isPermaLink="true">https://lcz.me/post/36244</guid><dc:creator><![CDATA[oopsdump]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:42:10 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:29:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/oopsdump" aria-label="Profile: oopsdump">@<bdi>oopsdump</bdi></a> 权重体积上去了，估计内存规格就是瓶颈。我这两台主机的情况，ddr4我不会再买了，200b这种，大概率就是老平台的斩杀线。准备未来的模型，肯定是要上最新的平台的。大显存卡和多卡就另说了，没有机器测试</p>
]]></description><link>https://lcz.me/post/36242</link><guid isPermaLink="true">https://lcz.me/post/36242</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:29:38 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:25:49 GMT]]></title><description><![CDATA[<p dir="auto">使用的话，当然是有本地化需求的，一些隐私类的数据。目前我跑Qwen3.8 flash next Q5_K_XL也是速度偏慢，感觉就是专家命中率不行。W7900这个卡内存大，但是性能和7900xtx一样的，所以是不是实际跑这类模型，性能会比R9700还好些。</p>
]]></description><link>https://lcz.me/post/36240</link><guid isPermaLink="true">https://lcz.me/post/36240</guid><dc:creator><![CDATA[oopsdump]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:25:49 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:04:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/oopsdump" aria-label="Profile: oopsdump">@<bdi>oopsdump</bdi></a> 因为这个模型，打开workbuddy，就能免费用了，云端标准可能还更高</p>
]]></description><link>https://lcz.me/post/36239</link><guid isPermaLink="true">https://lcz.me/post/36239</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:04:11 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 02:01:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/oopsdump" aria-label="Profile: oopsdump">@<bdi>oopsdump</bdi></a> 更大显存的卡，一般算力也更好，大概率是了。但这个hy4这个模型是否值得用更好的硬件跑，另说。主要是未来200b这个级别有更好的模型，是不是会成为本地部署的一个新的方向，不知道了～</p>
]]></description><link>https://lcz.me/post/36238</link><guid isPermaLink="true">https://lcz.me/post/36238</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Sat, 28 Nov 2026 02:01:21 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Sat, 28 Nov 2026 01:47:58 GMT]]></title><description><![CDATA[<p dir="auto">所以，如果大显存应该作用应该更大？比如48G显存的卡？即使MoE也要追求专家命中率的。</p>
]]></description><link>https://lcz.me/post/36237</link><guid isPermaLink="true">https://lcz.me/post/36237</guid><dc:creator><![CDATA[oopsdump]]></dc:creator><pubDate>Sat, 28 Nov 2026 01:47:58 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Fri, 27 Nov 2026 05:57:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/he-wanga" aria-label="Profile: he-wanga">@<bdi>he-wanga</bdi></a> 也没错，我手里的双通道家用主板，也就这样了。就是纯吃内存带宽。</p>
]]></description><link>https://lcz.me/post/36147</link><guid isPermaLink="true">https://lcz.me/post/36147</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Fri, 27 Nov 2026 05:57:44 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Fri, 27 Nov 2026 05:59:26 GMT]]></title><description><![CDATA[<p dir="auto">ddr4好像還是得上4通道平台，不然連x99 DDR3 4通道的頻寬都贏不了<br />
我最近在考慮升級TRX40或WRX80，<br />
從你文章中的實測數據，看來能吃滿血4通道和穩定超到3200才有價值 (我的目前只有雙通跟2666，平台瓶頸了)</p>
]]></description><link>https://lcz.me/post/36146</link><guid isPermaLink="true">https://lcz.me/post/36146</guid><dc:creator><![CDATA[he wanga]]></dc:creator><pubDate>Fri, 27 Nov 2026 05:59:26 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Fri, 27 Nov 2026 05:31:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/uly-chen" aria-label="Profile: uly-chen">@<bdi>uly-chen</bdi></a> 是的，本来我想要不要再补ddr4内存，看来不需要了。我猜，未来新的200b级别的模型跑本地，就是ddr4老平台的斩杀线了。我测完了就继续用qwen3.8-flash-next了。</p>
]]></description><link>https://lcz.me/post/36143</link><guid isPermaLink="true">https://lcz.me/post/36143</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Fri, 27 Nov 2026 05:31:33 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Fri, 27 Nov 2026 05:25:59 GMT]]></title><description><![CDATA[<p dir="auto">看來 hy4-flash 門檻太高 DDR5-96 or 128 才有好的品質與速度  這模型前端包含畫SVG圖評價差 但後端其實不錯 應該是Tencent 會主推一陣子 Workbuddy 送的與官方便宜用就好了</p>
]]></description><link>https://lcz.me/post/36142</link><guid isPermaLink="true">https://lcz.me/post/36142</guid><dc:creator><![CDATA[uly chen]]></dc:creator><pubDate>Fri, 27 Nov 2026 05:25:59 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Fri, 27 Nov 2026 02:50:09 GMT]]></title><description><![CDATA[<h1>更新四：官方标的 62 t/s 和我们的 34.9 t/s 差在哪——核对了官方仓库，也把「算力 vs 带宽」做了一次隔离实验</h1>
<blockquote>
<p dir="auto">本文是本系列第四篇。前三篇：主帖《Hy4-Flash-SQ-64 双卡上下文长度与资源配置实测》、更新《24G 卡上两个环境变量叠出 +24.5%》、《最终补充：24G 卡从 20 走到 48.7 t/s 与 19 个环境变量扫描》。<br />
本篇只回答一个问题：<strong>官方在你的同款卡上标 62 t/s，我们实测只有 34.9，这 27 t/s 的差距到底是什么。</strong> 顺带纠正一个很容易犯的归因错误。<br />
平台不变：Ubuntu 26.04.1 LTS / 内核 7.0.0-44 / Strata control 0.1.69 / engine 0.1.69 / hy4 0.1.67 / Hy4-Flash-SQ-64 + Engram-Q8 + Vision。<strong>A 机 = R9700 32GB，B 机 = 7900XTX 24GB</strong>，均限 4C8T。</p>
</blockquote>
<hr />
<h2>0. 先说结论</h2>
<ol>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>我们跑的就是官方包，一点没改。</strong> 三个权重文件的字节数与官方仓库逐位相同——不是我们自己的量化，也不是版本差异。所以差距不可能是「权重不对」。</li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>差距 100% 来自内存带宽。</strong> A 机 DDR4-2400 双通道实测只有 <strong>36.4 GB/s</strong>，而官方在同款 R9700 上标 62 t/s，反推需要约 <strong>64.5 GB/s</strong>——那是 DDR5 的水平。<strong>同一张卡、同一份权重，只换平台内存，就能差 77%。换显卡解决不了，加内存容量也解决不了。</strong></li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>「因为 5090 算力强所以快」这个归因是错的。</strong> 我做了一次隔离实验：把 GPU 算力占满 100%，B 机 decode 几乎不动（−0.9%），A 机掉 16.6%——而抢内存带宽能掉 38%。算力不是主瓶颈。</li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>注意别拿不同上下文的数字直接比。</strong> 官方表里 5090 是 128K ctx 下的 90–111 t/s，R9700 是 4K ctx 下的 62 t/s。长上下文 decode 本身要掉 18–29%，所以 5090 在更重的负载下还更快，差距比表面更大——但这两行<strong>不是同条件对比</strong>，别当成「同规格只差算力」。</li>
</ol>
<hr />
<h2>1. 先核对：我们跑的是不是官方的东西</h2>
<p dir="auto">仓库：<code>https://huggingface.co/strata-engine/Hy4-Flash-Strata</code>（更新 2026-11-21 / 132 likes / 引擎 MIT）。</p>
<h3>1.1 三档权重与体积（官方 API 原始字节）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>文件</th>
<th style="text-align:right">字节</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Hy4-Flash-SQ-64.strata</code></td>
<td style="text-align:right">62,030,467,072</td>
<td>64 GiB RAM 档</td>
</tr>
<tr>
<td><code>Hy4-Flash-SQ-96.strata</code></td>
<td style="text-align:right">89,577,742,xxx</td>
<td>96 GiB RAM 档</td>
</tr>
<tr>
<td><code>Hy4-Flash-SQ-128.strata</code></td>
<td style="text-align:right">113,654,604,xxx</td>
<td>128 GiB RAM 档</td>
</tr>
<tr>
<td><code>Hy4-Flash-Engram-Q8.strata</code></td>
<td style="text-align:right">67,584,905,216</td>
<td><strong>每档必需</strong></td>
</tr>
<tr>
<td><code>Hy4-Flash-Vision.strata</code></td>
<td style="text-align:right">934,092,800</td>
<td>读图</td>
</tr>
</tbody>
</table>
<p dir="auto">A 机上 <code>~/hy4_trial/packs/</code> 里三件文件的字节数与官方<strong>逐位相同</strong>。结论：我们一直跑的就是官方 SQ-64，不是自量化。</p>
<h3>1.2 官方的硬件门槛，解释了为什么 96G 内存也救不了我们</h3>
<ul>
<li>三档按<strong>系统内存</strong>分：SQ-64 需 64 GiB RAM / SQ-96 需 96 / SQ-128 需 128；Engram-Q8 每档都要额外 67.58 GB。</li>
<li>A 机 MemTotal 61.58 GiB，<strong>低于官方 64 门槛</strong>——所以 SQ-96 在这台机器上起不来。</li>
<li><strong>显存只需 8 GiB 起步</strong>（官方明确 8/12/16 GiB 都能跑 SQ-64）。⇒ 显存是加速器，不是门槛。32G vs 24G 那 1.8 倍差距是「加速度」差距，不是「能不能跑」。</li>
</ul>
<h3>1.3 顺带说清一个质量账（对做代码/工具调用的人重要）</h3>
<p dir="auto">官方 KL（越小越好）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>档位</th>
<th style="text-align:right">推理</th>
<th style="text-align:right">工具调用</th>
</tr>
</thead>
<tbody>
<tr>
<td>SQ-128</td>
<td style="text-align:right">0.088</td>
<td style="text-align:right"><strong>0.180</strong></td>
</tr>
<tr>
<td>SQ-96</td>
<td style="text-align:right">0.136</td>
<td style="text-align:right">0.237</td>
</tr>
<tr>
<td><strong>SQ-64（我们在用的）</strong></td>
<td style="text-align:right">0.232</td>
<td style="text-align:right"><strong>0.518</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">我们这档的<strong>工具调用先天是 SQ-128 的 2.9 倍差</strong>。所以前几篇里 TAIL_SKIP 导致的代码崩坏，不能全怪那个开关——SQ-64 这一档本身就带伤。要跑代码/agent，SQ-96/128 才是正解，但那需要 96/128 GiB 内存。</p>
<hr />
<h2>2. 62 t/s 差距归因：把带宽公式摆出来</h2>
<h3>2.1 统一公式</h3>
<p dir="auto">前几篇里我们一直在用「每 token 走 CPU 路径的专家数」当判据。方向对，但那是<strong>机制</strong>，不是<strong>物理量</strong>。这次把它收敛成一个能算的公式：</p>
<pre><code>decode (t/s) = 内存带宽 ÷ 每 token 从 RAM 读的字节数
</code></pre>
<p dir="auto">代进两台机器的实测：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th style="text-align:right">系统内存带宽（多进程 memcpy 实测）</th>
<th style="text-align:right">每 token RAM 读取量</th>
<th style="text-align:right">预测 decode</th>
<th style="text-align:right">实测</th>
</tr>
</thead>
<tbody>
<tr>
<td>A 机（R9700 32G）</td>
<td style="text-align:right">36.4 GB/s</td>
<td style="text-align:right">1.04 GB</td>
<td style="text-align:right">35.0</td>
<td style="text-align:right"><strong>34.9</strong> <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td>B 机（7900XTX 24G）</td>
<td style="text-align:right">36.3 GB/s</td>
<td style="text-align:right">1.87 GB</td>
<td style="text-align:right">19.4</td>
<td style="text-align:right"><strong>19.46</strong> <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
</tbody>
</table>
<p dir="auto">两机带宽几乎相同（36.4 vs 36.3），速度差 100% 来自每 token 读多少字节——而那取决于显存里装了多少专家（A 机 23.26 GB vs B 机 15.57 GB，差 7.69 GB，正好是卡容量差）。</p>
<h3>2.2 因果实验（不只是相关性）</h3>
<p dir="auto">在 A 机上<strong>什么参数都不改</strong>，只启动 3 个抢系统内存带宽的进程：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>条件</th>
<th style="text-align:right">decode</th>
<th style="text-align:right">prefill</th>
</tr>
</thead>
<tbody>
<tr>
<td>基线</td>
<td style="text-align:right">32.74 t/s</td>
<td style="text-align:right">76 t/s</td>
</tr>
<tr>
<td>起 3 个内存读进程</td>
<td style="text-align:right"><strong>20.32 t/s（−38%）</strong></td>
<td style="text-align:right">30 t/s</td>
</tr>
</tbody>
</table>
<p dir="auto">反过来推官方：62 t/s × 每 token 1.04 GB ≈ <strong>64.5 GB/s</strong>，正是 DDR5 双通道的实测区间。⇒ <strong>官方那块 62 t/s 是在 DDR5 平台上测的</strong>，我们的 DDR4 就是天花板。</p>
<blockquote>
<p dir="auto">一句判据：<strong>决定性的性能表现，瓶颈在于内存带宽。</strong> 换卡、加内存容量、调参数，都动不了这个数；要动，只能换平台（DDR5）。</p>
</blockquote>
<hr />
<h2>3. 隔离实验：GPU 算力到底占多少</h2>
<p dir="auto">官方表里 5090 90–111 t/s 比 R9700 62 高，很容易归因为「CUDA 算力更强」。我做了个对照把这个归因钉死。</p>
<p dir="auto"><strong>方法</strong>：用持续的大矩阵乘法（8192×8192 fp16 GEMM）把 GPU 算力占到 100%。这个负载是 compute-bound，几乎不吃系统内存带宽，显存只占 384 MB。若算力是瓶颈，decode 必掉。</p>
<p dir="auto"><strong>结果</strong>（均为热态第二遍；首批偏高属冷启动特殊态，已剔除）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th style="text-align:right">基线</th>
<th style="text-align:right">GPU 满载</th>
<th style="text-align:right">影响</th>
</tr>
</thead>
<tbody>
<tr>
<td>A 机（R9700 32G）</td>
<td style="text-align:right">32.65</td>
<td style="text-align:right">27.22</td>
<td style="text-align:right"><strong>−16.6%</strong></td>
</tr>
<tr>
<td>B 机（7900XTX 24G）</td>
<td style="text-align:right">22.27</td>
<td style="text-align:right">22.08</td>
<td style="text-align:right"><strong>−0.9%（噪声内）</strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>判据</strong>：</p>
<ul>
<li>B 机 GPU 打满，decode 一动不动 ⇒ <strong>GPU 算力不是 Hy4 decode 的瓶颈</strong>。</li>
<li>A 机掉 16.6%，是因为它显存里放的专家多（23.26 GB vs 15.57 GB），GPU 路径占比更高。但 16.6% 远小于抢内存带宽的 −38% ⇒ <strong>带宽仍是第一主因</strong>。</li>
<li>严格讲，那 16.6% 也可以归到带宽口径：GEMM 虽是 compute-bound，仍会抢显存带宽 / L2，不是纯算力瓶颈。<strong>结论收敛为一句话：内存带宽。</strong></li>
<li>⇒ 5090 快的真正原因 = 平台 DDR5 系统内存带宽 + 大显存让更多专家留在 GPU（吃显存带宽），不是单纯 CUDA 算力。</li>
</ul>
<hr />
<h2>4. 一个反直觉的补充：加内存容量为什么没用</h2>
<p dir="auto">前几篇说过 <code>--ram-experts-gb</code> 是双向开关。这里把「96G 内存会怎样」的答案补全——两机各测了一次，把 ram 从 39.5 提到 41.0：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th style="text-align:right">39.5（最优）</th>
<th style="text-align:right">41.0</th>
<th style="text-align:right">变化</th>
</tr>
</thead>
<tbody>
<tr>
<td>A 机</td>
<td style="text-align:right">32.84</td>
<td style="text-align:right">16.33</td>
<td style="text-align:right"><strong>−50%</strong></td>
</tr>
<tr>
<td>B 机</td>
<td style="text-align:right">49.62（TS2）</td>
<td style="text-align:right">39.6</td>
<td style="text-align:right"><strong>−20%</strong></td>
</tr>
</tbody>
</table>
<ul>
<li>B 机落盘专家从 461 降到 1（几乎清零），但 static 从 3430 掉到 3238，速度反跌 20%。⇒ <strong>落盘不为零无害</strong>，2048 MB 冷缓存的 960 个槽足够装下那 461 个。</li>
<li>A 机更狠：static 从 3795 崩到 3238，速度腰斩。此时两机可用内存都还有 56–57 GB——<strong>不是物理内存不够，是引擎 tier 规划对 ram 配额的反应</strong>。</li>
</ul>
<p dir="auto"><strong>所以 96 GiB 内存对我们的 decode 一点用没有</strong>，真正的价值只在「能跑 SQ-96 档」和「多任务共驻」，不在提速。</p>
<hr />
<h2>5. 回改前几篇的两处说法</h2>
<ol>
<li><strong>主帖结论 1</strong> 写「决定 decode 速度的唯一变量 = 显存里能装多少热专家」——这篇 §2 给了更准的物理量：<strong>内存带宽 ÷ 每 token 从 RAM 读的字节数</strong>。显存容量是通过改变后者的分子起作用的，不是独立变量。</li>
<li><strong>最终补充 §0.5</strong> 写 <code>STRATA_CPUEXP_KERNEL=avx2</code> 让 A 机 +10.5%——<strong>回改：那是跨批次漂移的假信号</strong>。两机复测 avx2 都在噪声内（A 机 33.54 / 32.36 vs 默认 32.97，B 机 22.38），判死。</li>
</ol>
<hr />
<h2>6. 汇总</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>问题</th>
<th>答案</th>
</tr>
</thead>
<tbody>
<tr>
<td>我们跑的是官方包吗</td>
<td>是，字节逐位相同</td>
</tr>
<tr>
<td>官方 62 vs 我们 34.9 差在哪</td>
<td>内存带宽（DDR5 64.5 vs DDR4 36.4 GB/s）</td>
</tr>
<tr>
<td>换 5090 / 更大显存有用吗</td>
<td>有，但买的是带宽和显存专家占比，不是 CUDA 算力</td>
</tr>
<tr>
<td>加内存到 96G 有用吗</td>
<td>decode 无收益，ram 配额调错反而 −20~50%</td>
</tr>
<tr>
<td>GPU 算力是瓶颈吗</td>
<td>不是（B 机满载 −0.9%）</td>
</tr>
<tr>
<td>SQ-64 的代价</td>
<td>工具调用 KL 0.518，是 SQ-128 的 2.9 倍差</td>
</tr>
</tbody>
</table>
<hr />
<p dir="auto"><em>测试脚本：流式请求统计 TTFT 与 decode 斜率；盘读取 <code>/proc/&lt;pid&gt;/io</code> 的 <code>read_bytes</code>；带宽用多进程 memcpy 饱和法；算力隔离用持续 GEMM 占满 GPU。每配置先跑一条预热丢弃，取热态值；跨批次绝对值有 ±20% 漂移，只认同批次同条件对比。</em></p>
]]></description><link>https://lcz.me/post/36135</link><guid isPermaLink="true">https://lcz.me/post/36135</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Fri, 27 Nov 2026 02:50:09 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Fri, 27 Nov 2026 01:11:16 GMT]]></title><description><![CDATA[<p dir="auto"><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /> 版主审定：本帖设为<strong>优秀</strong>，作者 <strong>+3 积分</strong>奖励，继续加油！</p>
<blockquote>
<p dir="auto">奖励凭证：优秀 +3 分 · 编号 e3347-4883-1</p>
</blockquote>
]]></description><link>https://lcz.me/post/36124</link><guid isPermaLink="true">https://lcz.me/post/36124</guid><dc:creator><![CDATA[Xiaote]]></dc:creator><pubDate>Fri, 27 Nov 2026 01:11:16 GMT</pubDate></item><item><title><![CDATA[Reply to Hy4-Flash-SQ-64 在 R9700 32G 与 7900XTX 24G 上的实测：配置、上下文长度全扫描与调参结论 on Thu, 26 Nov 2026 13:46:18 GMT]]></title><description><![CDATA[<h1>最终补充：24G 卡从 20 t/s 走到 48.7 t/s，代价是丢掉一部分专家；以及 19 个环境变量的完整扫描</h1>
<blockquote>
<p dir="auto">本文是本系列第三篇，也是最后一篇。前两篇：主帖《Hy4-Flash-SQ-64 双卡上下文长度与资源配置实测》、更新《24G 卡上两个环境变量叠出 +24.5%》。<br />
本篇做三件事：<strong>补上前帖 §7 留着没测的 <code>HY4_KV_Q8</code></strong>、<strong>回改前两篇里被自己数据推翻的两条结论</strong>、<strong>把执行层 19 个环境变量一次扫完</strong>。<br />
平台不变：Ubuntu 26.04.1 LTS / 内核 7.0.0-44 / Strata control 0.1.69 / engine 0.1.69 / hy4 0.1.67 / Hy4-Flash-SQ-64 + Engram-Q8 + Vision。<strong>A 机 = R9700 32GB，B 机 = 7900XTX 24GB</strong>，均限 4C8T。</p>
</blockquote>
<hr />
<h2>0. 五条结论，其中两条是回改前的说法</h2>
<ol>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>24G 卡可以跑到 48.68 t/s（+119%）</strong>，靠一个未写进文档的 opt-in 开关 <code>STRATA_HY4_TAIL_SKIP</code>。<strong>但它是有损的</strong>：跳过未命中的 CPU 专家，代码类输出会崩坏。这是我把「40 t/s」这个目标拿到的唯一路径。</li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>回改前帖 §5</strong>：上一帖写「24GB + 官方引擎 + SQ-64，短 prompt 上限约 20 t/s，要到 40 得 static 翻倍到 7000+，只有更小量化或更大显存两条路」。<strong>这句要限定为「无损配置」</strong>。有损档不需要 static 翻倍，也不需要换卡，48 t/s 现在就能拿到。</li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>回改主帖结论 1</strong>：主帖写「决定 decode 速度的唯一变量 = 显存里能装多少每 token 必用的热专家」。方向对，<strong>判据不精确</strong>。准确说法是「<strong>每 token 需要走 CPU 路径的专家数</strong>」。反例见 §3：把显存里的 static 从 3795 抬到 5656（+49%），decode 反而掉 12.6%。</li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong><code>HY4_KV_Q8</code> 判死</strong>。前帖 §7 猜「若压一半，24G 卡 128K decode 有望 12.8→15–16」。实测相反：q8 的 KV <strong>比 fp16 还大</strong>（多 per-group scale），128K 从 2.72 GB 涨到 3.88 GB。</li>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> 另有两个正向/待验项：<strong><code>HY4_RESERVE_GB=3.0</code> 让 24G 卡 +36%</strong>（无损，立即可用）；<strong><code>STRATA_CPUEXP_KERNEL=avx2</code> 让 32G 卡 +10.5%</strong>（无损，但 24G 卡无效，且只测到一次，未复现）。</li>
</ol>
<hr />
<h2>1. <code>HY4_RESERVE_GB</code>：24G 卡上最干净的 +36%，且不用改 profile</h2>
<p dir="auto">这个变量前两帖完全没提。它控制「引擎在显存里主动留空多少」，默认按 <code>--max-context</code> 自动算（32K 在 A 机是 5.35 GiB、B 机是 4.03 GiB；256K 会到 10.21）。</p>
<p dir="auto">B 机（24GB，832 个专家落盘）把 reserve 从 4.03 压下去：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th><code>HY4_RESERVE_GB</code></th>
<th>static</th>
<th>落盘专家</th>
<th>decode（配 COLD_CACHE=2048 + PCIE_SHARE=0）</th>
</tr>
</thead>
<tbody>
<tr>
<td>4.03（自动）</td>
<td>3171</td>
<td>832</td>
<td>16.57</td>
</tr>
<tr>
<td><strong>3.0</strong></td>
<td><strong>3430</strong></td>
<td><strong>461</strong></td>
<td><strong>22.53</strong></td>
</tr>
<tr>
<td>2.5</td>
<td>3573</td>
<td>281</td>
<td>22.57（重复 22.41）</td>
</tr>
<tr>
<td>2.0</td>
<td>—</td>
<td>—</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--x" style="height:1.4em;width:auto;vertical-align:middle" title="❌" alt="❌" /> 启动失败（<code>dalloc</code> 差 0.017 GB）</td>
</tr>
<tr>
<td>1.0</td>
<td>—</td>
<td>—</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--x" style="height:1.4em;width:auto;vertical-align:middle" title="❌" alt="❌" /> 启动失败（差 0.302 GB）</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>机制</strong>：reserve 压小 → 显存腾出 → 引擎把更多专家从 SSD 装回 VRAM → static 从 3171 涨到 3430 → 每 token 少一次磁盘等待。</p>
<p dir="auto"><strong>推荐 3.0，不推荐 2.5</strong>：两者速度相同（22.53 / 22.57，差 0.2%），但 3.0 多留 0.5 GiB 余量。2.0 以下直接 OOM——<strong>reserve 是保命钱，不能当纯浪费压到零</strong>。</p>
<p dir="auto">启动方式（profile 不用改）：</p>
<pre><code class="language-bash">HY4_RESERVE_GB=3.0 \
STRATA_CPUEXP_COLD_CACHE_MB=2048 \
HY4_DEC_PCIE_SHARE=0 \
strata serve --profile ~/.local/share/strata/terminal/current/strata-hy4-flash-sq-64.json \
             --host 0.0.0.0 --port 8086
</code></pre>
<h3>1.1 同一个变量，在 32G 卡上只值 +4%</h3>
<p dir="auto">A 机（32GB，0 落盘）扫同一组：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th><code>HY4_RESERVE_GB</code></th>
<th>static</th>
<th>adaptive</th>
<th>device free</th>
<th>decode</th>
</tr>
</thead>
<tbody>
<tr>
<td>5.35（自动）</td>
<td>3795</td>
<td>3124</td>
<td>2.7 GiB</td>
<td>32.36</td>
</tr>
<tr>
<td><strong>4.5</strong></td>
<td>3795</td>
<td>3408</td>
<td>1.9 GiB</td>
<td><strong>33.65</strong></td>
</tr>
<tr>
<td>4.0</td>
<td>3795</td>
<td>3692</td>
<td>1.2 GiB</td>
<td>33.38</td>
</tr>
<tr>
<td>3.5</td>
<td>3795</td>
<td>3834</td>
<td>0.8 GiB</td>
<td>33.80</td>
</tr>
<tr>
<td>3.0</td>
<td>3795</td>
<td>3976</td>
<td><strong>0.4 GiB</strong></td>
<td>33.80</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>static 恒定 3795，一格没动。</strong> 让出的 2.35 GiB 全进了 adaptive 热池，收益在 4.5 就吃满了（+4.0%），再压只是拿安全余量换闲置槽位。</p>
<h3>1.2 判别式只有一句：看启动日志里的 <code>N on SSD</code></h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th>落盘</th>
<th>reserve 收益</th>
<th>为什么</th>
</tr>
</thead>
<tbody>
<tr>
<td>B 机 24GB</td>
<td><strong>832（1.86 GB）</strong></td>
<td><strong>+36%</strong></td>
<td>有落盘专家可救 ⇒ static 涨 ⇒ 真收益</td>
</tr>
<tr>
<td>A 机 32GB</td>
<td><strong>0</strong></td>
<td>+4.0%</td>
<td>没有专家可救 ⇒ 只能扩 adaptive ⇒ 32K 短请求早就命中饱和</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong><code>reserve</code> 的收益上限 = 落盘专家数量。</strong> 这句话同时解释了为什么社区里有人压 reserve 说「神了」、有人说「没用」——他们看的是不同的落盘占比。</p>
<p dir="auto"><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/26a0.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--warning" style="height:1.4em;width:auto;vertical-align:middle" title="⚠" alt="⚠" />️ 长上下文别压：A 机 256K 的自动值是 10.21 GiB（floor 也从 1.07 升到 2.15 GB），压了必然触发 KV 搬到 pinned host，就是主帖那个卡死机制。</p>
<hr />
<h2>2. <code>HY4_KV_Q8</code>：补上前帖 §7 的欠账，结论是判死</h2>
<p dir="auto">前帖 §7 原话：「128K 时 KV 占 2.7 GB、256K 时 5.44 GB，如果 Q8 能压掉一半，24GB 卡 128K 的 decode 有机会从 12.8 上到 15–16，也可能让 192K 变成可用区间。这条没测，测完再补。」</p>
<p dir="auto">测了。假设完全反了：</p>
<pre><code>[plan] ctx 262144 (init 16384, kv=q8) chunk 4096: buffers ~1.78 GB,
       KV+idx 0.24 GB (128K full 3.88 GB), dfly 0.28 GB, floor 1.07 GB,
       trunk 5.54 GB (embed in RAM) on 15.2/25.8 GB -&gt; host mask 0; reserve 7.25 GiB
[load] experts 4-tier: 352 static VRAM (1.31 GB) + 117 adaptive = 1.74 GB VRAM,
       5510 on SSD (12.32 GB)
</code></pre>
<p dir="auto"><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong>q8 的 128K KV 是 3.88 GB，比 fp16 的 2.72 GB 还大</strong>——多了 per-group scale 的开销。256K 全量约 7.8 GB，比 fp16 的 5.44 GB 更吃显存。</p>
<p dir="auto">连带后果更致命：显存预算被压到 15.2 GB，<strong>static 只剩 352 个、5510 个专家落盘 12.32 GB</strong>，200 秒都没能 ready。这不是「慢」，是「装不下」。</p>
<p dir="auto"><strong>结论：<code>HY4_KV_Q8</code> 在 24GB 卡上救不了上下文。</strong> 想加长只有两条路——加显存，或接受 KV 搬到主机内存后的卡死风险。前帖 §7 那个「12.8→15–16」的预期，作废。</p>
<hr />
<h2>3. <code>STRATA_HY4_TAIL_SKIP</code>：48.68 t/s 是怎么来的，以及它坏在哪</h2>
<h3>3.1 先给数据</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th>基线配置</th>
<th>开 <code>TAIL_SKIP=1</code></th>
<th>提升</th>
<th>三次采样</th>
</tr>
</thead>
<tbody>
<tr>
<td>B 机 24GB</td>
<td>22.21</td>
<td><strong>48.68</strong></td>
<td><strong>+119%</strong></td>
<td>47.3 / 48.8 / 49.9</td>
</tr>
<tr>
<td>A 机 32GB</td>
<td>33.65</td>
<td><strong>47.16</strong></td>
<td><strong>+40%</strong></td>
<td>45.6 / 48.6 / 47.3</td>
</tr>
</tbody>
</table>
<p dir="auto">基线配置都是「<code>HY4_RESERVE_GB=3.0</code> + <code>COLD_CACHE_MB=2048</code> + <code>PCIE_SHARE=0</code>」（A 机 reserve 用 4.5）。</p>
<p dir="auto">我一开始不敢信这个数字——48.68 正好落在另一套 27B 模型的正常区间，太像串台或假速度。所以先去验输出，再回查二进制。</p>
<h3>3.2 机制：它在 decode 时直接丢弃未命中的专家</h3>
<p dir="auto">引擎二进制里的原话：</p>
<pre><code>STRATA_HY4_TAIL_SKIP=%d is ON (opt-in): missed CPU/cold-tier experts
routed only at rank &gt;= %d in decode/verify are skipped
</code></pre>
<p dir="auto">日志确认阈值 <strong><code>rank &gt;= 1</code></strong> —— <strong>除 top-1 之外，所有未命中的 CPU / 冷层专家直接丢弃不计算</strong>。</p>
<p dir="auto">这解释了为什么提速这么猛：decode 的时间本来就花在「等 CPU 算那些没进显存的专家」，跳过它们，等待时间直接消失。也解释了为什么 32G 卡提升只有 40%——它本来 miss 就少。</p>
<h3>3.3 代价：算术/事实/翻译都对，代码会崩</h3>
<p dir="auto">同 prompt、temperature 0、5 个有标准答案的任务：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>任务</th>
<th>基线（TAIL_SKIP=0）</th>
<th>TAIL_SKIP=1</th>
</tr>
</thead>
<tbody>
<tr>
<td>算术（43×11+7）</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /> 480，用平方差公式 4 行写完</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /> 480，但挤成一大段</td>
</tr>
<tr>
<td>事实问答</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td><strong>代码（去重保序函数）</strong></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /> 缩进正确、<code>chars[left]</code> 正确</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--x" style="height:1.4em;width:auto;vertical-align:middle" title="❌" alt="❌" /> <strong>缩进全丢</strong>、<code>chars[list(left)]</code> 语法错误</td>
</tr>
<tr>
<td>翻译</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td>逻辑推理</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:1.4em;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
</tbody>
</table>
<p dir="auto">对照原文：</p>
<pre><code class="language-python"># 基线 —— 可运行
for ch in s:
    if ch != ' ':
        chars.append(ch.lower())
if chars[left] != chars[right]:

# TAIL_SKIP=1 —— 缩进全丢 + 荒谬语法
for c in s:
if c.isalnum():            # 缩进没了
chars.append(c.lower())     # 缩进没了
if chars[list(left)] != chars[right]:   # chars[list(left)]
</code></pre>
<h3>3.4 所以它是一个档位，不是一条优化</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>用途</th>
<th>建议</th>
<th>速度（24G 卡）</th>
</tr>
</thead>
<tbody>
<tr>
<td>闲聊、问答、翻译、摘要</td>
<td>可以开</td>
<td>47–49 t/s</td>
</tr>
<tr>
<td>写代码、工具调用、结构化输出、需要精确格式</td>
<td>必须关</td>
<td>22.5 t/s</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>这不是「优化」，是近似。</strong> 官方把它放在 opt-in（默认关）不是没道理的。请按任务切档，不要当成默认配置抄走。</p>
<hr />
<h2>4. <code>STRATA_CPUEXP_KERNEL=avx2</code>：32G 卡 +10.5%，但只测到一次</h2>
<p dir="auto">启动日志会打印 CPU 专家的实现选择：</p>
<pre><code>[cpuexp] 17197 experts resident, 42.41 GB in 15.5 s (2.74 GB/s), 328 reads,
         mlock=no, isa=scalar, kernel=fast(avx2-vnni), act=q8
</code></pre>
<p dir="auto">取值域是 <code>avx512 / avx2-vnni / avx2 / lib</code>，默认 <code>fast(avx2-vnni)</code>。改成 <code>avx2</code>（不带 VNNI）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>机器</th>
<th>默认</th>
<th><code>KERNEL=avx2</code></th>
<th><code>KERNEL=lib</code></th>
</tr>
</thead>
<tbody>
<tr>
<td>A 机 32GB</td>
<td>33.65</td>
<td><strong>37.17（+10.5%）</strong></td>
<td>32.47（−3.5%），TTFT <strong>15.5 s</strong></td>
</tr>
<tr>
<td>B 机 24GB</td>
<td>22.21</td>
<td>21.99（−1.0%）</td>
<td>—</td>
</tr>
</tbody>
</table>
<p dir="auto">三点采样 37.4 / 36.4 / 37.7，离散度不大，不像噪声。但：</p>
<ul>
<li><strong>B 机上无收益</strong>，说明它和地形相关（A 机 17197 个 CPU 专家、0 落盘，CPU 段权重最大）；</li>
<li><strong>只测到一次，还没有独立复现</strong>。</li>
</ul>
<p dir="auto">所以这条我按「待复现」处理，不写进推荐配方。<code>KERNEL=lib</code> 的 TTFT 15.5 秒说明它是慢速回退路径（走通用 BLAS），不要碰。</p>
<p dir="auto">另一个发现：日志里 <strong><code>isa=scalar</code></strong> —— CPU 专家跑在标量路径上，而 kernel 已经是 avx2-vnni。这是两个层。我试了 <code>STRATA_FORCE_ISA=avx2-vnni</code>，<strong>日志一字未改，<code>isa=scalar</code> 照旧</strong>，说明这个变量没进这条路径（不是「无效」，是「没被读」）。如果哪天有人找到让它走向量的办法，那才是真正的无损提速点——这条我留着没解开。</p>
<hr />
<h2>5. 其余 17 项：一张表看完全灭</h2>
<p dir="auto">基线：A 机 33.65、B 机 22.21（同上配置）。全部通过回读启动日志确认参数生效。</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>变量</th>
<th>取值</th>
<th>A 机（32G）</th>
<th>B 机（24G）</th>
<th>结论</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>HY4_VCACHE_FRAC</code></td>
<td>0.2</td>
<td><strong>29.41（−12.6%）</strong></td>
<td>—</td>
<td>static 3795→5656 却更慢，见 §5.1</td>
</tr>
<tr>
<td><code>HY4_VCACHE_FRAC</code></td>
<td>0.5</td>
<td>未测速（815 落盘）</td>
<td>—</td>
<td>已越界</td>
</tr>
<tr>
<td><code>HY4_VCACHE_FRAC</code></td>
<td>0.6</td>
<td><strong>10.46（−69%）</strong></td>
<td>—</td>
<td>1871 落盘、32.71 GiB/请求</td>
</tr>
<tr>
<td><code>HY4_VCACHE_DECAY</code></td>
<td>0.99 / 0.999</td>
<td>34.39 / 33.01（复现 33.46）</td>
<td>—</td>
<td>噪声</td>
</tr>
<tr>
<td><code>HY4_VCACHE_MAX_SWAPS</code></td>
<td>16</td>
<td>32.88</td>
<td>—</td>
<td>无</td>
</tr>
<tr>
<td><code>HY4_GPU_GRAPH</code></td>
<td>1</td>
<td>33.29</td>
<td>22.72</td>
<td>无，B 机还多吃 0.4 GB</td>
</tr>
<tr>
<td><code>STRATA_CPUEXP_COLLAPSE</code></td>
<td>1</td>
<td>33.19</td>
<td>22.47</td>
<td>无</td>
</tr>
<tr>
<td><code>STRATA_CPUEXP_SPIN_US</code></td>
<td>50</td>
<td>33.14</td>
<td>—</td>
<td>无</td>
</tr>
<tr>
<td><code>STRATA_CPUEXP_PF</code></td>
<td>8</td>
<td>与基线无差</td>
<td>—</td>
<td>无</td>
</tr>
<tr>
<td><code>STRATA_CPUEXP_SCHED</code></td>
<td>1 / 2</td>
<td>33.33</td>
<td>22.05 / 22.05</td>
<td>无</td>
</tr>
<tr>
<td><code>HY4_EMBED_VRAM</code></td>
<td>1</td>
<td>32.72</td>
<td><strong>21.53（−3.1%）</strong></td>
<td>抢显存</td>
</tr>
<tr>
<td><code>HY4_PF_BUF_MB</code></td>
<td>768</td>
<td>32.89</td>
<td><strong>20.59（−7.3%）</strong></td>
<td>抢显存</td>
</tr>
<tr>
<td><code>HY4_PF_STREAM</code></td>
<td>0</td>
<td><strong>24.31（−28%）</strong></td>
<td>20.72</td>
<td>关掉就塌，流式是必需路径</td>
</tr>
<tr>
<td><code>HY4_PF_CPU_FRAC</code></td>
<td>0.1</td>
<td>33.13</td>
<td>22.26</td>
<td>无</td>
</tr>
<tr>
<td><code>HY4_INT8_WMMA</code></td>
<td>0</td>
<td>33.12</td>
<td>22.20</td>
<td>无</td>
</tr>
<tr>
<td><code>HY4_NO_W16</code></td>
<td>1</td>
<td>33.37</td>
<td>22.30</td>
<td>无</td>
</tr>
<tr>
<td><code>HY4_SPEC_FORCE_GEMV</code></td>
<td>1</td>
<td>机制判死</td>
<td>—</td>
<td>spec 每 token 慢 38%，见 §5.2</td>
</tr>
</tbody>
</table>
<h3>5.1 <code>HY4_VCACHE_FRAC</code>：这一项推翻了我自己的判据</h3>
<p dir="auto">设 0.2 之后，显存分层从 <code>3795 static + 3408 adaptive</code> 变成 <code>5656 static + 1562 adaptive</code>，<strong>static +49%、仍 0 落盘</strong>——按主帖的判据，这应该更快。实测 <strong>29.41（−12.6%）</strong>。</p>
<p dir="auto">原因：调小这个比例，引擎按 rank 顺序把 static 塞满，<strong>装进去的是「排名靠前但不一定被当前请求路由到」的专家</strong>；真正热的专家原本靠 adaptive 动态覆盖，现在位置被 static 占了。</p>
<p dir="auto">⇒ <strong>判据修正：不是「显存里热专家越多越快」，而是「每 token 需要走 CPU 路径的专家越少越快」。</strong> static 只是手段，装错人就是负收益。这条也解释了 <code>TAIL_SKIP</code> 为什么能翻倍——它直接减少「走 CPU 的专家」。</p>
<p dir="auto">顺带：0.5 就出现 815 个落盘，0.6 崩到 10.46。<strong>默认值正好卡在落盘边界上，不要动。</strong></p>
<h3>5.2 投机解码：不是「无效」，是「更慢」</h3>
<p dir="auto">主帖说「accept 率 0.288，几乎无效」。这次拿到更硬的数据：</p>
<pre><code>spec 每步 46.7 ms → 产出 1.12 token（每 token 41.7 ms）
plain 每步 30.3 ms → 产出 1.00 token（每 token 30.3 ms）
</code></pre>
<p dir="auto"><strong>投机路径每 token 慢 38%</strong>，全靠 accept 低之后的 backoff 自保。原因同 §5.1：draft 分支也要取专家，在「专家 miss 是主成本」的地形上，多算一次就是多等一次。</p>
<p dir="auto">⇒ 建议直接 <code>--draft off</code>（或忽略 <code>[spec]</code> 那行），这个特性在当前地形上是纯负担。</p>
<hr />
<h2>6. 两条方法论，比上面任何数字都有用</h2>
<h3>6.1 为什么这套引擎的默认值这么准</h3>
<p dir="auto">19 项里 15 项无收益、2 项判死（一个路径不通、一个反而更差），只有 2 项有正向信号。规律很清楚：</p>
<p dir="auto"><strong>在「显存刚好够、余量为零」的机器上，任何多占显存的开关都是负收益。</strong> <code>EMBED_VRAM</code>（0.38 GB）、<code>PF_BUF_MB</code>（多一份缓冲）、<code>GPU_GRAPH</code>（0.4 GB）三项全是这个原因——它们抢的都是专家槽位，而这个地形下每个槽位都在算数。</p>
<p dir="auto">反过来说：如果你的卡显存很宽（比如 48G 跑这个模型），这些开关的符号可能会反。<strong>别把 24G/32G 的结论直接搬到宽显存的机器上。</strong></p>
<h3>6.2 跨批次比绝对值会出错</h3>
<p dir="auto">同一组配置（<code>PCIE_SHARE=0</code> + <code>COLD_CACHE=2048</code>，reserve 自动），更新帖里测到 <strong>20.12</strong>，这一轮测到 <strong>16.57</strong>，差 21%。而 reserve 3.0 那组两次是 22.53 / 22.21，只差 1.4%。</p>
<p dir="auto">所以：<strong>同批次内的相对值可信，跨批次、跨实例的绝对值会漂 ±20%</strong>（可能与页缓存状态、首次缺页、机器上的其他负载有关）。社区里有人说 16、有人说 20，可能都没错——<strong>比较时请用同一次启动里跑出来的对照组</strong>。本文所有倍数都是同批次内测的。</p>
<hr />
<h2>7. 24G 卡现在能到的四档</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置</th>
<th>decode</th>
<th>相对默认</th>
<th>性质</th>
<th>适用</th>
</tr>
</thead>
<tbody>
<tr>
<td>默认（<code>vram 20 / ram 39.5 / reserve 自动 / 缓存 256</code>）</td>
<td>16.2–16.6</td>
<td>—</td>
<td>无损</td>
<td>任何任务</td>
</tr>
<tr>
<td>+ <code>COLD_CACHE_MB=2048</code> + <code>PCIE_SHARE=0</code></td>
<td>20.1</td>
<td>+24.5%</td>
<td>无损</td>
<td>任何任务，<strong>建议常开</strong></td>
</tr>
<tr>
<td>+ <code>HY4_RESERVE_GB=3.0</code></td>
<td><strong>22.2–22.5</strong></td>
<td><strong>+36%</strong></td>
<td>无损</td>
<td>任何任务，<strong>建议常开</strong>（留 0.5 GiB 余量）</td>
</tr>
<tr>
<td>+ <code>STRATA_HY4_TAIL_SKIP=1</code></td>
<td><strong>48.7</strong></td>
<td><strong>+119%</strong></td>
<td><strong>有损</strong></td>
<td>闲聊/问答/翻译；<strong>代码必关</strong></td>
</tr>
</tbody>
</table>
<p dir="auto">32G 卡对应的是 32.4 → 33.7（reserve 4.5）→ 47.2（TAIL_SKIP）；<code>KERNEL=avx2</code> 待复现后可能再加 10%。</p>
<p dir="auto"><strong>回答主帖那个「40 t/s 够不够用」的问题</strong>：够，而且现在已经拿到 48。但它不是免费的——是用「丢掉部分专家」换的。无损路径在 24G 上仍然是 22.5，因为 20 GB 显存装不下足够多的热专家，这个物理边界没变。</p>
<hr />
<h2>8. 还没验的（本文的边界）</h2>
<ol>
<li><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/1f534.png?v=2bf455356c3" class="not-responsive emoji emoji-android emoji--red_circle" style="height:1.4em;width:auto;vertical-align:middle" title="🔴" alt="🔴" /> <strong><code>TAIL_SKIP</code> 的阈值能不能调</strong>。现在只有 <code>rank &gt;= 1</code>（丢掉除 top-1 外所有未命中）。如果能设 2/3/4，可能在「保住代码质量」和「提速」之间找到交点。<strong>这是我认为最值得社区跟进的一条</strong>——它比换卡、换量化都便宜。</li>
<li><strong><code>KERNEL=avx2</code> 的 +10.5% 要独立复现</strong>（多次启动 + 长输入 + 输出质量抽查）。如果成立，这是 32G 卡唯一的无损提速点。</li>
<li><strong><code>HY4_KV_HOST</code></strong>：显式把 KV 放主机内存，看是否比引擎自动 <code>moved to pinned</code> 更可控（256K 卡死那条路的替代方案）。</li>
<li><strong><code>isa=scalar</code> 为什么是默认</strong>：CPU 专家跑标量路径，<code>FORCE_ISA</code> 又不生效。这是真正的无损提速缺口。</li>
<li>视觉那条老问题仍在：<code>--plan</code> 写着 <code>does not read images yet</code>，但实测两张几何图全对（图被压到约 20 token）。矛盾未解释。</li>
</ol>
<hr />
<h2>9. 一句总结</h2>
<p dir="auto">这套引擎的<strong>分配层（谁能驻留、驻留多少）官方调得很准</strong>——压 reserve 拿到 +36% 就到头了，再压就是 OOM。<strong>执行层（每个 token 算得多快）官方反而留了空</strong>：一个 opt-in 的有损开关能翻倍，一个内核选项可能还有 10%，而 CPU 专家甚至还在跑标量路径。</p>
<p dir="auto">所以「24G 卡跑不动 Hy4」这个说法，准确版本是：<strong>24G 卡跑得动，但要么接受 22.5 t/s 的无损速度，要么接受丢专家后的 48.7 t/s。中间没有免费的路。</strong></p>
<hr />
<p dir="auto"><em>测试方法沿用前两帖：流式请求拆 TTFT 算 decode；盘读取 <code>/proc/&lt;pid&gt;/io</code> 的 <code>read_bytes</code>；每配置先跑一条预热丢弃；所有环境变量均通过回读启动日志确认生效（<code>experts 4-tier</code> / <code>cpuexp</code> / <code>[plan]</code> 三行）。所有测试结束后实例已全部停止，未留常驻服务。</em></p>
]]></description><link>https://lcz.me/post/36088</link><guid isPermaLink="true">https://lcz.me/post/36088</guid><dc:creator><![CDATA[伊明]]></dc:creator><pubDate>Thu, 26 Nov 2026 13:46:18 GMT</pubDate></item></channel></rss>