9/8/2026

16g显存跑qwen3.8-27b-q3_k_p

Qwen3.8-27B Q3 FastMTP 当前方案

更新时间:2026-09-08

1. 当前硬件

  • GPU:NVIDIA GeForce RTX 4060 Ti
  • 显存:16,380 MiB(约 16GB)
  • 驱动:610.62
  • CPU:AMD Ryzen Threadripper 3960X,24 核 / 48 线程
  • 系统内存:约 128GB

2. 当前推理方案

  • 目标模型:Qwen3.8-27B Uncensored HauhauCS Aggressive Q3_K_P
  • 量化:Q3_K_P,模型文件约 12.52 GiB
  • FastMTP:已启用
  • FastMTP 草稿模型:FastMTP-32K.gguf,约 903MB
  • llama.cpp:作者指定提交 4df29be4f4c3673f428170fda944a5b19f743bb8
  • FastMTP 补丁:HauhauCS-FastMTP-llama.cpp.patch
  • 上下文:32,768 tokens(32K)
  • 并发槽位:1
  • 主模型:全 GPU 卸载
  • 草稿模型:全 GPU 卸载
  • KV cache:使用 GPU KV,不使用 --no-kv-offload
  • KV 类型:K/V 都是 q4_0
  • Flash Attention:开启
  • FastMTP 草稿深度:3
  • 思考模式:通过 -EnableThinking 开启
  • 服务地址:http://127.0.0.1:8080/v1
  • Metrics:http://127.0.0.1:8080/metrics

3. 启动方式

推荐双击:

text
Start-Qwen3.8-27B-Q3-OpenAI.cmd

该 .cmd 会自动向 PowerShell 脚本传入 -EnableThinking。

也可以手动启动:

powershell
.\Start-Qwen3.8-27B-Q3-OpenAI.ps1 -EnableThinking

直接启动但关闭思考:

powershell
.\Start-Qwen3.8-27B-Q3-OpenAI.ps1

修改端口:

powershell
.\Start-Qwen3.8-27B-Q3-OpenAI.ps1 -Port 8081 -EnableThinking

4. 启动脚本位置

text
D:\AI\MiniMax-H3\h3lite\Start-Qwen3.8-27B-Q3-OpenAI.ps1
D:\AI\MiniMax-H3\h3lite\Start-Qwen3.8-27B-Q3-OpenAI.cmd

脚本中最重要的参数如下:

text
--spec-draft-model <FastMTP-32K.gguf>
--spec-draft-ngl all
--ctx-size 32768
--gpu-layers all
--flash-attn on
--cache-type-k q4_0
--cache-type-v q4_0
--spec-type draft-mtp
--spec-draft-n-max 3
--spec-draft-p-min 0
--reasoning on/off
--reasoning-effort medium
--reasoning-preserve
--reasoning-format deepseek
--metrics

不要加入以下参数:

text
--no-kv-offload

该参数会把 KV cache 强制放进系统内存。在 32K 配置下会使速度从约 30 tok/s 降到约 8 tok/s。

5. 已验证速度

测试条件:固定英文提示词、非思考输出、最多生成 300 tokens。

配置 服务端生成速度 说明
32K,GPU KV,FastMTP 约 30.48 tok/s 推荐方案
32K,CPU KV,FastMTP 约 8.41 tok/s 不推荐
64K,CPU KV,FastMTP 约 8.47 tok/s 上下文更大但较慢
128K,CPU KV,FastMTP 约 5.66 tok/s 仅适合超长上下文

GPU KV 的 32K 测试还观察到:

  • GPU 利用率约 95%
  • GPU 功耗约 151W
  • 显存使用约 15.1GB
  • FastMTP 草稿接受率约 39.7%

实际速度会受提示词长度、思考模式、工具调用和草稿接受率影响。

6. 模型文件

模型目录:

text
E:\llama.cpp-models\HauhauCS\Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-MTP-GGUF

必需文件:

text
Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-Q3_K_P.gguf
Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-FastMTP-32K.gguf
HauhauCS-FastMTP-llama.cpp.patch

FastMTP sidecar 官方 SHA-256:

text
115e618e1f73cb50817ed5856f0551c6bf9c3d94df96f440eaca78dc63b8968b

本机下载的 sidecar 已与该 SHA-256 一致。

7. FastMTP 编译环境

编译输出目录:

text
C:\Tools\fastmtp-build\llama.cpp-exact\llama.cpp-4df29be4f4c3673f428170fda944a5b19f743bb8\build\bin

服务端:

text
C:\Tools\fastmtp-build\llama.cpp-exact\llama.cpp-4df29be4f4c3673f428170fda944a5b19f743bb8\build\bin\llama-server.exe

使用的工具链:

  • MSVC Build Tools:C:\BuildTools
  • CMake:C:\Tools\fastmtp-build\cmake-4.2.3-windows-x86_64
  • Ninja:C:\Tools\fastmtp-build\ninja.exe
  • CUDA Conda 环境:C:\Tools\fastmtp-build\cuda-conda
  • CUDA/NVCC:12.6 系列

8. OpenCode 配置

配置文件:

text
C:\Users\simon\.config\opencode\opencode.jsonc

本地模型使用:

text
local/qwen3.8-27b-q3

关键配置:

jsonc
{
  "permission": {
    "webfetch": "allow"
  },
  "provider": {
    "local": {
      "name": "local",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1",
        "timeout": false,
        "headerTimeout": false,
        "chunkTimeout": false
      },
      "models": {
        "qwen3.8-27b-q3": {
          "name": "qwen3.8-27b-q3",
          "reasoning": true,
          "interleaved": "reasoning_content",
          "tool_call": true,
          "limit": {
            "context": 32768,
            "output": 8192
          }
        }
      }
    }
  }
}

当前配置文件中还保留了 local/qwen3.8-27b-q3 的兼容覆盖项,同样设为 32K、8K 输出、支持 reasoning 和 tool call。

修改 OpenCode 配置后需要彻底重启 OpenCode。

9. 服务检查

确认服务是否启动:

powershell
Invoke-RestMethod http://127.0.0.1:8080/health

正常结果:

json
{"status":"ok"}

查看当前上下文和模型:

powershell
Invoke-RestMethod http://127.0.0.1:8080/props

应看到:

text
n_ctx       = 32768
model_alias = qwen3.8-27b-q3

查看速度和 FastMTP:

powershell
(Invoke-WebRequest http://127.0.0.1:8080/metrics).Content

重点字段:

text
llamacpp:predicted_tokens_seconds
llamacpp:prompt_tokens_seconds
llamacpp:spec_decode_num_draft_tokens_total
llamacpp:spec_decode_num_accepted_tokens_total
llamacpp:spec_decode_num_drafts_total

如果 spec_decode_num_draft_tokens_total 和 spec_decode_num_accepted_tokens_total 持续增加,说明 FastMTP 正在工作。

10. 停止服务

在运行服务的窗口按:

text
Ctrl+C

或者使用 PowerShell:

powershell
$listener = Get-NetTCPConnection -LocalPort 8080 -State Listen
Stop-Process -Id $listener[0].OwningProcess -Force

11. 常见问题

速度只有约 8 tok/s

检查启动参数中是否存在:

text
--no-kv-offload

32K 配置下应删除该参数,让 KV cache 尽量放入 GPU。

OpenCode 看不到思考内容

确认:

  1. 用 .cmd 启动,或手动加 -EnableThinking;
  2. OpenCode 模型包含 "reasoning": true;
  3. OpenCode 模型包含 "interleaved": "reasoning_content";
  4. 已彻底重启 OpenCode;
  5. 当前选择的是 local/qwen3.8-27b-q3。

OpenCode 的 webfetch 失败

确认:

  1. OpenCode 配置包含 "permission": { "webfetch": "allow" };
  2. 模型声明包含 "tool_call": true;
  3. 8080 服务正常;
  4. 使用的是本地模型而不是远程同名模型。

本地 API 已验证能够生成 webfetch 工具调用;网页抓取实际由 OpenCode 执行,不是 llama-server 执行。

想使用更大上下文

可以在启动时覆盖:

powershell
.\Start-Qwen3.8-27B-Q3-OpenAI.ps1 -ContextSize 65536 -EnableThinking

但超过 32K 后很可能需要 CPU KV,速度会明显下降。当前 RTX 4060 Ti 16GB 上,32K + GPU KV 是速度和上下文的较佳平衡点。