Quant tuning quantize

From kali20gakki/msAgent · View interactive version

Quant tuning quantize is an AI agent skill from the GitHub repository kali20gakki/msAgent. 执行模型量化。通过 msmodelslim quant 依据 Practice YAML 对模型进行量化。

How to use this skill

Skill file

Skill: Quant Tuning Quantize

Overview

解决什么:依据 Practice YAML 配置,调用 msmodelslim quant 执行模型量化。

不解决什么:

执行主体:msmodelslim quant(execute 调用,以 exit code 判定成败)


协作关系

quantization-accuracy-tuning-orchestrator (workflow)
        │
        ▼ 调用
quant-tuning-quantize (tool)
        │
        ▼ CLI
  msmodelslim quant
        │
        ▼ 输出
  量化后的模型权重

执行步骤

┌─────────────────┐
│ 输入检查        │
│ - practice_path │
│ - model_path    │
│ - save_path     │
└────────┬────────┘
         ▼
┌─────────────────┐
│ 参数校验        │
│ 路径存在且可读   │
└────────┬────────┘
         ▼
┌─────────────────┐
│ execute:        │
│ msmodelslim quant│
└────────┬────────┘
         ▼
┌─────────────────┐
│ 结果处理        │
│ - 检查 exit code │
│ - 记录产物路径   │
│ - 错误上报       │
└─────────────────┘

输入参数

| 参数 | 类型 | 必需 | 说明 |

|------|------|------|------|

| config_path | string | ✅ | Practice YAML 路径 |

| model_path | string | ✅ | 原始模型路径 |

| save_path | string | ✅ | 量化产物保存路径;须体现调优轮次,推荐 {workdir}/round_{N}/quantized(如 round_1/quantized) |

| model_type | string | ✅ | 模型类型名 |

| device | string | ✅ | 设备类型,如 npu:0 |

| trust_remote_code | bool | ❌ | 是否信任远程代码 |


CLI 调用

msmodelslim quant \
  --model_path "${MODEL_PATH}" \
  --save_path "${WORKDIR}/round_1/quantized" \
  --device npu:0 \
  --model_type "${MODEL_TYPE}" \
  --config_path "${CONFIG_PATH}" \
  --trust_remote_code False

save_path 必须包含轮次与产物目录层级,便于 orchestrator 区分各轮权重,例如 {workdir}/round_1/quantized、{workdir}/round_2/quantized。

成功判定:exit code 为 0,且 ${SAVE_PATH} 下出现量化权重产物。

错误处理

| 错误类型 | 处理 |

|----------|------|

| msmodelslim 未安装 | 按 prepare_environment.md 安装后重试 |

| 路径不存在 | 检查路径后重试或中止 |

| 量化失败 | 报 stderr 摘要,等待 orchestrator 决策 |

| 超时 | 按 Agent execution_timeout 处理,不上层续跑 |


输出结果

成功

向 orchestrator 回显:

量化完成:
- 产物路径: /workspace/output/round_1/quantized  (与 `--save_path` 一致,须含 round_N/quantized)
- 耗时: (可选)

失败

立即中止,回显命令名与 stderr 关键摘要,不续跑其它命令。


磁盘管理


约束


常见错误

| 错误 | 原因 | 解决 |

|------|------|------|

| practice.yaml not found | 配置文件不存在 | 检查 config_path |

| out of memory | 设备内存不足 | 换设备 |

若错误不在上述常见错误中或者多次解决后依然未解决,依据错误上报,按照错误上报格式返回至 orchestrator。


检查清单

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.