kali20gakki/msAgent / skills/quantizer/msmodelslim-model-dequant
msmodelslim-model-dequant
Verified为 msModelSlim 适配流程注入反量化能力。先识别模型权重是否可反量化,再实现反量化脚本并接入 model_adapter。当前仅覆盖 FP8 的 per-block 与 per-channel 两类;若格式不确定或无公开反量化规则,要求用户提供反量化脚本或浮点权重。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.8 KB |
| scripts/inspect_safetensors.py | script | 3.1 KB |
scripts/inspect_safetensors.py
View on GitHub# -------------------------------------------------------------------------
# This file is part of the MindStudio project.
# Copyright (c) 2026 Huawei Technologies Co.,Ltd.
#
# MindStudio is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# -------------------------------------------------------------------------
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import argparse
import fnmatch
import json
import os
from collections import defaultdict
from safetensors import safe_open
def parse_args():
parser = argparse.ArgumentParser(
description="Inspect tensor shape and dtype from safetensors by wildcard pattern."
)
parser.add_argument(
"-m",
"--model-path",
required=True,
help="Model directory containing model.safetensors.index.json",
)
parser.add_argument(
"-p",
"--pattern",
default="*",
help="Wildcard pattern for tensor names, e.g. 'model.layers.*.mlp*.weight*'",
)
parser.add_argument(
"--limit",
type=int,
default=0,
help="Limit output rows, 0 means no limit",
)
return parser.parse_args()
def load_weight_map(model_path: str):
index_path = os.path.join(model_path, "model.safetensors.index.json")
with open(index_path, "r", encoding="utf-8") as f:
model_index = json.load(f)
return model_index.get("weight_map", {})
def main():
args = parse_args()
weight_map = load_weight_map(args.model_path)
if not weight_map:
print("No weight_map found in model.safetensors.index.json")
return
filtered_names = [name for name in weight_map if fnmatch.fnmatch(name, args.pattern)]
if not filtered_names:
print(f"No tensors matched pattern: {args.pattern}")
return
file_to_names = defaultdict(list)
for name in filtered_names:
file_to_names[weight_map[name]].append(name)
rows = []
for file_name, names in sorted(file_to_names.items()):
file_path = os.path.join(args.model_path, file_name)
with safe_open(file_path, framework="pt", device="cpu") as f:
available = set(f.keys())
for name in sorted(names):
if name not in available:
rows.append((name, "N/A", "N/A", file_name))
continue
tensor = f.get_tensor(name)
rows.append((name, str(tuple(tensor.shape)), str(tensor.dtype), file_name))
if args.limit > 0:
rows = rows[: args.limit]
print(f"Matched tensors: {len(rows)} (pattern={args.pattern})")
print("tensor_name\tshape\tdtype\tfile")
for name, shape, dtype, file_name in rows:
print(f"{name}\t{shape}\t{dtype}\t{file_name}")
if __name__ == "__main__":
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: 198k | 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 |