<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Qwen on Hypho - AI Agent 技术博客</title><link>https://blog.hypho.cn/tags/qwen/</link><description>Recent content in Qwen on Hypho - AI Agent 技术博客</description><image><title>Hypho - AI Agent 技术博客</title><url>https://blog.hypho.cn/papermod-cover.png</url><link>https://blog.hypho.cn/papermod-cover.png</link></image><generator>Hugo -- 0.148.2</generator><language>zh-cn</language><lastBuildDate>Tue, 21 Apr 2026 10:05:00 +0800</lastBuildDate><atom:link href="https://blog.hypho.cn/tags/qwen/index.xml" rel="self" type="application/rss+xml"/><item><title>单卡 207 tok/s：DFlash + DDTree 让 Qwen3.5-27B 在 RTX 3090 上跑出推理新纪录</title><link>https://blog.hypho.cn/posts/dflash-ddtree-speculative-decoding-llm-inference/</link><pubDate>Tue, 21 Apr 2026 10:05:00 +0800</pubDate><guid>https://blog.hypho.cn/posts/dflash-ddtree-speculative-decoding-llm-inference/</guid><description>DFlash 块扩散草稿 + DDTree 树验证，在单张 RTX 3090 上把 Qwen3.5-27B Q4_K_M 推到 207 tok/s，比自回归解码快 5.46 倍。Lucebox 项目开源了首个 GGUF 版本的 DFlash 实现，揭开消费级 GPU 跑大模型推理的新思路。</description><content:encoded><![CDATA[<p>一个 27B 参数的大模型，在一张 2021 年买的游戏显卡上能跑多快？</p>
<p>Lucebox 团队给出了一个让很多人没想到的数字：<strong>207.6 token/s</strong>。用的还是 Qwen3.5-27B 官方模型，不是蒸馏，不是 INT8 量化残血版——就是 Q4_K_M 量化版本，目标加草稿模型全部加载在一张 24 GB VRAM 的 RTX 3090 上。</p>
<p>这个成绩靠的不是等英伟达下一代消费级显卡，而是对<strong>解码算法本身</strong>动刀子。</p>
<h2 id="为什么自回归解码是瓶颈">为什么自回归解码是瓶颈</h2>
<p>大多数人聊 LLM 推理优化，会先想到量化、KV cache 压缩、batch 并行。但对单卡消费级 GPU 来说，这些都已经做到头了——Q4_K_M 量化能压缩到约 16 GB，再压下去效果肉眼可见地降。</p>
<p>问题出在<strong>自回归解码本身</strong>。每生成一个 token，GPU 要完整跑一遍 27B 参数的前向传播。27B 参数在 Q4_K_M 下大约 16 GB，VRAM 带宽是 936 GB/s——每次解码都要把这 16 GB 从显存读一遍，理论带宽利用率撑死不到 20%。这是机械式的物理限制，不是软件优化能绕过去的。</p>
<p>speculative decoding（投机解码）解决的就是这个问题：用一个<strong>小草稿模型</strong>一次生成多个候选 token，再用<strong>大模型</strong>一次验证整串。如果草稿猜得准，大模型只跑一次就能吐出五六个 token，GPU 计算资源用得更充分。</p>
<h2 id="dflash块扩散草稿比-chain-eagle-更容易命中">DFlash：块扩散草稿，比 Chain EAGLE 更容易命中</h2>
<p>主流投机解码方案是 EAGLE（及其 chain 版），草稿模型做自回归预测，每步大约能接受 3 个 token。<strong>DFlash（2026）</strong> 换了个思路：用<strong>块扩散（block diffusion）</strong> 做草稿——一个 5 层非因果的去噪网络，同时预测多个位置，而不是逐个生成。</p>
<p>效果如何？看数字：</p>
<table>
  <thead>
      <tr>
          <th>任务</th>
          <th style="text-align: center">AR 基线（tok/s）</th>
          <th style="text-align: center">DFlash+DDTree（tok/s）</th>
          <th style="text-align: center">加速比</th>
          <th style="text-align: center">平均接受长度</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>HumanEval</td>
          <td style="text-align: center">37.78</td>
          <td style="text-align: center"><strong>129.52</strong></td>
          <td style="text-align: center"><strong>3.43×</strong></td>
          <td style="text-align: center">8.31</td>
      </tr>
      <tr>
          <td>Math500</td>
          <td style="text-align: center">37.71</td>
          <td style="text-align: center"><strong>110.51</strong></td>
          <td style="text-align: center"><strong>2.93×</strong></td>
          <td style="text-align: center">7.04</td>
      </tr>
      <tr>
          <td>GSM8K</td>
          <td style="text-align: center">37.65</td>
          <td style="text-align: center"><strong>96.15</strong></td>
          <td style="text-align: center"><strong>2.55×</strong></td>
          <td style="text-align: center">6.14</td>
      </tr>
  </tbody>
</table>
<p>AR 基线是 Qwen3.5-27B Q4_K_M 在 RTX 3090 上的原生速度，也是 llama.cpp、SGLang AWQ 等框架在同一硬件上的天花板。DFlash 把这个天花板一口气推到 3 倍以上——而且<strong>平均每次验证接受 8 个 token</strong>，比 EAGLE 的 ~3 高了将近两倍。</p>
<p>但这里有个工程问题：官方 DFlash 实现跑在 BF16 下，需要 60+ GB VRAM 的 B200 专业卡才能装下目标+草稿+验证树。消费级 GPU 想用，得从头移植。</p>
<h2 id="gguf-移植q4_k_m-是-24-gb-的最优解">GGUF 移植：Q4_K_M 是 24 GB 的最优解</h2>
<p>Lucebox 的贡献就是这个移植。他们选了 <strong>Q4_K_M 量化目标（~16 GB）+ BF16 草稿（~3.46 GB）+ DDTree 验证树（budget=22）</strong>，刚好能在 24 GB VRAM 里塞下整个推理链路。</p>
<p>GGUF 是 llama.cpp 的量化格式，在消费级 GPU 上生态最成熟。选择 ggml 作为运行时而非 libllama，是因为 ggml 有<strong>原生 Gated DeltaNet CUDA kernel</strong>，不需要额外改硬件抽象。</p>
<p>整个移植约 2000 行 C++/CUDA 代码，fork 了 llama.cpp 增加了三个 tree-mode 操作：</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">ggml_ssm_conv_tree</span>      <span class="c1">// SSM 卷积树结构
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">ggml_gated_delta_net_tree</span>        <span class="c1">// Gated DeltaNet 树验证
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">ggml_gated_delta_net_tree_persist</span> <span class="c1">// 持久化状态
</span></span></span></code></pre></div><p>硬编码了 Qwen3.5-27B + Qwen3.5-27B-DFlash 这一个模型组合，没有通用性——但消费级单卡跑 27B 规模，这个组合恰好是最有价值的一个。</p>
<h2 id="128k-context-怎么塞进去">128K context 怎么塞进去</h2>
<p>原生 DFlash 在 128K 上下文时会爆显存，因为 KV cache 太大。Lucebox 的解法是<strong>Q4_0 KV cache + 滑动 target_feat ring</strong>（4096 槽位）：</p>
<ul>
<li>Q4_0 比 BF16 省 8 倍显存</li>
<li>Sliding window 限制历史 KV 长度</li>
<li>target_feat 做 ring buffer，超长 prompt 自动驱逐旧状态</li>
</ul>
<p>代价是 Acceptance Length 约下降 3%，但换来了<strong>128K context 稳定在 24 GB 内</strong>，128K 模式下仍能跑出 ~135 tok/s。这对需要超长上下文的应用（代码库分析、长文档对话）是实打实的突破。</p>
<h2 id="关键洞察消费级-gpu-的-llm-推理还没到头">关键洞察：消费级 GPU 的 LLM 推理还没到头</h2>
<p>看完 Lucebox 的实现，有几个工程结论值得关注：</p>
<p><strong>1. 量化不是终点，算法才是</strong></p>
<p>Q4_K_M 已经把 27B 压到 16 GB，这个路径的边际收益越来越小。但在 Q4_K_M 基础上加 DFlash，能在不降低模型质量的前提下再快 3 倍——这说明解码算法的优化空间远没有到头。下一个突破点很可能是<strong>草稿模型和目标模型的协同训练</strong>，而不是继续压缩精度。</p>
<p><strong>2. GGUF 生态正在变厚</strong></p>
<p>Llama.cpp 的 GGUF 量化格式原本是&quot;省显存&quot;的妥协方案，但随着 ggml 支持更多的 CUDA kernel（SSM、Gated DeltaNet），它在某些场景下已经不只是&quot;能用&quot;，而是&quot;最优解&quot;。这对想在消费级硬件上做推理优化的开发者是好消息——不需要自己写 CUDA kernel，现成的生态已经能跑起来。</p>
<p><strong>3. 单卡 27B 的实用边界在拓宽</strong></p>
<p>207 tok/s 意味着什么？实际体验大概是：每秒能吐出大约 150-200 个中文词，或者 300-400 个英文词。这个速度已经能支持<strong>实时交互式 AI 助手</strong>——不是等几秒才回一个字，而是几乎感知不到延迟的流式响应。加上 128K 上下文，单卡 27B 能做的事比去年这个时候多了很多。</p>
<h2 id="快速上手">快速上手</h2>
<p>项目在 GitHub，clone 下来大概需要知道这几步：</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># 1. 克隆（含 submodule）</span>
</span></span><span class="line"><span class="cl">git clone --recurse-submodules https://github.com/Luce-Org/lucebox-hub
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> lucebox-hub/dflash
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># 2. 编译（CUDA 12+, RTX 3090/sm_86）</span>
</span></span><span class="line"><span class="cl">cmake -B build -S . -DCMAKE_CUDA_ARCHITECTURES<span class="o">=</span><span class="m">86</span> -DCMAKE_BUILD_TYPE<span class="o">=</span>Release
</span></span><span class="line"><span class="cl">cmake --build build --target test_dflash -j
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># 3. 下载模型（约 20 GB）</span>
</span></span><span class="line"><span class="cl">huggingface-cli download unsloth/Qwen3.5-27B-GGUF Qwen3.5-27B-Q4_K_M.gguf --local-dir models/
</span></span><span class="line"><span class="cl">huggingface-cli download z-lab/Qwen3.5-27B-DFlash model.safetensors --local-dir models/draft/
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># 4. 运行</span>
</span></span><span class="line"><span class="cl">python3 scripts/run.py --prompt <span class="s2">&#34;def fibonacci(n):&#34;</span>
</span></span></code></pre></div><p>完整的 benchmark 结果在 <a href="https://github.com/Luce-Org/lucebox-hub/tree/main/dflash/RESULTS.md">RESULTS.md</a>，包括不同模型、不同 context 长度下的吞吐和内存数据。</p>
<h2 id="信源">信源</h2>
<ul>
<li>Lucebox DFlash 实现：https://github.com/Luce-Org/lucebox-hub</li>
<li>DFlash 论文：https://arxiv.org/abs/2602.06036</li>
<li>DDTree 论文：https://arxiv.org/abs/2604.12989</li>
<li>Lucebox 官方博客：https://lucebox.com/blog/dflash27b</li>
<li>Qwen3.5-27B GGUF 量化模型：https://huggingface.co/unsloth/Qwen3.5-27B-GGUF</li>
<li>Qwen3.5-27B-DFlash 草稿模型：https://huggingface.co/z-lab/Qwen3.5-27B-DFlash</li>
</ul>
]]></content:encoded></item></channel></rss>