huaweicloud/huaweicloud-skills

huawei-cloud-msmodelslim-model-adapt

|- Create basic Transformers model adapters for msModelSlim.

Voir la source
Document Skill original

Rendu depuis le dépôt source en conservant titres, exemples, code, tableaux, liens et images.

Huawei Cloud msModelSlim Model Adapter

Overview

This skill guides how to create basic adapters for new models to run W8A8/W4A16 quantization workflows in msModelSlim.

Architecture: Model Analysis -> Adapter Creation -> Registration -> Verification (4 Steps)

Related Skills:

  • huawei-cloud-msmodelslim-model-analysis - Model structure analysis

before adapter implementation

  • huawei-cloud-ascend-profiler-db-explorer - Optional: Performance

analysis after deployment

Scope

Supported:

  • Decoder-only LLM
  • Understanding VLM (text/LLM backbone only)

Not supported:

  • Multimodal generation (Stable Diffusion/Flux/Wan)
  • Encoder-only models
  • Non-Transformers architectures

Architecture

text
┌─────────────────────────────────────────────────────────────┐
│              msModelSlim Model Adapter Skill                │
├─────────────────────────────────────────────────────────────┤
│  ┌──────────────────┐    ┌──────────────────────────────┐  │
│  │  Model Analysis │───▶│    Adapter Creation          │  │
│  │  - config.json  │    │    - LLM Adapter Template     │  │
│  │  - modeling_*.py│    │    - VLM Adapter Template     │  │
│  └──────────────────┘    │    - Required Interfaces     │  │
│                          └──────────────────────────────┘  │
│                                    │                       │
│                                    ▼                       │
│                          ┌──────────────────┐             │
│                          │  Registration    │             │
│                          │  & Installation  │             │
│                          └──────────────────┘             │
│                                    │                       │
│                                    ▼                       │
│  ┌──────────────────────────────────────────────────────┐ │
│  │                   Verification (4 Steps)              │ │
│  │  1. Generate Test Model → 2. Full Fallback Quant     │ │
│  │  3. Weight Verification → 4. Quant Description     │ │
│  └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘

Architecture Components

This skill involves the following cloud services and components:

  • msModelSlim: Huawei Cloud's model quantization framework for

efficient model compression

  • Transformers Library: Hugging Face Transformers for model loading

and processing

  • ModelScope: Model download and management platform
  • Ascend NPU: Target hardware for quantized model deployment

Use Cases

Typical Problem Scenarios:

  • Need to deploy LLM models with reduced memory footprint on Ascend NPU
  • Want to optimize inference speed without significant accuracy loss
  • Migrating models that don't have built-in msModelSlim support
  • Need W8A8/W4A16 quantization for decoder-only LLM or VLM text backbones

Typical User Phrases:

  • "How to quantize my custom LLM model for Ascend?"
  • "Create msModelSlim adapter for Qwen model"
  • "Implement W4A16 quantization workflow"
  • "Adapt my VLM text backbone for quantization"
  • "How to add quantization support for new models?"

Core Workflow

1. Preparation

  • Download Model: Recommended to use modelscope download for

non-weight files.

  • Example: `modelscope download --model <org>/<model> --local_dir

./models/<name> --exclude '*.safetensors'`

  • Analyze Model: Read config.json and modeling_*.py to confirm

structure and implementation.

2. Create Adapter

  • Use Templates:
  • LLM: assets/model_adapter_template.py
  • VLM: assets/vlm_model_adapter_template.py
  • Implement Interfaces: Implement handle_dataset, init_model,

generate_model_visit, generate_model_forward, enable_kv_cache.

  • Key Principles:
  • visit and forward must be strictly consistent.
  • MoE models recommended to unpack to pure linear layers.
  • See: Implementation Guide

3. Registration & Installation

  • Register model and entry in config/config.ini, then execute

bash install.sh.

4. Verify Adapter (Required)

  • Must execute four-step verification: Generate test model -> Full

fallback quantization -> Verify full fallback model matches float weights exactly and can load/save completely -> Verify actual quantization workflow works (including description file rule validation).

Common Scripts

Scripts located in scripts/ directory:

  • scripts/step1_generate_test_model.py
  • scripts/step2_run_quantization.py
  • scripts/step3_verify_weights.py
  • scripts/step4_verify_quant_description.py

Prerequisites

System Requirements

  • Python 3.8+
  • transformers >= 4.40.0
  • msmodelslim >= 1.0.0

Environment Check

Prerequisite check: Python3 + transformers + msmodelslim required ``bash python3 --version # Python3 >= 3.8 python3 -c "import transformers; print('OK')" # Transformers library python3 -c "import msmodelslim; print('OK')" # msModelSlim library If not installed: pip3 install --user transformers msmodelslim`

Reference Documents

DocumentDescription
Model Analysis GuideModel structure analysis guide
Implementation GuideAdapter implementation instructions
Registration GuideRegistration and installation guide
Verification GuideFour-step verification workflow
Interface ChecklistRequired interface implementation checklist
Core WorkflowCore workflow documentation
Acceptance CriteriaFunctional acceptance criteria
TroubleshootingCommon issues and solutions

Requirements

  • transformers >= 4.40.0 installed
  • msmodelslim >= 1.0.0 installed
  • Transformers model to be adapted
  • Understanding of target quantization scheme (W8A8/W4A16)

Core Commands

bash
# Create model adapter
python3 scripts/create_adapter.py \
  --model Qwen2-7B \
  --quantization W8A8

# Run four-step verification
python3 scripts/verify_adapter.py --adapter ./adapter.py

Parameter Confirmation

ParameterDescriptionRequired
modelModel name or pathYes
quantizationQuantization scheme (W8A8/W4A16)Yes
outputAdapter output pathNo
du même dépôt

Autres Skills

Tous les Skills
huaweicloud
Communauté

huawei-cloud-publish-work-to-gallery

Publish user's work to the Huawei Cloud University Operations Platform (华为云高校运营平台/作品陈列馆). Use this skill whenever the user wants to publish, submit, or upload a project/work to the gallery or a training camp (训练营) on the platform — including casual phrasings like "把作品发布上去", "投稿到陈列馆", "传作品到平台", "提交作品/项目", "报名发布作品", as well as formal ones like "publish to work gallery", "submit to training camp", "upload work to the platform". Do NOT use for general dev questions, git push to GitCode alone, or platform browsing without publishing intent.

installations
5
GitHub Stars
50
Mis à jour
23 sept.
huaweicloud
Communauté

huawei-cloud-eip-cost-optimizer

Huawei Cloud EIP (Elastic IP) cost optimization skill using hcloud CLI (KooCLI). 1. List and query EIPs across regions with detailed status 2. Identify idle/unbound EIPs and generate cost optimization reports 3. Set up idle EIP monitoring with webhook/email alerts 4. Generate HTML/JSON cost analysis reports 5. Maintain operation audit logs for compliance Read-only analysis only - NO bandwidth adjustment, tag management, or EIP release/deletion. Triggers include: "EIP cost optimization", "idle EIP analysis", "EIP audit", "cost report", "EIP status query", "EIP list", "EIP monitoring", "EIP alert", "cost analysis", "idle monitoring", "operation audit", "EIP 成本优化", "闲置 EIP 分析", "EIP 审计", "成本报告", "EIP 状态查询", "EIP 查询", "EIP 列表", "EIP 监控", "EIP 告警", "成本分析", "闲置监控", "操作审计"

installations
1
GitHub Stars
50
Mis à jour
22 sept.
huaweicloud
Communauté

huawei-cloud-flexus-l-deploy-jiuwenswarm

One-click deployment of JiuwenSwarm multi-Agent collaboration platform on Huawei Cloud Flexus L instances. Usage scenarios: When users need to quickly deploy JiuwenSwarm/JiuwenClaw on Huawei Cloud Flexus L instances, when they need to automatically create cloud instances and deploy AI Agent platforms, when they need to configure model APIs and message channels (Xiaoyi/Feishu/DingTalk). Automatically create instances, deploy applications via COC, configure models and message channels. Trigger keywords: JiuwenSwarm deployment, JiuwenClaw deployment, 九问Swarm部署, 九问Claw部署, 一键部署JiuwenSwarm, AI智能体平台部署, 部署九问Swarm, 部署九问Claw,云服务器部署AI平台.

installations
1
GitHub Stars
50
Mis à jour
22 sept.
huaweicloud
Communauté

huawei-cloud-flexus-l-server-flexusagent-deployment

Deploy AI Agent development platform (Dify) on Huawei Cloud Flexus L instance, providing deployment operations, password management, MaaS model configuration, and workflow import capabilities. Trigger keywords: deploy flexusagent/一键部署Flexus AI Agent开发平台、change password/修改开发平台管理员密码、change dify password/修改dify平台密码、add maas provider/添加MaaS模型供应商、configure maas model/配置MaaS模型、view workflow/查看AI Agent工作流、import workflow/导入AI Agent工作流

installations
1
GitHub Stars
50
Mis à jour
22 sept.