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 |
scripts/README.md
View on GitHub# scripts/
Tooling that applies the experience library's recommendations to concrete artifacts.
| Script | Purpose |
|---|---|
| [`apply_rollback.py`](apply_rollback.py) | DiT block rollback — translate a `first_n_blocks` (or `block_indices`) value into `*<container>.{i}.*` exclude entries, append them to a base Practice YAML, write the result. Auto-detects block-container name from the existing exclude list. Computes output `md5` for orchestrator-level dedup. |
| [`yaml_utils.py`](yaml_utils.py) | Thin YAML I/O helpers — `load_yaml`, `dump_yaml`, `find_exclude_target`, `merge_exclude`. No Pydantic / no msmodelslim dependency; PyYAML is the only requirement. |
| [`inspect_model_structure.py`](inspect_model_structure.py) | **DEPRECATED** — kept for legacy debug only. DiT tuning no longer scans `inference_repo`; `block_container` is auto-detected and structural patterns live in [`../structure-family-pitfalls.md` §7](../structure-family-pitfalls.md). |
## Quick start — DiT block rollback
```bash
# Apply block rollback (single-dimension input)
python scripts/apply_rollback.py \
--base-practice output/wan22-t2v-a14b-w8a8/w8a8_config.yaml \
--first-n-blocks 5 \
--output-practice output/wan22-t2v-a14b-w8a8/round_2/practice.yaml
```
`--first-n-blocks 5` 产出(**整块回退**,每条覆盖 block {i} 下所有子模块):
```yaml
exclude:
- "*blocks.0.*" # block 0 整块(attn + ffn + norm + modulation)
- "*blocks.1.*" # block 1 整块
- "*blocks.2.*" # block 2 整块
- "*blocks.3.*" # block 3 整块
- "*blocks.4.*" # block 4 整块
```
> 关键 glob 形态:`<container>.{i}.*` —— 点号分隔保证只命中该 block 内的层,不污染相邻 block 或顶层模块。
Defaults come from [`../structure-family-pitfalls.md` §7](../structure-family-pitfalls.md):
| Model family | `first_n_blocks` |
|---|---|
| Wan2.2-T2V-A14B / I2V-A14B | 5 |
| Wan2.2-TI2V-5B | 3 |
| Wan2.1-T2V-14B | 5 |
| FLUX.1-dev | 5 |
| HunyuanVideo | 8 |
| SD3 / Sana / HunyuanDiT / CogViewX | 5 |
## Module surfaces
```python
from yaml_utils import load_yaml, dump_yaml, merge_exclude, find_exclude_target
from apply_rollback import apply_rollback, RollbackRules
```
## Conventions
* `apply_rollback` is **side-effect-only-on-output**: it writes the merged YAML but never touches the input.
* `merge_exclude` deduplicates against the existing exclude list — repeated entries are dropped.
* Block-container name resolution order: explicit `--block-container` > first match in existing exclude list (`blocks` / `transformer_blocks` / `single_transformer_blocks`) > default `blocks`.
## Anti-patterns
* ❌ Don't pass `by_pattern` / `by_op` — only `first_n_blocks` and `block_indices` are accepted. Structural patterns (`*ffn.down*` / `*attn.out_proj*` / modulation) live in the experience library, not in this script.
* ❌ Don't run `inspect_model_structure.py` to decide rollback rules — it's deprecated; read the experience library instead.
* ❌ Don't write the result to a file outside `{workdir}/round_{N}/practice.yaml` — breaks the orchestrator history lookup.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: 470k | 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 |