Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计异常

msmodelslimmsmodelslim 搜索

Agent Skill

msmodelslim 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,024

周安装

44

GitHub Stars

60

下载量

359
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:msmodelslim(msmodelslim 搜索)
来源仓库:https://github.com/ascend-ai-coding/awesome-ascend-skills
仓库路径:skills/msmodelslim
安装命令:
npx skills add https://github.com/ascend-ai-coding/awesome-ascend-skills --skill msmodelslim
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ascend-ai-coding/awesome-ascend-skills --skill msmodelslim

简介

msmodelslim 用于查找、检索和筛选相关信息。

  • 适合根据关键词或任务场景快速定位候选结果。
  • 可在 Codex、Claude 等平台中使用,需结合原始文档验证。
  • 安装前建议确认权限范围和维护状态。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

msModelSlim - Ascend Model Compression Tool

MindStudio ModelSlim (msModelSlim) is a model compression tool optimized for Huawei Ascend AI processors. It supports quantization and compression for LLMs, MoE models, and multimodal models.


Quick Start

One-Click Quantization (V1 - Recommended)

V1 automatic quantization uses configuration files from lab_practice/ directory.

# Basic W8A8 quantization for Qwen2.5-7B-Instruct
# Config files located at: lab_practice/<model_series>/<model>-<quant_type>-v1.yaml
msmodelslim quant \
    --model_path /path/to/Qwen2.5-7B-Instruct \
    --save_path /path/to/output \
    --device npu \
    --model_type Qwen2.5-7B-Instruct \
    --config_path /path/to/msmodelslim/lab_practice/qwen2.5/qwen2.5-7b-w8a8-v1.yaml \
    --trust_remote_code True

# MoE model quantization (Qwen3-30B-A3B W4A8)
msmodelslim quant \
    --model_path /path/to/Qwen3-30B-A3B \
    --save_path /path/to/output \
    --device npu \
    --model_type Qwen3-30B \
    --config_path /path/to/msmodelslim/lab_practice/qwen3_moe/qwen3-30b-w4a8-v1.yaml \
    --trust_remote_code True

# Multi-device distributed quantization
msmodelslim quant \
    --model_path /path/to/model \
    --save_path /path/to/output \
    --device npu:0,1,2,3 \
    --model_type Qwen2.5-72B-Instruct \
    --config_path /path/to/msmodelslim/lab_practice/qwen2.5/qwen2.5-72b-w8a8c8-v1.yaml \
    --trust_remote_code True
Note: Find config files in lab_practice/ directory of msmodelslim repository: - Structure: lab_practice/<model_series>/<model>-<quant_type>-v1.yaml - Example: lab_practice/qwen2.5/qwen2.5-7b-w8a8-v1.yaml

Traditional Quantization (V0)

cd msmodelslim
python3 example/Qwen/quant_qwen.py \
    --model_path /path/to/Qwen2.5-7B-Instruct \
    --save_directory /path/to/output \
    --calib_file example/common/boolq.jsonl \
    --w_bit 8 --a_bit 8 \
    --device_type npu \
    --trust_remote_code True

Installation

Prerequisites

  • Python: 3.8+ (3.9+ recommended for some environments)
  • CANN: 8.2.RC1+ (8.3.RC1 or 8.5.0 recommended)
  • PyTorch Ascend: Ascend Extension for PyTorch

Install Steps

# 1. Clone repository
git clone https://gitcode.com/Ascend/msmodelslim.git
cd msmodelslim

# 2. Run installation script
bash install.sh

# 3. For Atlas 300I Duo (sparse quantization support)
cd ${PYTHON_SITE_PACKAGES}/msmodelslim/pytorch/weight_compression/compress_graph/
sudo bash build.sh ${CANN_INSTALL_PATH}/ascend-toolkit/latest
chmod -R 550 build
Note: Do not run msmodelslim commands from within the source directory to avoid module path conflicts.

See references/installation.md for detailed environment setup.


Quantization Types

TypeWeightActivationDescriptionUse Case
W8A8INT8INT8Standard 8-bit quantizationGeneral use, balanced precision/performance
W8A16INT8FP16Weight-only quantizationHigher precision needs (MindIE only)
W4A8INT4INT8Low-bit weight quantizationHigher compression ratio
W8A8C8INT8INT8 + KV CacheWith KV Cache quantizationLong sequence inference
W8A8SINT8 SparseINT8Sparse quantizationAtlas 300I Duo optimization
W16A16SFP16 SparseFP16Float sparse quantizationHigh compression needs

Quantization Type Selection

PriorityRecommended Type
Precision firstW8A16 > W8A8 > W4A8
Memory firstW4A8 > W8A8 > W8A16
Long sequenceW8A8C8 (with KV Cache quant)
Atlas 300I DuoW8A8S or W16A16S

BFLOAT16 Model Notes

For models with torch_dtype=bfloat16 weights (e.g., Qwen3-30B-A3B):

If you encounter AclNN_Parameter_Error(EZ1001): Tensor self not implemented for DT_BFLOAT16, this is likely a Docker image issue, not a msmodelslim limitation.

Quick Diagnosis:

# Test if torch_npu works correctly
python3 -c "import torch; import torch_npu; a = torch.tensor(1).npu(); print('NPU OK')"

If this fails, your Docker image has compatibility issues. Try:

  1. Use a different/updated Docker image
  2. Reinstall torch_npu matching your CANN version
  3. Ensure CANN 8.3.RC1+ for BF16 support
Container Setup: See ascend-docker for proper Docker container creation with NPU device mappings. Refer to references/docker-setup.md for msmodelslim-specific container configuration.

Algorithm Selection

Outlier Suppression Algorithms

AlgorithmDescriptionWhen to Use
SmoothQuantCo-scale activation and weightStandard outlier suppression
QuaRotOrthogonal rotation matrixHigh precision requirements
Iterative SmoothIterative smoothingComplex distributions
Flex SmoothGrid search for optimal alpha/betaDifferent architectures
KV SmoothKV Cache smoothingKV Cache quantization

Quantization Algorithms

AlgorithmDescriptionWhen to Use
AutoRoundSignSGD optimization for rounding4-bit ultra-low quantization
GPTQColumn-wise optimizationHigh precision weight quantization
SSZIterative scale/offset searchUneven weight distributions
PDMIXDynamic (prefill) + static (decode)Large model inference
FA3Per-head INT8 attentionLong sequence, MLA models
MinMaxMin-max range statisticsBasic quantization
HistogramHistogram distribution analysisFilter outliers

Quick Selection Guide

  • Beginners: Use one-click quantization with --config_path pointing to lab_practice/ config files
  • Precision priority: QuaRot + AutoRound
  • Long sequence: FA3 + KVCache Quant
  • Custom model: See references/model-integration.md

See references/quantization-algorithms.md for algorithm details.


Supported Models

Large Language Models

Model SeriesOne-ClickV0 ScriptNotes
Qwen3example/Qwen/Qwen3-8B/14B/32B
Qwen2.5example/Qwen/7B/32B/72B/Coder
Qwen2-example/Qwen/7B/72B
DeepSeek-V3example/DeepSeek/V3/V3.1/V3.2, R1
LLaMA-example/Llama/LLaMA2, LLaMA3.1
GLM-example/GLM/GLM-4, GLM-5
InternLM2-example/InternLM2/InternLM2-20B
Kimi-example/Kimi/Kimi K2
HunYuan-example/HunYuan/HunYuan-A52B

MoE Models

ModelOne-ClickNotes
Qwen3-MoEQwen3-30B-A3B, Qwen3-235B-A22B
DeepSeek MoEDeepSeek-V2, V3 series

Multimodal Models

TypeModelsExample Script
Vision-LanguageQwen-VL, Qwen2-VL, Qwen3-VL, InternVL2, LLaVA, GLM-4.1Vexample/multimodal_vlm/
GenerationFLUX, SD3, HunyuanVideo, OpenSoraPlan, Wan2.1example/multimodal_sd/

See references/model-support.md for complete support matrix.


Custom Model Integration

Quick Overview

  1. Create adapter file: msmodelslim/model/my_model/model_adapter.py
  2. Define adapter class: Inherit TransformersModel + interface classes
  3. Implement interfaces: handle_dataset, init_model, generate_model_visit, etc.
  4. Register model: Add to config/config.ini

Example

from msmodelslim.model.interface_hub import ModelSlimPipelineInterfaceV1
from msmodelslim.model.common.transformers import TransformersModel

class MyModelAdapter(TransformersModel, ModelSlimPipelineInterfaceV1):
    def handle_dataset(self, dataset, device):
        return self._get_tokenized_data(dataset, device)

    def init_model(self, device):
        return self._load_model(device)

    def generate_model_visit(self, model):
        from msmodelslim.model.common.layer_wise_forward import generated_decoder_layer_visit_func
        yield from generated_decoder_layer_visit_func(model)

    def generate_model_forward(self, model, inputs):
        from msmodelslim.model.common.layer_wise_forward import transformers_generated_forward_func
        yield from transformers_generated_forward_func(model, inputs)

See references/model-integration.md and scripts/model_adapter_template.py for complete guide.


Precision Auto-Tuning

Sensitive Layer Analysis

# Analyze model sensitivity
msmodelslim analyze --model_path /path/to/model --model_type Qwen2.5-7B-Instruct

Analysis Algorithms:

  • std: Standard deviation based (recommended for general use)
  • quantile: Quantile/IQR based (for long-tail distributions)
  • kurtosis: Kurtosis based (for extreme value detection)

Auto-Tuning Strategy

Standing High: Binary search to minimize fallback layers while maintaining precision.

# Use auto-tuning config
msmodelslim quant \
    --model_path /path/to/model \
    --save_path /path/to/output \
    --model_type Qwen2.5-7B-Instruct \
    --config_path /path/to/auto_tuning_config.yaml

See references/precision-tuning.md for tuning strategies.


Deployment

vLLM-Ascend

# Online service
vllm serve /path/to/quantized-model \
    --served-model-name "Qwen2.5-7B-w8a8" \
    --max-model-len 4096 \
    --quantization ascend

# Offline inference (Python)
from vllm import LLM, SamplingParams

llm = LLM(
    model="/path/to/quantized-model",
    max_model_len=4096,
    quantization="ascend"
)
outputs = llm.generate(["Hello"], SamplingParams(temperature=0.6))

MindIE

# Deploy with MindIE
# See MindIE documentation for details

Weight Conversion

# Convert to AutoAWQ/AutoGPTQ format
python3 example/common/ms_to_vllm.py --input /path/to/quantized --output /path/to/converted

See references/deployment.md for deployment details.


Output Files

After quantization, the output directory contains:

output/
├── config.json                      # Original model config
├── generation_config.json           # Generation config
├── quant_model_description.json     # Quantization description
├── quant_model_weight_w8a8.safetensors  # Quantized weights
├── tokenizer_config.json            # Tokenizer config
├── tokenizer.json                   # Tokenizer vocabulary
└── vocab.json                       # Vocabulary (if applicable)

Troubleshooting

Common Issues

Q: Out of memory during quantization?

# Use layer-by-layer quantization (default in V1)
# Or use CPU quantization
msmodelslim quant --device cpu ...

Q: Precision degradation after quantization?

  • Use higher precision type (W8A8 instead of W4A8)
  • Check lab_practice/ for best practice configs
  • Enable outlier suppression algorithms
  • See references/precision-tuning.md

Q: Model type not supported?

Q: How to enable debug logging?

export MSMODELSLIM_LOG_LEVEL=DEBUG
msmodelslim quant ...

Scripts & Assets

Scripts

Config Templates (assets/)


Official References


Related Skills

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

39.67%
按下载量换算142

Claude

28.12%
按下载量换算101

Cursor

19.25%
按下载量换算69

Gemini CLI

9.09%
按下载量换算33

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills