<?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[双魔改卡实现P2P的新路线]]></title><description><![CDATA[<h1>双魔改卡实现P2P的新路线</h1>
<p dir="auto">魔改卡通常采用特殊 PCB / VBIOS，因此和正常卡 在 PCIe ReBAR / BAR1 方面存在一些差异。</p>
<p dir="auto">除了主板是否支持ReBAR，魔改卡的BAR1也是其中一堵高墙，最近发现除了传统的“ReBAR + P2P 驱动”路线之外，现在其实出现了一条<strong>专门绕开 256MB BAR1 限制的新路线</strong>。</p>
<p dir="auto">如果这条路线能够进一步成熟，那么对于使用魔改卡推理，会挺有意义。</p>
<hr />
<h2>一、传统双魔改卡 P2P 的路线</h2>
<p dir="auto">目前双卡 P2P，比较常见的思路大致是：</p>
<pre><code class="language-text">双 GPU
  ↓
开启 Above 4G Decoding / ReBAR
  ↓
让 GPU BAR1 尽可能扩大
  ↓
使用修改后的 NVIDIA P2P 驱动
  ↓
CUDA P2P
  ↓
NCCL P2P
  ↓
双 GPU 直接通信
</code></pre>
<p dir="auto">正常的消费级 NVIDIA GPU，只要平台、VBIOS 和驱动条件合适，就可以通过这种方式实现 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 的直接 PCIe 通信。</p>
<p dir="auto">这样做最大的好处就是：</p>
<pre><code class="language-text">GPU0 → PCIe → GPU1
</code></pre>
<p dir="auto">数据可以直接从一张显卡到另一张显卡，<strong>不需要先经过系统内存再绕回来</strong>。</p>
<p dir="auto">对于大模型推理来说，这一点很重要，尤其是 Tensor Parallel（TP）。因为 TP 运行过程中需要频繁进行 GPU 间通信。</p>
<hr />
<h2>二、问题就在 BAR1</h2>
<p dir="auto">问题是，传统线路要求BAR1与VRAM大小一致，由于魔改的显存是硬长出来的，BAR1还是原来的大小，甚至30系列可能只有256MB。有些魔改卡可以通过更换 VBIOS来实现ReBAR，使BAR1 达到要求，但一是很多卡刷了VBIOS也无法解决，二是刷VBIOS是有风险的。</p>
<hr />
<h1>三、新路线</h1>
<p dir="auto">最近发现这个项目：</p>
<p dir="auto"><strong>barlink-pcie</strong></p>
<p dir="auto">项目地址：</p>
<p dir="auto"><a href="https://github.com/efschu/barlink-pcie" rel="nofollow ugc">https://github.com/efschu/barlink-pcie</a></p>
<p dir="auto">它解决这个问题的思路并不是：</p>
<blockquote>
<p dir="auto">“想办法把 256MB BAR1 变成 20GB。”</p>
</blockquote>
<p dir="auto">而是：</p>
<blockquote>
<p dir="auto"><strong>既然 BAR1 只有 256MB，那就把它当成一个“小窗口”来使用。</strong></p>
</blockquote>
<p dir="auto">也就是说，它不要求整个 20GB 显存都映射到 BAR1。</p>
<p dir="auto">而是让 GPU 在 BAR1 里建立一个比较小的通信窗口，然后把需要传输的数据分批通过这个窗口直接发送到另外一张显卡。</p>
<p dir="auto">简单理解就是：</p>
<pre><code class="language-text">传统方案：

GPU0
 ↓
整个显存映射到大 BAR1
 ↓
PCIe
 ↓
GPU1


新方案：

GPU0
 ↓
小块 BAR1 窗口
 ↓
PCIe
 ↓
GPU1 BAR1
 ↓
GPU1 显存
</code></pre>
<p dir="auto">256MB 在这里并不是“只能传 256MB 数据”，而只是：</p>
<p dir="auto"><strong>一次能够直接映射和传输的窗口比较小。</strong></p>
<p dir="auto">数据量大了，就分成多轮传输。</p>
<p dir="auto">因此：</p>
<pre><code class="language-text">256MB BAR1
</code></pre>
<p dir="auto">并不再成为：</p>
<pre><code class="language-text">20GB 显存无法 P2P
</code></pre>
<p dir="auto">这样的绝对限制。</p>
<hr />
<h1>四、是否有人实际跑通</h1>
<p dir="auto">这不是单纯的理论方案。</p>
<p dir="auto">项目作者提到，这套 BAR1→BAR1 DMA 的方案已经在：</p>
<ul>
<li>RTX 3080 20GB</li>
<li>BAR1 = 256MB</li>
<li>双 3080</li>
<li>甚至跨代 GPU</li>
</ul>
<p dir="auto">上做过实际测试。</p>
<p dir="auto">这个方案就是最初从 htsglang 项目里的相关实现独立出来的，后来单独做成了 <code>barlink-pcie</code> 项目。</p>
<p dir="auto">倒是一个非常值得试一下的方向：</p>
<pre><code class="language-text">RTX 3080 20GB
BAR1 = 256MB
        ↓
不追求扩大 BAR1
        ↓
直接利用现有 256MB BAR1
        ↓
BAR1 → BAR1 DMA
        ↓
PCIe GPU → GPU
</code></pre>
]]></description><link>https://lcz.me/topic/1856</link><generator>RSS for Node</generator><lastBuildDate>Fri, 23 Oct 2026 22:35:18 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1856.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Sep 2026 07:50:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 双魔改卡实现P2P的新路线 on Tue, 22 Sep 2026 07:16:08 GMT]]></title><description><![CDATA[<p dir="auto">感兴趣，请大佬继续跟踪</p>
]]></description><link>https://lcz.me/post/20005</link><guid isPermaLink="true">https://lcz.me/post/20005</guid><dc:creator><![CDATA[Capri Swicord]]></dc:creator><pubDate>Tue, 22 Sep 2026 07:16:08 GMT</pubDate></item><item><title><![CDATA[Reply to 双魔改卡实现P2P的新路线 on Tue, 22 Sep 2026 01:36:31 GMT]]></title><description><![CDATA[<p dir="auto">只能说这功能需要实测</p>
]]></description><link>https://lcz.me/post/19886</link><guid isPermaLink="true">https://lcz.me/post/19886</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Tue, 22 Sep 2026 01:36:31 GMT</pubDate></item><item><title><![CDATA[Reply to 双魔改卡实现P2P的新路线 on Mon, 21 Sep 2026 11:42:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/starryskyknight" aria-label="Profile: starryskyknight">@<bdi>starryskyknight</bdi></a> 我也要</p>
]]></description><link>https://lcz.me/post/19745</link><guid isPermaLink="true">https://lcz.me/post/19745</guid><dc:creator><![CDATA[johnnybegood]]></dc:creator><pubDate>Mon, 21 Sep 2026 11:42:32 GMT</pubDate></item><item><title><![CDATA[Reply to 双魔改卡实现P2P的新路线 on Mon, 21 Sep 2026 10:29:36 GMT]]></title><description><![CDATA[<p dir="auto">感謝分享 很受用 來研究看看</p>
]]></description><link>https://lcz.me/post/19731</link><guid isPermaLink="true">https://lcz.me/post/19731</guid><dc:creator><![CDATA[starryskyknight]]></dc:creator><pubDate>Mon, 21 Sep 2026 10:29:36 GMT</pubDate></item></channel></rss>