Ascend/msagent / skills/quantizer/msmodelslim-adapter-verification
msmodelslim-adapter-verification
Verified为 msModelSlim 适配器执行功能性验证。适用于基础适配器开发完成后,自动执行四步验证(测试模型、全回退量化、权重一致性与可加载/保存、实际量化规则校验)并输出通过/失败结论。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.6 KB |
| references/dit/README.md | markdown | 3.2 KB |
| references/dit/fallback_config.yaml | config | 1.5 KB |
| references/dit/index.example.jsonl | other | 1.4 KB |
| references/dit/w8a8_dynamic_full_model.yaml | config | 1.3 KB |
| references/dit/w8a8_mxfp8_full_model.yaml | config | 1.6 KB |
| references/llm/fallback_config.yaml | config | 473 B |
| references/llm/w8a8_dynamic_full_model.yaml | config | 497 B |
| references/llm/w8a8_static_full_model.yaml | config | 497 B |
| references/verification_guide.md | markdown | 8.5 KB |
| references/vlm/fallback_config.yaml | config | 562 B |
| references/vlm/w8a8_dynamic_full_model.yaml | config | 652 B |
| references/vlm/w8a8_static_full_model.yaml | config | 652 B |
| scripts/step1_generate_test_model.py | script | 8.5 KB |
| scripts/step2_run_quantization.py | script | 2.7 KB |
| scripts/step2_run_quantization_dit.py | script | 13.7 KB |
| scripts/step3_verify_weights.py | script | 2.4 KB |
| scripts/step4_verify_quant_description.py | script | 4.3 KB |
scripts/step3_verify_weights.py
View on GitHub#!/usr/bin/env python3
"""步骤3:验证权重一致性(精简版)。"""
import argparse
import glob
import os
import sys
import torch
def _load_weights(model_path):
try:
from safetensors.torch import load_file
files = sorted(glob.glob(os.path.join(model_path, "*.safetensors")))
if files:
merged = {}
for file in files:
merged.update(load_file(file))
return merged
except Exception:
pass
pt_path = os.path.join(model_path, "pytorch_model.bin")
if os.path.exists(pt_path):
return torch.load(pt_path, map_location="cpu", weights_only=True)
return {}
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--original-path", required=True)
parser.add_argument("--quantized-path", required=True)
parser.add_argument(
"--reference-weights",
default=None,
help="Explicit baseline weights directory. If set, used as the left-"
"hand side of the comparison instead of --original-path. Useful when "
"step1 used --skip-random-model and the real-weight baseline lives "
"elsewhere on disk.",
)
parser.add_argument("--tolerance", type=float, default=1e-5)
args = parser.parse_args()
left_path = args.reference_weights or args.original_path
left = _load_weights(left_path)
right = _load_weights(args.quantized_path)
if not left or not right:
print("[ERROR] step3失败: 权重加载失败")
return 1
left_keys = set(left.keys())
right_keys = set(right.keys())
if left_keys != right_keys:
print("[ERROR] step3失败: 权重键不一致")
print(f"[INFO] 仅左侧数量: {len(left_keys - right_keys)}")
print(f"[INFO] 仅右侧数量: {len(right_keys - left_keys)}")
return 1
max_diff = 0.0
for key in sorted(left_keys):
l = left[key]
r = right[key]
if l.shape != r.shape:
print(f"[ERROR] step3失败: 形状不一致 {key}")
return 1
diff = torch.abs(l.float() - r.float()).max().item()
if diff > max_diff:
max_diff = diff
if diff > args.tolerance:
print(f"[ERROR] step3失败: 权重差异超阈值 {key} diff={diff:.2e}")
return 1
print(f"[OK] step3完成: max_diff={max_diff:.2e}")
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |