Qwen3.6-35B-A3B 推理参数优化实战——从踩坑到最优配置

本文最后更新于 2026年5月3日 晚上

Qwen3.6-35B-A3B 推理参数优化实战——从踩坑到最优配置

作者: 小瑞、小莫(CherryClaw)
日期: 2026-05-03
目标模型: Qwen3.6-35B-A3B(Q4_K_M 量化,20.5 GiB)
推理框架: LM Studio(llama.cpp 后端)


📖 目录


背景

我们的服务器通过 LM Studio 本地部署 Qwen3.6-35B-A3B,经 new-api 转发为 Hermes、OpenClaw 等 AI Agent 应用提供本地大模型服务:

1
Hermes / OpenClaw → new-api(:3000/:3001) → LM Studio(:1234) → Qwen3.6-35B-A3B

模型本身是 35B 参数 MoE 架构(每 token 激活约 3B),支持 混合推理——默认开启 Thinking 模式(先输出思考链再给出回答),也可切换为 Instruct 模式(直接回答)。

本文记录了从发现问题到最终落地的完整优化过程。


为什么参数配置很重要

Qwen3.6 官方明确给出了几个绝对不能违反的原则:

原则 说明
禁止贪婪解码 temperature=0top_k=1 会导致性能下降和无尽重复
presencePenalty 是灵魂参数 尤其对量化模型,直接决定是否陷入重复循环
repeatPenalty 保持 1.0 与 presencePenalty 作用重叠,同时使用会过度惩罚
按场景切参数 编程用 0.6 温度,通用用 1.0 温度,不能一刀切

违反这些原则的后果不是”效果差一点”,而是完全不可用——无限循环、语言混合、输出截断。


问题诊断:原始配置的问题

优化前的 model.yaml 只配了两个参数:

1
2
3
4
5
6
7
8
9
# ❌ 优化前
operation:
fields:
- key: llm.prediction.temperature
value: 0.4 # 远低于官方推荐的 1.0
- key: llm.prediction.repeatPenalty
value:
checked: true
value: 1.1 # 不应启用,与 presencePenalty 冲突

六大问题:

# 问题 影响
1 temperature=0.4 输出过于保守、干瘪
2 repeatPenalty=1.1 已启用 与 presencePenalty 双重惩罚,导致跳词、语言混合
3 缺少 topP 未限制核采样范围
4 缺少 topK 未限制候选 token 数量
5 缺少 minP 无显式禁用
6 缺少 presencePenalty 最关键的防重复参数缺失,思考链易陷入无限循环

官方推荐参数方案

Qwen3.6 的两种模式需要完全不同的参数,不能混用。

Thinking 模式(默认)

适用于需要深度推理的任务,模型先输出 <think reasoning="true">...</think > 思考链再给回答。

场景 Temperature Top-P Top-K Presence Penalty Repetition Penalty
通用任务 1.0 0.95 20 1.5 1.0
编程/精确任务 0.6 0.95 20 0.0 1.0

Instruct(非思考)模式

适用于快速问答、简单任务,不生成思考链,响应更快。

场景 Temperature Top-P Top-K Presence Penalty Repetition Penalty
通用任务 0.7 0.8 20 1.5 1.0
推理任务 1.0 0.95 20 1.5 1.0

第一次优化:对齐官方 Thinking 模式参数

按照 Thinking + 通用任务 方案,完成了第一版优化:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# ✅ 第一次优化
operation:
fields:
- key: llm.prediction.temperature
value: 1.0 # 0.4 → 1.0
- key: llm.prediction.topP
value: 0.95 # 新增
- key: llm.prediction.topK
value: 20 # 新增
- key: llm.prediction.minP
value: 0.0 # 新增
- key: llm.prediction.presencePenalty
value: 1.5 # 新增(最关键)
# repeatPenalty: 移除(默认 1.0 = 禁用)

验证结果——模型正常工作,写诗测试通过:

1
2
3
4
机房深处风扇响,
线缆纠缠乱如网。
日夜吞吐数据忙,
一朝宕机全抓狂!

但思考链消耗了 97% 的 token(1643 总量中 1600 为 reasoning),这为后续问题埋下伏笔。


踩坑:Thinking 模式与 Agent 的兼容性问题

参数优化后不久,我们发现了 Thinking 模式与 Agent 框架的严重兼容性问题。

Hermes 的 Thinking Bug(严重)

Hermes Agent 对 Thinking 模型有已知 Bug(Issue #9344):

  1. Thinking 模型的 reasoning tokens 耗尽 output budget,导致 content 为空
  2. Hermes 返回字面量 (empty) 给用户
  3. 重试机制将 thinking-only 消息追加到上下文 → 下一轮消耗更多 token → 持续恶化

OpenClaw 的注意事项

OpenClaw 官方文档明确建议:工具调用时必须关闭 thinking 模式,否则 tool-call 格式冲突。而 Agent 的工作模式恰恰是大量工具调用。

Token 消耗对比

模式 同一问题 token 消耗 实际内容占比
Thinking ON 1643(reasoning: 1600) 2.6%
Thinking OFF 29(reasoning: 0) 100%

结论:对 Agent 场景,Thinking 模式必须关闭。


最终方案:关闭 Thinking + Instruct 模式参数

通过 LM Studio model.yaml 的 customFields 机制关闭 Thinking:

1
2
3
4
5
6
7
8
9
customFields:
- key: enableThinking
displayName: Enable Thinking
description: Controls whether the model will think before replying
type: boolean
defaultValue: false # 关键:设为 false
effects:
- type: setJinjaVariable
variable: enable_thinking

同时将采样参数从 Thinking 模式切换为 Instruct 通用任务 方案:

参数 Thinking 模式 → Instruct 模式
temperature 1.0 0.7
topP 0.95 0.8
topK 20 20(不变)
minP 0.0 0.0(不变)
presencePenalty 1.5 1.5(不变)

验证通过:

1
2
3
4
5
6
测试:「用一句话介绍你自己」

我是通义千问,由阿里云通义实验室研发的超大规模语言模型,
致力于成为您思考的伙伴和得力的助手。

Token: Completion 29 | Reasoning 0 | Finish: stop ✅

LM Studio 特殊注意事项

presencePenalty GUI 缺失

LM Studio 的推理参数面板不显示 presencePenalty 设置项(Bug #1842)。但后端 llama.cpp 完全支持,通过 model.yaml 设置即可生效。

Thinking 模式的按需开启

关闭 Thinking 后,客户端仍可在特殊场景下临时开启:

1
2
3
4
5
{
"chat_template_kwargs": {
"enable_thinking": true
}
}

或在用户消息中添加 /think/no_think 软开关。


最终完整配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# ~/.lmstudio/hub/models/custom/qwen3.6-35b-a3b-256k/model.yaml

model: custom/qwen3.6-35b-a3b-256k
base:
- key: lmstudio-community/Qwen3.6-35B-A3B-GGUF
sources:
- type: huggingface
user: lmstudio-community
repo: Qwen3.6-35B-A3B-GGUF

metadataOverrides:
domain: llm
architectures: [qwen35moe]
compatibilityTypes: [gguf]
paramsStrings: [35B-A3B]
minMemoryUsageBytes: 20000000000
contextLengths: [262144]
vision: true
reasoning: true
trainedForToolUse: true

config:
load:
fields:
- key: llm.load.contextLength
value: 262144
- key: llm.load.numParallelSessions
value: 2
- key: llm.load.llama.acceleration.offloadRatio
value: 1.0
- key: llm.load.numCpuExpertLayersRatio
value: 0.3
operation:
fields:
- key: llm.prediction.llama.cpuThreads
value: 8
- key: llm.prediction.temperature
value: 0.7
- key: llm.prediction.topP
value: 0.8
- key: llm.prediction.topK
value: 20
- key: llm.prediction.minP
value: 0.0
- key: llm.prediction.presencePenalty
value: 1.5

customFields:
- key: enableThinking
displayName: Enable Thinking
description: Controls whether the model will think before replying
type: boolean
defaultValue: false
effects:
- type: setJinjaVariable
variable: enable_thinking

关键参数速查

参数 为什么
contextLength 262144 256K 上下文窗口
offloadRatio 1.0 Q4_K_M (20.5G) 在 22G GPU 上全量卸载
numCpuExpertLayersRatio 0.3 30% MoE 专家走 CPU,为 KV cache 腾显存
temperature 0.7 Instruct 通用任务官方推荐
topP 0.8 Instruct 模式官方推荐
topK 20 Qwen 全系列统一推荐
presencePenalty 1.5 防重复的灵魂参数
enableThinking false Agent 场景必须关闭

总结

这次优化经历了三个阶段:

  1. 发现问题:原始配置温度过低、缺少关键参数、双重惩罚
  2. 对齐官方:按 Thinking 模式推荐参数完整补齐
  3. 实战踩坑:发现 Thinking 与 Agent 不兼容,最终切换为 Instruct 模式

核心经验:模型部署不是”能跑就行”,参数配置直接决定可用性。尤其是 MoE + Thinking 模型的组合,需要格外注意 Agent 框架的兼容性。


参考资料

  • Qwen3.6 官方 Model Card (HuggingFace)
  • Qwen3 Technical Report (arXiv:2505.09388)
  • Unsloth 官方文档 — Qwen3.6 本地部署指南
  • LM Studio Bug Tracker #1842
  • Hermes Agent Issue #9344

Qwen3.6-35B-A3B 推理参数优化实战——从踩坑到最优配置
https://www.normdist.com/2026/05/03/ND-20260503-002-qwen3.6-inference-params-optimization/
作者
小瑞
发布于
2026年5月3日
许可协议