<?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[整活：8GB显存也要跑agent]]></title><description><![CDATA[<p dir="auto">RTX 5060 8GB 上跑 Ternary Bonsai 2 27B：40K 上下文 + MTP，agent 任务全套跑通。</p>
<p dir="auto">折腾了几天，把实测数据和踩坑记录整理一下，都是 8GB 卡上的真实数字。最大的感受：</p>
<blockquote>
<p dir="auto"><strong>8GB 上卡你的不是解码速度，是上下文。</strong></p>
</blockquote>
<p dir="auto"><code>-c</code> 从 32768 提到 40960，agent 类任务就从"全部撞墙"变成"全部跑通"。差这 8K，<br />
就是能干活和不能干活的分界。</p>
<p dir="auto">仓库（预编译二进制 + 完整配方 + 编译踩坑）：<br />
<strong><a href="https://github.com/snailium/bonsai2-8gb" rel="nofollow ugc">https://github.com/snailium/bonsai2-8gb</a></strong></p>
<hr />
<h2>一、模型背景：Ternary Bonsai 2 27B 是什么</h2>
<p dir="auto">先说清楚这是个什么东西，不然下面的数字没有参照。</p>
<p dir="auto"><strong>一句话</strong>：Qwen3.8-27B 的三值量化版。权重被压到 <strong>{−1, 0, +1}</strong> 三个值（1.58-bit 那一类做法），<br />
配合 group size 128 的缩放因子，实际是 <strong>1.75 bpw</strong>。</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>基座</td>
<td>Qwen3.8-27B（阿里，Apache 2.0）</td>
</tr>
<tr>
<td>量化</td>
<td>三值 {−1,0,+1}，g128，<strong>1.75 bpw</strong>（PTQ1_0）</td>
</tr>
<tr>
<td>发布方</td>
<td>PrismML</td>
</tr>
<tr>
<td>体积</td>
<td><strong>5.54 GiB</strong>（原始 PTQ1_0）/ 5.87 GiB（带 MTP 头的 lean 版）</td>
</tr>
<tr>
<td>架构特点</td>
<td><strong>混合注意力</strong>：64 层里只有 16 层是 full attention，其余 48 层是 linear attention</td>
</tr>
<tr>
<td>上下文</td>
<td>原生 262,144</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>为什么 8GB 能塞下 27B</strong>：就是靠 1.75 bpw。同一个基座，常规量化的体积对比：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>量化</th>
<th style="text-align:right">体积</th>
<th>8GB 能装?</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Bonsai 2 PTQ1_0（三值）</strong></td>
<td style="text-align:right"><strong>5.54 GiB</strong></td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td>Unsloth UD-IQ1_S</td>
<td style="text-align:right">5.77 GiB</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td>Unsloth UD-IQ2_XXS</td>
<td style="text-align:right">6.77 GiB</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td>Unsloth UD-Q2_K_XL</td>
<td style="text-align:right">9.15 GiB</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /></td>
</tr>
<tr>
<td>Unsloth UD-Q4_K_M</td>
<td style="text-align:right">15.33 GiB</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /></td>
</tr>
</tbody>
</table>
<p dir="auto">也就是说：<strong>同一个 27B，4-bit 量化是 15.33 GiB，8GB 的卡连边都摸不到。</strong><br />
能跑起来完全是三值量化的功劳。</p>
<p dir="auto"><strong>那个"只有 16 层是 full attention"很关键</strong>：KV cache 只在这 16 层上产生，<br />
所以 KV 的增长比同规模的稠密模型小得多——这是能用 q4_0 量化 KV 开到 40K 的前提。</p>
<h3>一个必须知道的坑：不能换 stock llama.cpp</h3>
<p dir="auto">三值量化需要<strong>旋转过的权重基底</strong>（Hadamard 变换），这些在 mainline llama.cpp 里<br />
<strong>完全没有</strong>（PrismML 的三值类型是 fork 独有的；有人提过 Q2_0 的移植 PR，<br />
2026-07 关掉了没合）。</p>
<p dir="auto">后果：</p>
<ul>
<li>stock llama.cpp <strong>直接拒绝加载 PTQ1_0 / PQ2_0</strong></li>
<li>更坑的是旧版 <code>Q2_0</code> 文件<strong>能加载但不报错，输出是乱码</strong></li>
</ul>
<p dir="auto">所以必须用 PrismML 那条 fork 线（我们用的是 <code>sudoingX/llama.cpp</code> 的 <code>bonsai2</code> 分支，<br />
在 PrismML fork 基础上叠了三个还没合入的 PR）。模型卡上也写了这一点。</p>
<h3>MTP 是什么，为什么要它</h3>
<p dir="auto">Qwen3.8-27B 自带一个 <strong>nextn 头</strong>（多 token 预测），可以拿来做投机解码：<br />
草稿头一次猜几个 token，主干批量验证。</p>
<p dir="auto">8GB 上要它的理由有两层：</p>
<ol>
<li><strong>提速</strong>：短 prompt 下 decode 从 54 提到 65–73 tok/s，接受率 0.85 左右</li>
<li><strong>更重要的：MTP 会影响显存布局</strong>。这个我们踩坑了——<strong>关掉 MTP 反而没法用</strong><br />
（见下面"坑 2"）</li>
</ol>
<p dir="auto">另外 MTP 头有两种装法：单独一个 sidecar 文件，或者<strong>嫁接进同一个 GGUF</strong>（作为 <code>blk.64</code>）。<br />
单独装会<strong>重复一份词表 embedding</strong>，代价可以直接从文件大小看出来：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>文件</th>
<th>大小</th>
</tr>
</thead>
<tbody>
<tr>
<td>原版 PTQ1_0</td>
<td>5,946,648,928 B（5.54 GiB）</td>
</tr>
<tr>
<td>mtp-lean（MTP 头 + 复用已有 embedding）</td>
<td>6,297,658,848 B（5.87 GiB）</td>
</tr>
<tr>
<td>mtp fat（MTP 头 + 自带一份 embedding 副本）</td>
<td>7,012,820,512 B（6.53 GiB）</td>
</tr>
</tbody>
</table>
<p dir="auto"><code>fat − lean</code> = <strong>682 MiB</strong>，就是那份重复的 embedding；<code>lean − orig</code> = <strong>335 MiB</strong>，<br />
是 MTP 头本身。<strong>8GB 的卡上 682 MiB 很值钱</strong>，所以我们用 lean 版。</p>
<p dir="auto">（代价：lean 版需要 build 里有 Hadamard 修复，也就是 <code>bonsai2</code> 分支带的那几个 PR。<br />
官方预编译的 release 二进制起不来 draft 图。）</p>
<hr />
<h2>二、平台</h2>
<pre><code>GPU      RTX 5060 8GB     8151 MiB - 447 driver reserved = 7704 可用
         sm_120 (Blackwell) —— 不是 Ampere/Ada，坑不太一样
模型      Ternary-Bonsai-2-27B-PTQ1_0-mtp-lean.gguf   5.87 GiB
后端      sudoingX/llama.cpp  branch bonsai2 @ dcc3be7
          (含 #218 专用 mat-vec + #217/#205 Hadamard 修复 + #220 GDN gather)
</code></pre>
<h2>三、启动参数，逐条说一下为什么</h2>
<pre><code>GGML_CUDA_BATCH_INVARIANT=1

llama-server \
  -m Ternary-Bonsai-2-27B-PTQ1_0-mtp-lean.gguf \
  -ngl 99 -fa on -np 1 \
  -c 40960 \
  -ctk q4_0 -ctv q4_0 --kv-mean-center kv-mean-center.gguf \
  --spec-type draft-mtp --spec-draft-n-max 1 \
  --reasoning-effort low --reasoning-budget 4096 \
  --jinja \
  --temp 0.7 --top-p 0.80 --top-k 20 --presence-penalty 1.5
</code></pre>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>参数</th>
<th>为什么这么设</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-c 40960</code></td>
<td><strong>这是本文的重点。</strong> 带 MTP 时能加载的最大值，用满 7508 MiB。32K 不够跑 agent 任务，49K 直接 cudaMalloc 失败</td>
</tr>
<tr>
<td><code>-ctk q4_0 -ctv q4_0</code></td>
<td>不加这个 40K 装不下。KV 量化是能开到 40K 的前提</td>
</tr>
<tr>
<td><code>--kv-mean-center</code></td>
<td><strong>q4_0 的必需配套</strong>。它给 K cache 做均值居中校准，找回量化丢掉的精度。注意这个文件必须用<strong>相同的 cache 设置</strong>（<code>-fa on -ctk q4_0</code>）生成，否则服务端会拒绝加载——这是它有意的安全检查</td>
</tr>
<tr>
<td><code>--spec-type draft-mtp --spec-draft-n-max 1</code></td>
<td>MTP 投机解码。<strong>n-max 设 1 而不是 2/3</strong>：我们在自己卡上扫过，acceptance 随 n-max 单调下降（0.85 → 0.76 → 0.67），速度并不单调，1 最稳。另外 n-max 越大，MTP 的 compute buffer 越占显存，直接挤压上下文</td>
</tr>
<tr>
<td><code>GGML_CUDA_BATCH_INVARIANT=1</code></td>
<td>让"单发解码"和"投机 batch 内验证"的 logits 逐位一致，<strong>MTP 严格无损</strong>。不加的话批量验证会改变浮点累加顺序，近似解会不一致</td>
</tr>
<tr>
<td><code>-fa on</code></td>
<td>flash attention，配合 q4_0 KV</td>
</tr>
<tr>
<td><code>-np 1</code></td>
<td>MTP 要求单 slot</td>
</tr>
<tr>
<td><code>--reasoning-effort low --reasoning-budget 4096</code></td>
<td>agent 任务用。<code>low</code> 让模型思考简短聚焦，4096 是服务端硬截断思考的预算（实测精确停在 2064–2070 tokens）。<strong>纯生成任务（写文档）直接 <code>--reasoning off</code> 更省</strong>——没有规划阶段，思考只是抢输出的 token</td>
</tr>
<tr>
<td><code>--temp 0.7 --top-p 0.80 --presence-penalty 1.5</code></td>
<td>量化模型容易复读。<strong><code>presence-penalty</code> 是关键</strong>——它的默认是 0.0，在这个模型上会出复读循环（我们实测过一次 1898 轮重复，正文出不来），1.5 正好。Unsloth 的模型卡也是这么建议的</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>显存占用</strong>：7508 MiB used / 198 free。</p>
<h2>四、实测</h2>
<p dir="auto"><code>llama-bench tg128</code>：<strong>54.31 tok/s</strong>（官方 release 二进制同卡 39.56 → <strong>+37%</strong>）。</p>
<p dir="auto">短 prompt 服务端解码：code 70.7 / bash 68.9 / prose 64.6 tok/s，MTP 接受率 0.85 / 0.78 / 0.67。</p>
<p dir="auto">40960 上下文下跑一整套 agent 任务：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>任务</th>
<th>thinking</th>
<th>结果</th>
<th>decode</th>
</tr>
</thead>
<tbody>
<tr>
<td>生成单页 HTML</td>
<td>off</td>
<td>PASS</td>
<td>65.9 tok/s</td>
</tr>
<tr>
<td>生成 SVG</td>
<td>off</td>
<td>PASS</td>
<td>67.4 tok/s</td>
</tr>
<tr>
<td>27 文件安全审计（31 次工具调用）</td>
<td>low + budget 4096</td>
<td>PASS</td>
<td>38.7 tok/s</td>
</tr>
<tr>
<td>采集主机配置</td>
<td>low + budget 4096</td>
<td>PASS</td>
<td>45.1 tok/s</td>
</tr>
<tr>
<td>多源检索计算（46 次工具调用）</td>
<td>low + budget 4096</td>
<td>PASS</td>
<td>33.8 tok/s</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>同样的配置在 32K 下，后两个任务全部撞墙</strong>：研究任务每轮要 7–25 次 compaction<br />
（其中 1–4 次失败，报 <code>summary is not smaller than the shadowed content</code>），审计任务<br />
根本跑不完。只多 8K，就是"全挂"到"全过"。</p>
<blockquote>
<p dir="auto">agent 任务的 decode（33–45）明显低于生成任务（66–67），是上下文深度造成的——<br />
这些 run 的 prompt 有 9–15K tokens。另外<strong>每轮对话都要完整重算 prefill</strong><br />
（上下文裁剪会打断前缀缓存），约 72 秒/次工具调用，这是长任务的真实墙钟成本。</p>
</blockquote>
<h2>五、两个坑，踩过的可以直接跳过</h2>
<p dir="auto"><strong>坑 1：带 MTP 的上下文上限是 40960，不是 64K。</strong> 同一张卡上逐档试出来的：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="text-align:right"><code>-c</code></th>
<th>带 MTP</th>
<th>无 MTP</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">32768</td>
<td>7284 MiB <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
<td>—</td>
</tr>
<tr>
<td style="text-align:right"><strong>40960</strong></td>
<td><strong>7508 MiB <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></strong></td>
<td>—</td>
</tr>
<tr>
<td style="text-align:right">49152</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /> cudaMalloc OOM</td>
<td>—</td>
</tr>
<tr>
<td style="text-align:right">65536</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /></td>
<td>7268 MiB <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td style="text-align:right">81920</td>
<td>—</td>
<td>7636 MiB <img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--white_check_mark" style="height:23px;width:auto;vertical-align:middle" title="✅" alt="✅" /></td>
</tr>
<tr>
<td style="text-align:right">90112</td>
<td>—</td>
<td><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/274c.png?v=ecb7c61779a" class="not-responsive emoji emoji-android emoji--x" style="height:23px;width:auto;vertical-align:middle" title="❌" alt="❌" /></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>坑 2：这个 build 关掉 MTP 之后，模型输出会坍缩成 <code>/</code>。</strong></p>
<p dir="auto">上面那张表里"无 MTP"一列看着很诱人——能把窗口开到 80K，省显存也是真的<br />
（7268 MiB，跟文档里的 7,266 几乎分毫不差）。<strong>但代价是模型直接不会写字了：</strong></p>
<pre><code>32K + MTP             -&gt; 正常
32K 无 MTP            -&gt; 全是 "/"        (多次复现)
64K 无 MTP            -&gt; 全是 "/"        (3/3)
无 MTP + 关 thinking  -&gt; 正文直接是 200 个连续 "/"
无 MTP + 原版 PTQ1_0  -&gt; 同样坍缩
</code></pre>
<p dir="auto">不是 <code>-mtp-lean</code> 文件的问题（原版 GGUF 一样），也不是 reasoning 路径的问题。<br />
<strong>所以"拿 MTP 换上下文"这条路，至少在这个 build 上走不通。</strong></p>
<h2>六、能跑通还有一半功劳在 harness：dsh + 我们自己写的两个小插件</h2>
<p dir="auto">上面那些 agent 任务不是我手动盯着一步步喂的，是模型自己调工具、自己决定下一步，<br />
跑在 <a href="https://github.com/deepseek-ai/deepseek-harness" rel="nofollow ugc"><strong>DeepSeek Harness (dsh)</strong></a><br />
的 headless 容器里。</p>
<p dir="auto">速度这块已经很多人卷了，但**"小窗口下 agent 怎么不把自己搞死"讲的人不多**——<br />
而 8GB 卡上这就是生死线。我们前后写了两个 dsh 插件来治这个，都有点用：</p>
<h3>插件一：一个不花模型调用的"后悔药" —— <a href="https://github.com/snailium/dsh-command-context-trim" rel="nofollow ugc">context-trim</a></h3>
<p dir="auto">上下文满了怎么办？常规操作是让模型自己压缩历史。<strong>问题是压缩本身也要跑一次模型</strong>，<br />
而且它得把"要压缩的那段"塞进已经快满的窗口里——于是就经常压不动。我们实测撞到的：</p>
<pre><code>summary is not smaller than the shadowed content (1180 &gt;= 1180)
</code></pre>
<p dir="auto">翻译一下："我想把它变小，但变小之后还是一样大。" 32K 的卡上，到这一步基本就死了。</p>
<p dir="auto">我们这个小东西的思路特别土：<strong>一次模型都不调，纯记账。</strong> 把最老最没用的那段对话<br />
直接换成一行标记，或者把超长的工具输出掐头去尾留一段。腾地方不要钱，所以<br />
<strong>它在所有请求都快挂掉的时候反而最管用</strong>。</p>
<p dir="auto">效果：那次 27 个文件的安全审计，它出手 <strong>11 次，一共腾出约 3.7 万 tokens</strong>。<br />
没它的话，这个任务在 40K 窗口里根本走不到"开始写报告"那一步。</p>
<p dir="auto">一句话总结：<strong>别指望模型自己管上下文，裁剪这种事应该是 harness 的零成本杂活。</strong></p>
<h3>插件二：它钻牛角尖的时候，得有人踹一脚 —— <a href="https://github.com/snailium/dsh-repeat-tool-breaker" rel="nofollow ugc">repeat-tool-breaker</a></h3>
<p dir="auto">小模型 + 低显存，"原地打转"是高频死法。我们碰到的真实案例：<br />
<strong>同一个 API 打了 29 次，每次参数都不一样，跑满一小时没结果。</strong></p>
<p dir="auto">最阴险的地方在于——<strong>从字面上看它每次都在做不同的事</strong>。所以任何"检测重复调用"的<br />
工具都抓瞎，你只能干看着它烧时间。</p>
<p dir="auto">我们的做法是不看字面、看<strong>语义</strong>：比如"往 <a href="http://weather.gc.ca" rel="nofollow ugc">weather.gc.ca</a> 这个域名一共打了多少次"<br />
单独计数。不管你 URL 参数怎么变，<strong>同一个目标的调用会攒起来</strong>，钻牛角尖就现形了。</p>
<p dir="auto">喊停也不是一上来就拦死，分三级：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>第几次</th>
<th>反应</th>
</tr>
</thead>
<tbody>
<tr>
<td>7 次</td>
<td>轻轻提醒一句："你在重复，考虑换条路"</td>
</tr>
<tr>
<td>11 次</td>
<td>要求它<strong>写出进度摘要 + 至少两个还没试过的方案</strong></td>
</tr>
<tr>
<td>12+ 次</td>
<td>才真拦</td>
</tr>
</tbody>
</table>
<p dir="auto">T5 那次的效果：模型连着 7 次 curl 同一个天气 API、5 次失败，第 7 次触发提醒，<br />
<strong>下一次调用它就换思路了</strong>——从"怎么调通这个端点"变成去搜气象局官网数据，<br />
最后算出正确答案。</p>
<p dir="auto">一句话总结：<strong>小模型本来就更容易钻牛角尖，而且钻起来更慢更烧时间。<br />
与其调 temperature / penalty 试图让它别钻，不如在 harness 层给它一句<br />
"你该换个思路了"。</strong> 后半句是我们反复验证过的：光调采样参数，救不回来。</p>
<blockquote>
<p dir="auto">顺手记一个 bug：判断"失败"不能只看 <code>isError</code>。<code>curl ... | python3 ... | head</code><br />
的退出码是 0，脚本里把 HTTP 400 吃掉了也是 0——我们那次 7 个调用里 5 个失败，<br />
<strong>全被判成了成功</strong>，所以提醒一直不吭声。最后得去读文本里的报错特征才行。</p>
</blockquote>
<h2>七、thinking 也有个方向性的坑</h2>
<p dir="auto">模板里 <code>reasoning_effort</code> 只接受 <code>xhigh</code> / <code>medium</code> / <code>low</code> 三个值。默认 <code>xhigh</code> 会注入<br />
一段"仔细思考、验证假设、考虑替代方案"的系统提示，在量化模型上会失控——我们实测过<br />
一次 <strong>24508 token 的回复里 86% 烧在 thinking，正文一个字没出来</strong>。</p>
<p dir="auto"><code>low</code> 注入的是相反指令（"Keep your thinking brief and focused"），配<br />
<code>--reasoning-budget 4096</code> 在 agent 任务上表现最好；纯生成任务直接 <code>--reasoning off</code>。</p>
<p dir="auto"><strong>方向性坑</strong>：服务端设了 <code>--reasoning off</code> 之后，<strong>客户端发 <code>reasoning_effort: high</code><br />
是压不过它的</strong>（实测 0 个 reasoning frame）。想两种模式共用一个 server，要反过来做：<br />
服务端开着 thinking，需要关的请求带 <code>chat_template_kwargs: {"enable_thinking": false}</code>。</p>
<h2>八、复现入口</h2>
<p dir="auto">仓库：<strong><a href="https://github.com/snailium/bonsai2-8gb" rel="nofollow ugc">https://github.com/snailium/bonsai2-8gb</a></strong></p>
<ul>
<li><code>bonsai2-universal.tar.gz</code> — 预编译二进制，<strong>sm_75 → sm_120 全架构</strong><br />
（我们从源码编的：官方预编译包只含 Ampere/Ada，而 CUDA 12.4 编不了 sm_120）</li>
<li><code>RECIPE.md</code> — 完整配方、每个参数的依据、各项实测数据、12 条注意事项</li>
<li><code>BUILD.md</code> — 编译三个坑：CUDA 12.4 编不了 Blackwell、glibc 2.43 的 <code>rsqrt</code><br />
声明冲突、cmake 会静默选错 nvcc（报 <code>ptxas fatal: Value 'sm_52' is not defined</code>）</li>
</ul>
<p dir="auto"><strong>这两个插件是我们自己写的</strong>，源码和设计说明都公开：</p>
<ul>
<li><a href="https://github.com/snailium/dsh-command-context-trim" rel="nofollow ugc">snailium/dsh-command-context-trim</a><br />
—— 零模型调用的上下文裁剪</li>
<li><a href="https://github.com/snailium/dsh-repeat-tool-breaker" rel="nofollow ugc">snailium/dsh-repeat-tool-breaker</a><br />
—— 语义指纹的重复/失败检测</li>
</ul>
<p dir="auto">写它们的原因很直接：<strong>8GB 这种小窗口跑 agent，光靠调模型参数是救不回来的，<br />
必须在 harness 层动手</strong>。如果有人在别的低显存场景做 agent，这两个的思路应该能照搬——<br />
插件的阈值和开关都是可配的，不绑定任何特定模型。</p>
]]></description><link>https://lcz.me/topic/1908</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 21:27:08 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1908.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Sep 2026 07:12:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Fri, 25 Sep 2026 14:50:38 GMT]]></title><description><![CDATA[<p dir="auto">多谢，分享。我试试你的插件，这几天正在被repeat问题折磨</p>
]]></description><link>https://lcz.me/post/20733</link><guid isPermaLink="true">https://lcz.me/post/20733</guid><dc:creator><![CDATA[J Z 0]]></dc:creator><pubDate>Fri, 25 Sep 2026 14:50:38 GMT</pubDate></item><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Wed, 23 Sep 2026 13:02:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/snailium" aria-label="Profile: snailium">@<bdi>snailium</bdi></a> 认同，用脚本扫是对的——计算值和实测差得多，这个差值本身就是最该固化的数据。差距一般来自几块：① KV 按 block 分配 + 计算缓冲（受 batch/ubatch、是否 flash-attn 影响）；② CUDA context/graph 与分配器的预留；③ mmproj 视觉塔单独占一块；④ MTP draft 头及它自己的 KV；⑤ sidecar 那份重复词表。</p>
<p dir="auto">建议扫描时固定 batch/ubatch 与 flash-attn 开关，分别给「带 mmproj / 不带」两组，把结果拟合成 <code>峰值 = 固定开销 + 每 token 字节 × 上下文</code> 两个常数。8GB 上固定开销占比很大，别人换 12G/16G 拿这条线性式就能直接估自己能不能上 40K，比单给一个 40K 点更有用。</p>
]]></description><link>https://lcz.me/post/20297</link><guid isPermaLink="true">https://lcz.me/post/20297</guid><dc:creator><![CDATA[Xiaote]]></dc:creator><pubDate>Wed, 23 Sep 2026 13:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Wed, 23 Sep 2026 12:00:11 GMT]]></title><description><![CDATA[<p dir="auto">40k上下文应该是Hermes的最低要求，只能勉强跑的起来，不要指望跑得顺畅。而且能跑起来的关键是那两个插件，Hermes没法装。小上下文还得靠DSH。</p>
<p dir="auto">另外，<a class="plugin-mentions-user plugin-mentions-a" href="/user/xiaote" aria-label="Profile: xiaote">@<bdi>xiaote</bdi></a> 说明一下，40K上下文不是算出来的，而是通过脚本扫出来的。用脚本的理由也很简单，计算出来的和实际显存占用差距很大。</p>
<p dir="auto">理论上讲8GB卡应该显存占用都一样，10GB/12GB需要根据需求加载mmproj（视觉塔）之后用脚本扫一下最大可支持的上下文</p>
]]></description><link>https://lcz.me/post/20283</link><guid isPermaLink="true">https://lcz.me/post/20283</guid><dc:creator><![CDATA[snailium]]></dc:creator><pubDate>Wed, 23 Sep 2026 12:00:11 GMT</pubDate></item><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Wed, 23 Sep 2026 10:43:28 GMT]]></title><description><![CDATA[<p dir="auto">好奇问一嘴，可以用4060 8G跑hermes吗？刚好有张闲置的，放着浪费，打算装个Ubuntu24跑Hermes，不知道是否可行？</p>
]]></description><link>https://lcz.me/post/20275</link><guid isPermaLink="true">https://lcz.me/post/20275</guid><dc:creator><![CDATA[apple]]></dc:creator><pubDate>Wed, 23 Sep 2026 10:43:28 GMT</pubDate></item><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Wed, 23 Sep 2026 10:02:07 GMT]]></title><description><![CDATA[<p dir="auto">数据挺实在，补三点可以固化进 README 的：</p>
<ol>
<li>
<p dir="auto">「卡上下文而不是解码」这个结论值得量化：Bonsai2 只有 16 层 full attention，KV 只在这 16 层增长，所以每 token KV 字节数 = 2 × 16 × n_kv_heads × head_dim × 每权重字节。把 q4_0 KV 下的 bytes/token 写出来，32K→40K 到底多占多少 MB 就能手算，别人换 3060 12G、4060Ti 16G 也能直接估自己能不能上 40K——这比给结论有用。</p>
</li>
<li>
<p dir="auto">「关掉 MTP 反而不能跑」多半不是算力问题，而是 sidecar 那份重复词表 embedding 改了显存布局；嫁接成 blk.64 省掉的正是这份重复。建议把两种装法的峰值显存差贴出来，这是很反直觉的一个坑。</p>
</li>
<li>
<p dir="auto">三值基底的 Hadamard 旋转是硬依赖，旧 Q2_0「能加载但输出乱码」这种静默失效最危险（比直接拒绝加载坑得多）。建议启动自检加一条固定 prompt 的输出哈希校验，对不上就拒绝启动，并把 fork 的 commit digest 钉进镜像而不是只写分支名。</p>
</li>
</ol>
<p dir="auto">另外如果方便，补一组同上下文下「q4_0 KV vs q8_0 KV」的 tg 对比，就能知道 40K 是硬墙还是还能再挤。8GB 跑通完整 agent 是个不错的边界样本。</p>
]]></description><link>https://lcz.me/post/20271</link><guid isPermaLink="true">https://lcz.me/post/20271</guid><dc:creator><![CDATA[Xiaote]]></dc:creator><pubDate>Wed, 23 Sep 2026 10:02:07 GMT</pubDate></item><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Wed, 23 Sep 2026 07:46:08 GMT]]></title><description><![CDATA[<p dir="auto">這模型的名稱為什麼要取拉屎的閩南語？</p>
]]></description><link>https://lcz.me/post/20239</link><guid isPermaLink="true">https://lcz.me/post/20239</guid><dc:creator><![CDATA[paul hou]]></dc:creator><pubDate>Wed, 23 Sep 2026 07:46:08 GMT</pubDate></item><item><title><![CDATA[Reply to 整活：8GB显存也要跑agent on Wed, 23 Sep 2026 07:22:54 GMT]]></title><description><![CDATA[<p dir="auto">原始的 dsh session 在这里 <a href="https://github.com/snailium/bonsai2-8gb/tree/main/evidence" rel="nofollow ugc">https://github.com/snailium/bonsai2-8gb/tree/main/evidence</a> ，有兴趣的朋友可以分析一下，看看插件还有没有能改进的地方。</p>
<p dir="auto">只要是CUDA 13.1支持的显卡应该都能跑起来。像RTX3080 10GB这种卡还能加视觉模型（多模态，直接使用Qwen3.8:27b官方的mmproj就行）</p>
]]></description><link>https://lcz.me/post/20237</link><guid isPermaLink="true">https://lcz.me/post/20237</guid><dc:creator><![CDATA[snailium]]></dc:creator><pubDate>Wed, 23 Sep 2026 07:22:54 GMT</pubDate></item></channel></rss>