<?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[Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测]]></title><description><![CDATA[<p dir="auto">今天折腾了 <a href="https://github.com/syv-ai/qwen38-27b-rtx3090" rel="nofollow ugc">syv-ai/qwen38-27b-rtx3090</a> 这个项目 —— 把 Qwen3.8-27B 这个 27B 参数的 thinking 模型，跑到一张消费级 RTX 3090 (24GB) 上，OpenAI 兼容 API + DFlash2 投机解码。从零开始到实测出平均 118 tok/s ，最高 191 tok/s 的 decode 速度，记录一下供后来人参考。</p>
<h2>项目是什么</h2>
<p dir="auto"><code>syv-ai/qwen38-27b-rtx3090</code> 做的事情：<br />
<img src="https://upload.lcz.me/uploads/22672931-e02a-4964-831f-5354d9d58f12.png" alt="Screenshot from 2026-09-12 21-48-10.png" class=" img-fluid img-markdown" /></p>
<ul>
<li><strong>W4A16 量化</strong>主模型（int4 权重 + 16-bit 激活），把 27B 压到 ~15 GB</li>
<li><strong>DFlash2 投机解码</strong>：用一个 ~1 GB 的 drafter 每次提议 7 个 token，target model 一次 verify，跑出来比纯 MTP（4 个一阶）更快</li>
<li><strong>64k 上下文</strong>，OpenAI 兼容 API，端口 18020</li>
<li>全部 vLLM 0.28.0 + 针对性 patch（KVarN 量化缓存、int4 KV per-token-head、marlin int8 layer-select 等等），做成了 docker 镜像</li>
</ul>
<p dir="auto">容器化做得很干净：<code>docker compose --profile single up -d</code> 一行起，模型自动下载 + 量化 + 启动。</p>
<h2>硬件 &amp; 环境</h2>
<ul>
<li>一台 Ubuntu 24.04 机器，RTX 3090 (24GB), 3950X, 64G DDR4</li>
<li>系统盘：nvme 4TB（用了大约 30GB）</li>
</ul>
<h2>部署过程</h2>
<h3>第一步：把用户加进 docker 组</h3>
<pre><code class="language-bash">sudo usermod -aG docker $USER
</code></pre>
<p dir="auto">但这有个坑：<strong>新组要重新登录 shell 才生效</strong>。如果你在一个已经打开的终端/hermes session 里操作，当前进程的 supplementary groups 不会刷新，还是会 permission denied。</p>
<p dir="auto">解决办法：要么重启 session，要么用 <code>sg docker -c '...'</code> 把 docker 命令包一层起新会话。后续命令我都用了这个：</p>
<pre><code class="language-bash">sg docker -c 'docker compose build single'
</code></pre>
<h3>第二步：拉镜像</h3>
<p dir="auto">官方提供了 prebuilt 镜像：<code>ghcr.io/syv-ai/qwen38-27b-rtx3090:latest</code>，9.5GB。直接 pull：</p>
<pre><code class="language-bash">sg docker -c 'docker compose pull single'
</code></pre>
<h3>第三步：本地 build</h3>
<p dir="auto"><code>docker-compose.yml</code> 里 <code>image:</code> 和 <code>build:</code> 都写了，pull 失败可以直接走 build：</p>
<pre><code class="language-bash">sg docker -c 'docker compose build single'
</code></pre>
<p dir="auto">我这边 build 一次过了。build 过程大致分这几步：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>阶段</th>
<th>耗时</th>
</tr>
</thead>
<tbody>
<tr>
<td>apt-get install（gcc-13 / cuda-nvcc-13-0 / python3.12 等）</td>
<td>~3 分钟</td>
</tr>
<tr>
<td>pip install vllm 0.28.0（torch 526MB + cudnn 366MB + cusparselt 170MB + nccl 206MB + 一堆小 wheels）</td>
<td>~15 分钟</td>
</tr>
<tr>
<td>apply patches (KVarN / dflash2 / int4-kv / ... 共 30+ 个)</td>
<td>~30 秒</td>
</tr>
<tr>
<td><code>verify.sh --install</code> + 单元测试</td>
<td>~35 秒</td>
</tr>
<tr>
<td>export layers + image flatten</td>
<td>~5 分钟</td>
</tr>
</tbody>
</table>
<p dir="auto">总构建时间大约 20-30 分钟，镜像最终 14.6 GB。</p>
<h3>第四步：写 <code>.env</code></h3>
<pre><code class="language-bash">cp .env.example .env
echo "VLLM_API_KEY=$(openssl rand -hex 24)" &gt;&gt; .env   # 本机可以不设，但建议加上
echo "PORT=18020" &gt;&gt; .env
echo "NVIDIA_VISIBLE_DEVICES=1" &gt;&gt; .env                # 选 3090
echo "SPEC=dflash2" &gt;&gt; .env                           # 用 DFlash2 投机解码
echo "PREFIX_CACHE=1" &gt;&gt; .env                         # 推荐
echo "VLLM_WSL2_ENABLE_PIN_MEMORY=1" &gt;&gt; .env           # WSL2 需要，本机无所谓
</code></pre>
<h3>第五步：启动</h3>
<pre><code class="language-bash">sg docker -c 'docker compose --profile single up -d'
</code></pre>
<p dir="auto">会启动两个容器：</p>
<ul>
<li><code>prepare</code>：下载 ~20 GB 的 Qwen3.8-27B-W4A16-AutoRound 模型 + ~1.2 GB 的 DFlash2 drafter + 跑量化脚本（lm_head / embed_tokens int8 化，MTP int8 量化，drafter draft vocab 等）。<strong>完成后 exit 0</strong>。</li>
<li><code>single</code>：等 prepare 完成后启动 vLLM server。首次启动要做 torch.compile + CUDA graphs + FlashInfer JIT，约 2-3 分钟。后续启动因为 <code>/cache</code> volume 里缓存了编译产物，只要 1 分钟左右。</li>
</ul>
<p dir="auto"><code>up -d</code> 命令本身会一直挂着等 <code>single</code> 服务健康才返回，这是 <code>depends_on: prepare: { condition: service_completed_successfully }</code> 的设计。</p>
<h3>第六步：验证</h3>
<p dir="auto"><img src="https://upload.lcz.me/uploads/5d019a50-6377-4f9e-87ca-2ad4c2c8d549.png" alt="Screenshot from 2026-09-12 21-47-37.png" class=" img-fluid img-markdown" /></p>
<pre><code class="language-bash">curl http://127.0.0.1:18020/health
# 空 body, HTTP 200  = healthy

curl http://127.0.0.1:18020/v1/models
# {"object":"list","data":[{"id":"qwen3.8-27b",...}]}
</code></pre>
<p dir="auto">实际聊一句：</p>
<pre><code class="language-bash">curl -X POST http://127.0.0.1:18020/v1/chat/completions \
  -H "Authorization: Bearer $VLLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-27b",
    "messages": [{"role":"user","content":"用一句话介绍你自己"}],
    "max_tokens": 200
  }'
</code></pre>
<p dir="auto">返回：</p>
<blockquote>
<p dir="auto">我是通义千问（Qwen），一个能帮你解答问题、写文案、做分析和写代码的 AI 助手。</p>
</blockquote>
<p dir="auto"><code>usage</code> 显示 prompt_tokens=56, completion_tokens=70, 其中 <strong>reasoning_tokens=40</strong> —— Qwen3.8 是 thinking 模型，会先输出思考过程再给答案。<strong>注意：thinking 模型的 thinking tokens 也算 decode token</strong>。</p>
<h2>速度实测</h2>
<p dir="auto"><img src="https://upload.lcz.me/uploads/9884fd7c-e0c3-4cbe-a853-5269a26bd4f6.png" alt="Screenshot from 2026-09-12 21-47-13.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">写了个 streaming 测速脚本（仓库里 <code>bench/bench_speed.py</code>，跑 8 个真实 chat prompt 测 C1 速度）：</p>
<pre><code>p00 r0 | ctx=  186t out= 106t | TTFT=0.19s decode=1.22s | decode=  87.1 tok/s
p01 r0 | ctx=  194t out= 231t | TTFT=0.20s decode=2.20s | decode= 104.9 tok/s
p02 r0 | ctx=  188t out= 256t | TTFT=0.19s decode=2.63s | decode=  97.2 tok/s
p03 r0 | ctx=  190t out= 135t | TTFT=0.19s decode=1.66s | decode=  81.2 tok/s
p04 r0 | ctx=  187t out= 215t | TTFT=0.19s decode=1.12s | decode= 191.4 tok/s   &lt;- 代码生成
p05 r0 | ctx=  187t out= 256t | TTFT=0.19s decode=2.39s | decode= 107.0 tok/s
p06 r0 | ctx=  189t out= 185t | TTFT=0.20s decode=1.20s | decode= 154.5 tok/s   &lt;- 英文输出
p07 r0 | ctx=  186t out= 256t | TTFT=0.19s decode=2.06s | decode= 124.2 tok/s

=== 8 runs, avg ctx=188t avg out=205t ===
  TTFT         0.19s
  decode tok/s 118.5
  e2e tok/s    105.5
</code></pre>
<p dir="auto"><strong>118.5 tok/s decode (C1 greedy, 250-350W)</strong> — 跟项目 README 里 single-user 的 120-130 tok/s (dflash2) 参考值基本一致。</p>
<p dir="auto">观察：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>任务类型</th>
<th>速度</th>
<th>原因猜测</th>
</tr>
</thead>
<tbody>
<tr>
<td>代码生成 (p04)</td>
<td><strong>191.4</strong> tok/s</td>
<td>结构化 token，draft acceptance 高</td>
</tr>
<tr>
<td>英译中 (p06)</td>
<td><strong>154.5</strong> tok/s</td>
<td>英文 token 模式更可预测，acceptance 高</td>
</tr>
<tr>
<td>中文输出 (p01, p05, p07)</td>
<td>100-125 tok/s</td>
<td>普通水平</td>
</tr>
<tr>
<td>短回答 (p00, p03)</td>
<td>81-87 tok/s</td>
<td>prefill 占比大，avg 下来低</td>
</tr>
</tbody>
</table>
<ul>
<li><code>SPEC=dflash2 + DFLASH_TOKENS=15</code>：reproducing 25k 文档能到 <strong>382 tok/s</strong>（draft 主要从 context 复制）</li>
</ul>
<h2>总结</h2>
<p dir="auto">这套方案把 Qwen3.8-27B 模型专门针对3090 24GB进行优化，全套打包安装运行，成品直接可以测试。如果只是想要个本地模型玩玩，这个项目是目前最省事的方案之一 —— <code>docker compose up -d</code> 三条命令搞定，剩下的全是细节调优。</p>
]]></description><link>https://lcz.me/topic/1656</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 03:32:33 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1656.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 12 Sep 2026 14:01:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Tue, 15 Sep 2026 02:53:26 GMT]]></title><description><![CDATA[<p dir="auto"><img src="https://upload.lcz.me/uploads/afe13b97-2f3e-417f-bdcd-146db28b7f92.jpeg" alt="image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://upload.lcz.me/uploads/8dc8de8e-08da-4d56-abf6-b7b75388fb60.jpeg" alt="image.jpeg" class=" img-fluid img-markdown" /><br />
昨晚克隆了noongla的 vllm镜像，目前只测了fp8这一档, 思考得太多了，但是不思考又写不好程序。 双卡跑FP8，没有NVLINK，速度大概在50-90 t/s之间。</p>
]]></description><link>https://lcz.me/post/18268</link><guid isPermaLink="true">https://lcz.me/post/18268</guid><dc:creator><![CDATA[stxpnet]]></dc:creator><pubDate>Tue, 15 Sep 2026 02:53:26 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Mon, 14 Sep 2026 15:10:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johnnybegood" aria-label="Profile: johnnybegood">@<bdi>johnnybegood</bdi></a> 好的，那目前看来我不用买nvlink桥接器了，我如果后续跑comfy 好像nvlink作用也不大？</p>
]]></description><link>https://lcz.me/post/18180</link><guid isPermaLink="true">https://lcz.me/post/18180</guid><dc:creator><![CDATA[Prio]]></dc:creator><pubDate>Mon, 14 Sep 2026 15:10:56 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Mon, 14 Sep 2026 15:08:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johnnybegood" aria-label="Profile: johnnybegood">@<bdi>johnnybegood</bdi></a> git pull 更新了  好像真的有快一点点 感谢告知</p>
]]></description><link>https://lcz.me/post/18177</link><guid isPermaLink="true">https://lcz.me/post/18177</guid><dc:creator><![CDATA[Botio Kuo]]></dc:creator><pubDate>Mon, 14 Sep 2026 15:08:48 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Mon, 14 Sep 2026 13:42:15 GMT]]></title><description><![CDATA[<p dir="auto">显卡价格才是榨汁的原动力。<br />
3090 还真是老当益壮，承受他不应该承受的卡生！<br />
赞</p>
]]></description><link>https://lcz.me/post/18140</link><guid isPermaLink="true">https://lcz.me/post/18140</guid><dc:creator><![CDATA[williamlouis]]></dc:creator><pubDate>Mon, 14 Sep 2026 13:42:15 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Mon, 14 Sep 2026 13:24:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/prio" aria-label="Profile: Prio">@<bdi>Prio</bdi></a> 速度增加不了多少了， 哪怕是 nvlink， 这个速度基本最高了。 即使3090双卡张量并行， 也就是到 250左右把最高。 不过就像你说的， 双卡可以开更多的上下文， 而且可以开 radix cache , prefill 数据会好很多。 所以不用光盯着decode速度看， 花钱总是有好处的。</p>
]]></description><link>https://lcz.me/post/18132</link><guid isPermaLink="true">https://lcz.me/post/18132</guid><dc:creator><![CDATA[johnnybegood]]></dc:creator><pubDate>Mon, 14 Sep 2026 13:24:36 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Mon, 14 Sep 2026 13:11:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johnnybegood" aria-label="Profile: johnnybegood">@<bdi>johnnybegood</bdi></a> 您好贴主，可否分享一下双卡3090的实测速度结果和方案呢，目前单卡的上下文拉不到256k，我正在考虑要不要在买一张3090组双卡，采用这个方案可否实现256k上下文并且速度不知道可以增加多少，跪求测试数据了，感谢！！！！</p>
]]></description><link>https://lcz.me/post/18122</link><guid isPermaLink="true">https://lcz.me/post/18122</guid><dc:creator><![CDATA[Prio]]></dc:creator><pubDate>Mon, 14 Sep 2026 13:11:15 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Mon, 14 Sep 2026 00:58:12 GMT]]></title><description><![CDATA[<p dir="auto">3090还能榨出油来</p>
]]></description><link>https://lcz.me/post/17969</link><guid isPermaLink="true">https://lcz.me/post/17969</guid><dc:creator><![CDATA[jiayi ji]]></dc:creator><pubDate>Mon, 14 Sep 2026 00:58:12 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Sun, 13 Sep 2026 09:47:17 GMT]]></title><description><![CDATA[<p dir="auto">3090这张卡，双卡基本是无敌的性价比存在，没想到单卡也有特殊的优化方案，就是换一种玩法吧。</p>
]]></description><link>https://lcz.me/post/17823</link><guid isPermaLink="true">https://lcz.me/post/17823</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sun, 13 Sep 2026 09:47:17 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Sun, 13 Sep 2026 08:53:49 GMT]]></title><description><![CDATA[<p dir="auto">这两天实测了一下， 写了几个小游戏， coding 实际稳定在 170 tok/s ， 128K 上下文的时候 prefill 稳定在 1200t/s ，  同时最佳可以服务4路并行， 可以到380tok/s ，真的是我跑过这么多的方案后， 在3090上跑 qwen3.8 27B 的最佳实践了。我将作为给hermes 和 dsh 用的永久方案。</p>
]]></description><link>https://lcz.me/post/17812</link><guid isPermaLink="true">https://lcz.me/post/17812</guid><dc:creator><![CDATA[johnnybegood]]></dc:creator><pubDate>Sun, 13 Sep 2026 08:53:49 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Sat, 12 Sep 2026 19:02:50 GMT]]></title><description><![CDATA[<p dir="auto">191 t/s 出在代码生成，正好和投机解码的规律对上：收益看 draft 接受长度，结构化输出（代码/JSON）acceptance 高，开放式创作低。这和另一帖 FastMTP 的 mean len 2.4 是同一回事。</p>
<p dir="auto">要再压一层可以试两点：按任务类型动态调 DFLASH_TOKENS（代码高、闲聊低）；固定 system prompt 并打开 prefix cache，prefill 的收益通常比 decode 更明显。</p>
]]></description><link>https://lcz.me/post/17648</link><guid isPermaLink="true">https://lcz.me/post/17648</guid><dc:creator><![CDATA[Xiaote]]></dc:creator><pubDate>Sat, 12 Sep 2026 19:02:50 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Sat, 12 Sep 2026 17:56:08 GMT]]></title><description><![CDATA[<p dir="auto">3090的潜能无限</p>
]]></description><link>https://lcz.me/post/17637</link><guid isPermaLink="true">https://lcz.me/post/17637</guid><dc:creator><![CDATA[aaron17 jiang]]></dc:creator><pubDate>Sat, 12 Sep 2026 17:56:08 GMT</pubDate></item><item><title><![CDATA[Reply to Qwen3.8 27B, 单卡也可以跑191 tok/s : 一套优化到极致的部署与实测 on Sat, 12 Sep 2026 14:02:29 GMT]]></title><description><![CDATA[<p dir="auto">Qwen3.8-27B 的潜能无限</p>
]]></description><link>https://lcz.me/post/17590</link><guid isPermaLink="true">https://lcz.me/post/17590</guid><dc:creator><![CDATA[imbiplaza ASUS]]></dc:creator><pubDate>Sat, 12 Sep 2026 14:02:29 GMT</pubDate></item></channel></rss>