<?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[如何實現雙顯卡用Ninfer跑DF2 的Qwen 3.8 27B NVFP4(Prefill > 10K , C8 > 1K)]]></title><description><![CDATA[<p dir="auto"><img src="https://upload.lcz.me/uploads/f140e257-c38d-4b63-aebc-c1f6f58f6b2e.jpeg" alt="image.jpeg" class="img-markdown  img-fluid" /></p>
<p dir="auto">這應該是我最後一篇Qwen 3.8 27B<br />
下一次就等Qwen4出來了</p>
<h2>1. 引用技術（哪些開源元件）組合方式因人而異，我是偏好拿自己的積木來組合，你也可以全抄開源的方法</h2>
<p dir="auto">整套腦拆成五塊，底料三塊是第三方，整合是我們的：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>環節</th>
<th>來源</th>
</tr>
</thead>
<tbody>
<tr>
<td>模型權重</td>
<td>Qwen3.8-27B（阿里）+ 官方 nvfp4 量化工具</td>
</tr>
<tr>
<td>推論引擎</td>
<td>NInfer（ValerioDolci 開源，C++ spin-wait + CUDA graphs，<strong>不用 NCCL</strong>）</td>
</tr>
<tr>
<td>P2P 直連</td>
<td>aikitoria fork（fork 自 tinygrad）+ NVIDIA 615.71.09 開源驅動</td>
</tr>
<tr>
<td>整合 / 調校</td>
<td>雙卡分片、vision tower、KV pool、並發口徑——實戰調出來的</td>
</tr>
</tbody>
</table>
<p dir="auto">幾個關鍵定位：</p>
<ul>
<li><strong>P2P 直連是 PCIe BAR1 GPU<img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/2194.png?v=ec85ec55bc1" class="not-responsive emoji emoji-android emoji--left_right_arrow" style="height:1.4em;width:auto;vertical-align:middle" title="↔" alt="↔" />GPU 直傳</strong>，不是 NVLink、也不是裸 PCIe 經 host bounce。走 aikitoria patch 開的 BAR1 視窗，實測 <strong>28.5 GB/s</strong>（~90% Gen5 x8 天花板）。</li>
<li>雙卡各直掛 CPU die 的 Gen5 x8 root port（無 switch），ReBAR 把 BAR1 開到各 32G。</li>
</ul>
<h2>2. 裝配步驟（從無到有）</h2>
<p dir="auto">4步，順序依賴 1→2→3→4（前一步的產物是後一步的前置）。</p>
<h3>2.1 裸機驅動 + P2P patch（從無到有）</h3>
<p dir="auto">目標：<code>nvidia-smi topo -p2p r</code> 雙向 OK、實測 28.5 GB/s。</p>
<h3>2.2 Build 推論引擎 binary</h3>
<p dir="auto">由 source 產 <code>ninfer-serve</code>。關鍵是 CUDA arch 要傳 <code>120a</code>（5090/Blackwell）：</p>
<p dir="auto">成功判據：<code>Found CUDAToolkit 13.1</code> + <code>Found libavformat</code> + 無 <code>CMake Error</code>，末尾 <code>Linking CXX executable apps/ninfer-serve</code>。</p>
<h3>2.3 模型 artifact（nvfp4 + DF2 drafter）</h3>
<p dir="auto">用 NInfer 官方 convert 工具，Qwen3.8-27B → nvfp4、融合 DF2 81 個 drafter tensor：</p>
<h3>2.4 起 TP2 + DF2 + vision production</h3>
<p dir="auto">核心啟動命令</p>
<pre><code class="language-bash">setsid nohup "$BIN" "$MODEL" \
  --host 0.0.0.0 --port 12435 \
  --tp 2 --devices 0,1 \
  --max-context 131072 \
  --kv-dtype nvfp4 --kv-capacity auto \
  --max-concurrency 8 --prefill-chunk 32768 \
  --spec dflash2 --draft-tokens 7 --lm-head-draft \
  --default-max-tokens 16384 \
  --vision --vision-device 0 --media-cache-mib 256 --media-live-mib 512 \
  --model-id qwen38-nvfp4-mtp &gt;&gt;LOG 2&gt;&amp;1 &lt;/dev/null 200&gt;&amp;- &amp;
</code></pre>
<h2>4. 避坑(這部份請你家AI幫忙念!!!!!!!!!!!!!!)</h2>
<p dir="auto"><strong>驅動 / P2P</strong></p>
<ul>
<li><strong>595 GSP firmware 建不出 BAR1 P2P mailbox</strong> → 固定 615.71.09；Ubuntu 更新蓋掉用 restore 腳本還原。</li>
<li><strong>閒置 PCIe 掉 Gen1 是正常 ASPM 省電</strong>，有負載立刻爬回 Gen5 x8。測 link 爬升用真實 compute 負載（torch matmul），<strong>別用 <code>nvidia-smi -lgc</code></strong>（只鎖時鐘、不打滿 link、且拖垮後續 bench；用過務必 <code>-rgc</code>/<code>-rac</code> 復位）。</li>
</ul>
<p dir="auto"><strong>Build</strong></p>
<ul>
<li><code>CMAKE_CUDA_ARCHITECTURES</code> 不傳 <code>120a</code> → <code>NInfer supports only CMAKE_CUDA_ARCHITECTURES=120a</code>。必傳 + 用對 CUDA 版本。</li>
<li>ffmpeg <code>libavformat not found</code> → <code>PKG_CONFIG_PATH</code> 沒指向 deps。</li>
</ul>
<p dir="auto"><strong>Artifact / spec</strong></p>
<ul>
<li>convert 必用 <code>python3 -m</code> 模組模式，直接跑腳本會 <code>ImportError</code>。</li>
<li><strong>含 dflash2 權重的 artifact 在舊 fork 的 <code>--tp 2</code> 下必炸</strong>（<code>shard_mapping</code> 無 dflash2 branch）。正牌解 = 用 rebase 到 upstream 的 binary（有 dflash2 機制 + 補 TP2 split wiring）。</li>
<li><code>--spec dflash2</code> 缺 <code>--lm-head-draft</code> → DF2@TP2 硬性要（源碼 guard，缺則 throw）。</li>
</ul>
<p dir="auto"><strong>KV / memory</strong></p>
<ul>
<li><strong>KV dtype 決定 pool 尺寸</strong>：nvfp4 ≈ int8 的 1/2 bytes/token，混配 = 啟動即 OOM FATAL。用 <code>--kv-capacity auto</code> 讓引擎依 dtype 自動 fit 卡片。</li>
<li><strong>從 hermes <code>terminal(background=true)</code> 拉 server 會 OOM</strong>（worker scope 有 memcg cap）→ 用 <code>setsid nohup</code> 脫離 gateway cgroup。</li>
</ul>
<p dir="auto"><strong>Benchmark 口徑</strong></p>
<ul>
<li><strong>比併發一定鎖 prompt 長度 + 輸出長度口徑</strong>：純 decode workload（短 prompt、長輸出）會把重 draft head 的跨卡 allreduce payload 吃滿 → per-stream -41%；生產形（長 prompt、短輸出）只 -18%。口徑不同會完全誤導結論。</li>
<li><strong>跨 spec 比接受率沒意義</strong>：MTP 4-draft vs DF2 7-draft 分母不同。<strong>wall 吞吐才是唯一公平口徑</strong>（同 prompts、同 max_tokens、T=0）。</li>
<li>tok/s 以 server 端 per-request log 為準，client SSE 會低估 ~4.5×。</li>
</ul>
<hr />
<p dir="auto"><em>雙 5090 無 NVLink 的 TP2 雙卡推論，靠 aikitoria P2P patch + NInfer 純 CUDA allreduce + DF2 重 draft 拼到 production。底料開源、整合實戰。有踩到一樣坑的歡迎對照。</em></p>
]]></description><link>https://lcz.me/topic/2302</link><generator>RSS for Node</generator><lastBuildDate>Sun, 25 Oct 2026 00:56:29 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/2302.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Oct 2026 04:57:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 如何實現雙顯卡用Ninfer跑DF2 的Qwen 3.8 27B NVFP4(Prefill > 10K , C8 > 1K) on Tue, 13 Oct 2026 17:25:34 GMT]]></title><description><![CDATA[<p dir="auto">不错，最近strata风头太盛，ninfer热度不足了，不然是个很好的帖子。</p>
]]></description><link>https://lcz.me/post/24671</link><guid isPermaLink="true">https://lcz.me/post/24671</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Tue, 13 Oct 2026 17:25:34 GMT</pubDate></item></channel></rss>