<?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>CUDA on Hypho - AI Agent 技术博客</title><link>https://blog.hypho.cn/tags/cuda/</link><description>Recent content in CUDA 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>Wed, 17 Jun 2026 10:06:52 +0800</lastBuildDate><atom:link href="https://blog.hypho.cn/tags/cuda/index.xml" rel="self" type="application/rss+xml"/><item><title>Rust 写 GPU 内核终于安全了？cuTile Rust 的 tile-based 方案和它背后的推理引擎</title><link>https://blog.hypho.cn/posts/cutile-rust-safe-gpu-kernel-programming/</link><pubDate>Wed, 17 Jun 2026 10:06:52 +0800</pubDate><guid>https://blog.hypho.cn/posts/cutile-rust-safe-gpu-kernel-programming/</guid><description>NVIDIA Labs 开源的 cuTile Rust 把 Rust 所有权模型延伸到 GPU 内核编程，实现无数据竞争的 tile-based GPU 计算。本文解析其核心机制、与 cuda-oxide 的路线差异、Grout 推理引擎的性能表现，以及 Rust GPU 编程生态的最新格局。</description><content:encoded><![CDATA[<p>如果你关注 GPU 编程和 AI 基础设施，最近应该注意到一个趋势：Rust 正在悄悄渗透进 GPU 开发的每一个角落。NVIDIA Labs 在同一时间开源了两个 Rust GPU 项目——cuda-oxide（2768 stars）和 cuTile Rust（381 stars），前者是把标准 Rust 代码直接编译成 PTX 的 rustc 后端，后者是我们今天要聊的主角：一个基于 tile 抽象的安全 GPU 内核编程系统。</p>
<p>坦白说，第一次看到 cuTile Rust 的 README 时我有点不以为然——又一个 DSL？但读完论文 <em>Fearless Concurrency on the GPU</em> 之后，我的看法变了。这不是简单的语法糖，而是认认真真地把 Rust 的所有权和借用检查搬到了 GPU 内核层面。</p>
<h2 id="问题gpu-内核编程为什么需要安全">问题：GPU 内核编程为什么需要安全？</h2>
<p>写 CUDA 内核的人大概都踩过这些坑：线程越界访问 shared memory、race condition 导致结果随机出错、异步 kernel launch 后 host 端提前释放了显存。传统 CUDA C++ 对这类问题基本靠程序员自觉——你犯了错，程序不会告诉你，只会给你一个错误结果或者 segfault。</p>
<p>cuTile Rust 的核心思路是：既然 Rust 在 CPU 端已经用所有权系统解决了数据竞争问题，为什么不能把这个保证延伸到 GPU 端？</p>
<p>具体来说，cuTile Rust 做了三件事：</p>
<p><strong>1. 可变 tensor 在 launch 前被切分成不相交的块（partition）</strong></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-rust" data-lang="rust"><span class="line"><span class="cl"><span class="kd">let</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">api</span>::<span class="n">zeros</span>::<span class="o">&lt;</span><span class="kt">f32</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="mi">1024</span><span class="p">]).</span><span class="n">partition</span><span class="p">([</span><span class="mi">128</span><span class="p">]);</span><span class="w">
</span></span></span></code></pre></div><p>这行代码把 1024 个元素的 tensor 切成 8 块，每块 128 个元素。每个 GPU 线程块只能访问自己那一块，物理上不可能发生跨块写冲突。</p>
<p><strong>2. 不可变 tensor 被标记为共享只读</strong></p>
<p>函数签名里的 <code>&amp;Tensor</code> 和 <code>&amp;mut Tensor</code> 直接表达了访问权限：</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-rust" data-lang="rust"><span class="line"><span class="cl"><span class="k">fn</span> <span class="nf">add</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">B</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="p">(</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="n">z</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Tensor</span><span class="o">&lt;</span><span class="kt">f32</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">[</span><span class="n">B</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">,</span><span class="w">  </span><span class="c1">// 唯一可写
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="w">    </span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">Tensor</span><span class="o">&lt;</span><span class="kt">f32</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">,</span><span class="w">     </span><span class="c1">// 只读共享
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="w">    </span><span class="n">y</span>: <span class="kp">&amp;</span><span class="nc">Tensor</span><span class="o">&lt;</span><span class="kt">f32</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">,</span><span class="w">     </span><span class="c1">// 只读共享
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">)</span><span class="w">
</span></span></span></code></pre></div><p>这不是注释层面的约定，而是编译器强制的。</p>
<p><strong>3. Host 端在 kernel 执行期间保持所有权</strong></p>
<p>launch 一个 kernel 不会把 tensor 的所有权转移走。GPU 在执行时，host 端的 tensor 仍然被&quot;借用&quot;，你没法在这个窗口期意外释放或修改它。这解决了异步执行中最阴险的一类 bug。</p>
<h2 id="性能安全不是免费的这次可能是">性能：安全不是免费的？这次可能是</h2>
<p>论文里的数据相当有说服力。在 NVIDIA B200 上：</p>
<ul>
<li><strong>逐元素操作</strong>：7 TB/s，达到峰值显存带宽的 91%</li>
<li><strong>GEMM（矩阵乘法）</strong>：2 PFlop/s，达到 B200 dense f16 峰值的 92%，和 cuBLAS 差距在 0.3% 以内</li>
<li><strong>Persistent GEMM</strong>：安全版本跑出 2.07 PFlop/s，和低层 Tile IR 版本差距不到 0.3%</li>
</ul>
<p>换句话说，安全抽象带来的运行时开销在测量噪声范围内——几乎为零。</p>
<p>这个结论如果经得起复现，意义很大。它意味着你可以用 Rust 写 GPU 内核，获得编译期安全保证，而不用付出传统上&quot;安全语言写 GPU&quot;的那种性能税。</p>
<h2 id="grout用-cutile-rust-写的推理引擎">Grout：用 cuTile Rust 写的推理引擎</h2>
<p>理论说完了，来看实战。Hugging Face 和 NVIDIA 合作用 cuTile Rust 构建了 <a href="https://github.com/huggingface/grout">Grout</a>，一个纯 Rust 的 Qwen3 推理引擎。</p>
<p>性能数据：</p>
<table>
  <thead>
      <tr>
          <th>模型</th>
          <th>硬件</th>
          <th>速度</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Qwen3-4B</td>
          <td>RTX 5090</td>
          <td>171 tok/s</td>
      </tr>
      <tr>
          <td>Qwen3-32B</td>
          <td>B200</td>
          <td>82 tok/s</td>
      </tr>
  </tbody>
</table>
<p>论文的 HBM roofline 分析显示这些数字和理论带宽上限一致，说明没有明显的效率损失。和 vLLM、SGLang 等成熟的 Python/C++ 推理框架相比，这个性能是 competitive 的。之前我们聊过 <a href="https://blog.hypho.cn/posts/kvarn-vllm-kv-cache-quantization-production/">KVarN 在 vLLM 上做 KV-cache 量化的吞吐优化</a>，以及 <a href="https://blog.hypho.cn/posts/mimo-tilert-1000tps-trillion-parameter-inference/">MiMo × TileRT 的模型-系统联合设计</a>如何在推理吞吐上做到极致——Grout 走的是另一条路：用 Rust 重写整个推理栈，从语言层面消除内存安全隐患。</p>
<p>当然，Grout 目前只有 29 stars，还是个研究性质的 testbed，离生产级推理引擎还有距离。但它证明了一件事：<strong>用 Rust + cuTile Rust 写高性能推理内核是完全可行的</strong>。</p>
<h2 id="cutile-rust-vs-cuda-oxide两条路线">cuTile Rust vs cuda-oxide：两条路线</h2>
<p>NVIDIA Labs 同时维护着两个 Rust GPU 项目，这让不少人困惑。它们的区别其实很清晰：</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th>cuTile Rust</th>
          <th>cuda-oxide</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>抽象级别</strong></td>
          <td>高层 tile DSL</td>
          <td>底层标准 Rust 语法</td>
      </tr>
      <tr>
          <td><strong>编译路径</strong></td>
          <td>Rust → CUDA Tile IR → cubin</td>
          <td>Rust → Rust MIR → LLVM IR → PTX</td>
      </tr>
      <tr>
          <td><strong>安全保证</strong></td>
          <td>编译器强制的 tile 分区 + 所有权</td>
          <td>&ldquo;safe-ish&rdquo;，部分检查</td>
      </tr>
      <tr>
          <td><strong>适用场景</strong></td>
          <td>tile-based 计算（GEMM、卷积等）</td>
          <td>通用 SIMT 内核</td>
      </tr>
      <tr>
          <td><strong>Stars</strong></td>
          <td>381</td>
          <td>2768</td>
      </tr>
  </tbody>
</table>
<p>cuda-oxide 更像是&quot;让 Rust 成为 CUDA C++ 的替代品&quot;，你写的代码更接近传统 CUDA 内核的风格，只是用了 Rust 语法。cuTile Rust 则是更高层的抽象，让你在 tile 层面思考，编译器帮你处理线程映射和内存安全。</p>
<p>两者不矛盾，更像是同一生态里的不同层次。对于 ML 工程师来说，cuTile Rust 的 tile 抽象更接近日常的 tensor 操作心智模型；对于系统程序员来说，cuda-oxide 的底层控制更灵活。</p>
<h2 id="rust-gpu-编程的全景">Rust GPU 编程的全景</h2>
<p>把视野拉远一点，2026 年的 Rust GPU 生态已经初具规模：</p>
<ul>
<li><strong><a href="https://github.com/Rust-GPU/Rust-GPU">Rust-GPU</a></strong>（Embark Studios，3169 stars）：把 Rust 编译成 SPIR-V，面向 Vulkan 生态</li>
<li><strong><a href="https://github.com/NVlabs/cuda-oxide">cuda-oxide</a></strong>（NVIDIA Labs，2768 stars）：Rust 直接编译 PTX</li>
<li><strong>cuTile Rust</strong>（NVIDIA Labs，381 stars）：tile-based 安全 GPU 编程</li>
<li><strong><a href="https://github.com/vosen/ZLUDA">ZLUDA</a></strong>（14288 stars）：让 CUDA 在 AMD GPU 上跑</li>
</ul>
<p>有意思的是，NVIDIA 自己在大力推 Rust GPU 方向，这在几年前是不可想象的。背后的原因可能和 AI 推理的工程需求有关——当你的推理引擎要处理越来越大的模型、越来越复杂的调度逻辑时，C++ 的内存安全问题就不再是&quot;偶发 bug&quot;而是&quot;系统性风险&quot;。更根本的问题是，<a href="https://blog.hypho.cn/posts/ai-chip-memory-wall-hbm-cost/">GPU 算力的瓶颈正在从计算转向显存</a>，这意味着推理内核的优化空间越来越依赖于精细的内存管理——而这恰恰是 Rust 类型系统最擅长的领域。</p>
<h2 id="我的判断">我的判断</h2>
<p>cuTile Rust 值得关注，但要分清楚&quot;值得关注&quot;和&quot;现在就该用&quot;的区别。</p>
<p><strong>值得关注的原因</strong>：</p>
<ol>
<li>这是 NVIDIA Labs 的研究项目，有论文支撑，不是草根实验</li>
<li>tile-based 抽象和 Rust 所有权的结合思路非常优雅</li>
<li>性能数据（92% cuBLAS，安全零开销）如果可复现，是真正的突破</li>
<li>Grout 证明了在推理场景的可行性</li>
</ol>
<p><strong>现在不急着用的原因</strong>：</p>
<ol>
<li>项目自己说了&quot;early stage, expect bugs and API breakage&quot;</li>
<li>需要 CUDA 13.2，目前主流环境还在 CUDA 12.x</li>
<li>生态还很小（381 stars，Grout 29 stars），遇到问题很难找到帮助</li>
<li>和现有 CUDA C++ 代码的互操作性还不明确</li>
</ol>
<p>对于正在做自定义推理内核优化的团队，建议持续跟踪但先不要迁移。对于研究 GPU 编程语言方向的人，这是必读的——论文 <em>Fearless Concurrency on the GPU</em>（arXiv: 2606.15991）写得很清晰，值得花一个下午细读。</p>
<p>如果你手头有 RTX 5090 或者能接触 B200，可以用 Grout 跑个 benchmark 看看实际表现。对于大多数 ML 巘程师来说，vLLM 和 SGLang 仍然是短期内的务实选择——但 Rust GPU 写推理内核这个方向，三到五年内可能会变得非常重要。</p>
<hr>
<p><strong>信源</strong></p>
<ul>
<li><a href="https://github.com/nvlabs/cutile-rs">cuTile Rust GitHub</a> — NVIDIA Labs，381 stars，Apache 2.0</li>
<li><a href="https://arxiv.org/abs/2606.15991">Fearless Concurrency on the GPU (arXiv: 2606.15991)</a> — cuTile Rust 论文</li>
<li><a href="https://github.com/huggingface/grout">Grout — Qwen3 Inference Engine</a> — HuggingFace，基于 cuTile Rust</li>
<li><a href="https://github.com/NVlabs/cuda-oxide">cuda-oxide</a> — NVIDIA Labs，Rust-to-PTX 编译器，2768 stars</li>
<li><a href="https://github.com/Rust-GPU/Rust-GPU">Rust-GPU</a> — Embark Studios，Rust-to-SPIR-V，3169 stars</li>
<li><a href="https://news.ycombinator.com/item?id=48561410">HN 讨论</a> — cuTile Rust Show HN</li>
</ul>
]]></content:encoded></item><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>