kali20gakki/msAgent / skills/quantizer/quantization-expert-experience-tuning-rules
quantization-expert-experience-tuning-rules
Verified量化专家经验调优库:按「L1 通用专家调优意见 → L2 结构化专家调优意见 → L3 模型专属专家调优意见」三级递进, 输出量化精度调优的完整手段(离群值抑制 / 量化方法·粒度·对称性选型 / 校准集调整 / 敏感层回退 / 模型专属策略), 每条结论附专家原因分析与专家意见可信度等级。 本 Skill 是专家经验库,负责说明可选离群值抑制算法并询问用户选择哪些算法,以及回答「怎么调、哪些层需要回退及为什么」;不运行离群值抑制 processor,不修改 YAML、不执行量化、不做 EP 检查 / 服务化 / 任务评测。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.8 KB |
| cross-model-pitfalls.md | markdown | 8.3 KB |
| models/README.md | markdown | 1.3 KB |
| models/deepseek/deepseek-v3.md | markdown | 2.9 KB |
| models/deepseek/deepseek-v4.md | markdown | 2.5 KB |
| models/glm/glm-4-moe.md | markdown | 1.3 KB |
| models/glm/glm-5.md | markdown | 1.4 KB |
| models/minimax/minimax-m.md | markdown | 1.6 KB |
| scripts/README.md | markdown | 3.1 KB |
| scripts/apply_rollback.py | script | 10.1 KB |
| scripts/inspect_model_structure.py | script | 7.1 KB |
| scripts/yaml_utils.py | script | 4.2 KB |
| structure-family-pitfalls.md | markdown | 14.2 KB |
models/deepseek/deepseek-v3.md
View on GitHub# DeepSeek-V3 / R1 / V3.1 / V3.2 专属经验
> 层级:L3。结构模型类背景同 L2 的「MoE」「MLA 低秩投影」。本节只记该模型类独有、不可迁移的坑。
## 1. MLA 低秩投影排除(该模型类高频、跨版本稳定)
- 排除清单高频出现:`*kv_b_proj`、`*wq_b`、`*wk`、`*weights_proj`(V3.2 还有 `*q_a_proj`/`*kv_a_proj*`)。
- 原因:MLA 用低秩投影把 KV 压缩进隐空间再做逐头展开,`kv_b_proj`/`wq_b` 这类投影是隐空间↔头空间的转换枢纽,量化误差会被展开到所有注意力头并沿序列传播,属于典型的结构性敏感层;基于此结构特性做结构性排除,而非逐层试错。专家意见可信度:高。
- 注意:**同一模型类内不同版本命名略有差异**,务必按目标模型实际 `named_modules` 确认,不要照抄旧版本。
## 2. `fa3_quant` 逐头注意力量化(MLA 独有)
- DeepSeek-V3/R1/V3.1 系使用 `fa3_quant` 处理器做 **Q/K/V 逐头(per-head)INT8/FP8 量化**,适应不同注意力头的分布差异。
- 配置要点:`fa_q` 用 `per_token`,`fa_k`/`fa_v` 用 `per_head`(或 `per_token`),dtype 可为 `fp8_e4m3` 或 `int8`。
- 原因:MLA 的不同注意力头承载不同语义分工、激活分布差异大,per-head 粒度比整体 per-tensor 更能贴合各头分布,避免个别大值头拉低全局量化精度。
- **尾部敏感层排除**:常排除 `model.layers.0/1/2.*`(首层)以及尾部若干层(如 R1 排除 46~61,V3.1 排除 3~14 + 46~61),避免 fa3 量化误差干扰。原因:首层误差向后续所有层传播,尾部层输出直接决定最终生成质量。专家意见可信度:中(层号随版本/训练差异变化,须实测)。
## 3. 尾部 `model.layers.61.*` 敏感层提级
- W4A8 场景下,多份实践将 `model.layers.61.mlp.experts*` 单列提级到 W8A8(其余 experts 走 W4A8),并相应在 W4A8 include 中排除 `model.layers.61.*`。
- 原因:这是「专家整体 W4 + 指定高敏感层专家 W8」的典型落地——尾部层在推理中是上下文汇聚与最终输出的关键阶段,其专家承担的误差经后续层累积后直接作用于输出,所以对高敏感尾部层单独提级;层号 61 是该模型类某规模的实测结论,**移植到其他规模/版本需按敏感层分析重新确认**。专家意见可信度:中。
## 4. 离群值抑制组合(该模型类典型搭配)
- W4A8 常见:`quarot` + `flex_awq_ssz`(enable `up-down`)+ `flex_smooth_quant`(enable `norm-linear`/`ov`/`up-down`)。
- W8A8 常见:`quarot` + `flex_smooth_quant`(enable `norm-linear`/`ov`)。
- 原因:DeepSeek 这类大规模 MoE 激活分布长尾明显,单一手段难以压住离群值;QuaRot 先做正交旋转集中能量,再叠加 smooth 类算法把激活量化难度转移到权重,多层抑制才能把异常大值压缩进有效比特。专家意见可信度:中。
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |