Skip to main content
skill CX Codex

huawei-cloud-msmodelslim-model-adapt — Claude Code skill

huawei-cloud-msmodelslim-model-adapt — a skill for Claude Code and Codex that builds Transformers model adapters for msModelSlim quantization. Guides the flow from reading config.json to four-step weight verification.

MIT 165 installs ★ 59 updated 2026-11-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add huaweicloud/huaweicloud-skills --skill huawei-cloud-msmodelslim-model-adapt -a claude-code
Open on GitHub

What huawei-cloud-msmodelslim-model-adapt does

The skill targets basic adapters for decoder-only LLMs and understanding VLM text backbones using W8A8 or W4A16 quantization on Ascend NPU. Image or video generators like Stable Diffusion and advanced schemes such as SmoothQuant or QuaRot are out of scope. Pick another tool for those architectures.

You start by inspecting config.json and modeling_*.py after pulling non-weight files with modelscope download. From there, the workflow fills out assets/model_adapter_template.py or assets/vlm_model_adapter_template.py with required methods such as handle_dataset, init_model, generate_model_visit, generate_model_forward, and enable_kv_cache, keeping visit and forward strictly aligned. Registration goes into config/config.ini via bash install.sh. Four scripts under scripts/ then test the adapter from dummy model creation to weight parity and description checks.

The environment requires python3, bash, Python 3.8+, transformers 4.40.0 or newer, and msmodelslim 1.0.0 or newer. Missing either library breaks the verification step.

What it helps with

  • build a Transformers adapter for a new decoder-only LLM in msModelSlim
  • adapt an understanding VLM text backbone for W8A8 or W4A16 quantization
  • register a new model entry in config/config.ini and install it with install.sh
  • verify fallback quantized weights and description rules using test scripts

Example prompts for the agent

  • Build a msModelSlim adapter for my custom Qwen model using config.json and modeling_*.py
  • Set up a W4A16 quantization workflow for a decoder-only LLM targeting Ascend NPU
  • Adapt the text backbone of my understanding VLM and run the four-step weight verification

How to install huawei-cloud-msmodelslim-model-adapt

1Skills CLI (Vercel)

npx skills add huaweicloud/huaweicloud-skills --skill huawei-cloud-msmodelslim-model-adapt -a claude-code

2Manually: put the files in place

~/.claude/skills/huawei-cloud-msmodelslim-model-adapt/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/huawei-cloud-msmodelslim-model-adapt/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about huawei-cloud-msmodelslim-model-adapt

How do I install huawei-cloud-msmodelslim-model-adapt in Claude Code?

Run npx skills add huaweicloud/huaweicloud-skills --skill huawei-cloud-msmodelslim-model-adapt -a claude-code in your terminal. The skill also supports Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

What does huawei-cloud-msmodelslim-model-adapt do?

It guides the creation of basic Transformers adapters for msModelSlim W8A8 and W4A16 quantization workflows. The flow covers inspecting model files, implementing required template interfaces, registering in config/config.ini, and running four verification scripts.

What are the requirements and unsupported models for huawei-cloud-msmodelslim-model-adapt?

The environment needs python3, bash, Python 3.8+, transformers >= 4.40.0, and msmodelslim >= 1.0.0. Only decoder-only LLMs and understanding VLM text backbones are supported; multimodal generation like Stable Diffusion, encoder-only models, non-Transformers architectures, and methods like SmoothQuant or QuaRot are excluded.

Source text

SKILL.md · MIT
---
name: huawei-cloud-msmodelslim-model-adapt
description: |-
  Create basic Transformers model adapters for msModelSlim. Implements required interfaces and completes a four-step verification workflow:
  generate test model -> full fallback quantization -> weight verification -> quantization description validation. Use this skill when the user wants to: (1) create msModelSlim adapters for decoder-only LLM, (2) adapt understanding VLM text backbones for quantization, (3) implement W8A8/W4A16 quantization workflow for new models. Trigger: user mentions "msModelSlim", "adapter", "model adapter","quantization", "W8A8","W4A16", "transformers", "LLM", "VLM", "adapter creation", "适配器","模型适配", "量化", "模型适配器", "LLM量化"
compatibility:
  - transformers >= 4.40.0
  - msmodelslim >= 1.0.0
tags: [msModelSlim, adapter, quantization, model]
allowed-tools:
  - python3
  - bash
---

# 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
- High-level quantization methods (SmoothQuant/QuaRot/FA3/FlatQuant)

## 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.
  - See: [Model Analysis Guide](references/model_analysis.md)

### 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](references/implementation_guide.md)

### 3. Registration & Installation

- Register model and entry in `config/config.ini`, then execute
  `bash install.sh`.
- See: [Registration Guide](references/registration_guide.md)

### 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).
- See: [Verification Guide](references/verification_guide.md)

## 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

| Document | Description |
| ---------- | ------------- |
| [Model Analysis Guide](references/model_analysis.md) | Model structure analysis guide |
| [Implementation Guide](references/implementation_guide.md) | Adapter implementation instructions |
| [Registration Guide](references/registration_guide.md) | Registration and installation guide |
| [Verification Guide](references/verification_guide.md) | Four-step verification workflow |
| [Interface Checklist](references/interface_checklist.md) | Required interface implementation checklist |
| [Core Workflow](references/core_workflow.md) | Core workflow documentation |
| [Acceptance Criteria](references/acceptance-criteria.md) | Functional acceptance criteria |
| [IAM Policies](references/iam-policies.md) | IAM permission policies required by this skill |
| [Troubleshooting](references/troubleshooting.md) | Common 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

The four-step verification workflow is executed through the scripts in
the `scripts/` directory:

```bash
# Step 1: Generate a random-weight test model (slim)
python3 scripts/step1_generate_test_model.py \
  --model-path ./models/<model_name> \
  --output-path ./test_model

# Step 2: Run full fallback quantization (LLM / use --model-family vlm for VLM)
python3 scripts/step2_run_quantization.py \
  --model-path ./test_model \
  --output-path ./quantized_model \
  --model-type <model_type> \
  --model-family llm

# Step 3: Verify fallback weights match the float model exactly
python3 scripts/step3_verify_weights.py \
  --original-path ./test_model \
  --quantized-path ./quantized_model \
  --tolerance 1e-5

# Step 4: Verify the quantization description file against your rules
python3 scripts/step4_verify_quant_description.py \
  --desc-path ./quantized_model \
  --rules-path ./verify_rules.json
```

## Parameter Confirmation

| Script | Parameter | Required | Description |
| ------ | --------- | -------- | ----------- |
| step1 | `--model-path` | Yes | Path to the original model directory |
| step1 | `--output-path` | Yes | Output directory for the generated test model |
| step1 | `--num-layers` | No | Number of layers for the slim test model (default 2) |
| step2 | `--model-path` | Yes | Test model directory (step1 output) |
| step2 | `--output-path` | Yes | Output directory for the quantized model |
| step2 | `--model-type` | Yes | Model type of the target model |
| step2 | `--model-family` | No | `llm` (default) or `vlm` |
| step2 | `--config-path` | No | Fallback quantization config; auto-generated if omitted |
| step3 | `--original-path` | Yes | Directory of the float/step1 model |
| step3 | `--quantized-path` | Yes | Directory of the step2 quantized model |
| step3 | `--tolerance` | No | Max allowed weight difference (default 1e-5) |
| step4 | `--desc-path` | Yes | Quantization output dir or description file path |
| step4 | `--rules-path` | Yes | Verification rules JSON file path |

© huaweicloud · MIT · huaweicloud/huaweicloud-skills

Similar skills

All skills for AI and ML →

From the same set80

The whole set →
huawei-cloud-dws-io-diag huawei-cloud-dws-io-diag — a skill for Claude Code, Codex, and Cursor. Pinpoints the root causes of disk I/O bottlenecks in Huawei Cloud DWS clusters whenever storage alerts fire. CX Codex +1 180installs huawei-cloud-cce-metric-analyzer huawei-cloud-cce-metric-analyzer monitors Huawei Cloud CCE clusters, checks pod and node load, correlates ECS or ELB metrics, and catches threshold anomalies via AOM Prometheus and hcloud. CX Codex +1 171installs huawei-cloud-cce-alarm-correlation-engine huawei-cloud-cce-alarm-correlation-engine pulls Huawei Cloud AOM alarms for CCE clusters, groups them by severity, finds storms and chronic noise, and manages alarm rules and notification rules. CX Codex +1 168installs huawei-cloud-ucs-cluster-onboarding-manager The huawei-cloud-ucs-cluster-onboarding-manager skill handles Kubernetes cluster onboarding, fleet groups, and access data in Huawei Cloud UCS through the hcloud CLI. CX Codex +1 168installs huawei-cloud-ucs-policy-governor The huawei-cloud-ucs-policy-governor skill manages Huawei Cloud UCS policies through hcloud, from policy instances and definitions to enforcement checks and fleet compliance. CX Codex +1 164installs huawei-cloud-msmodelslim-model-analysis huawei-cloud-msmodelslim-model-analysis — a skill for Claude Code and Codex that inspects a model architecture before writing an msModelSlim adapter. Checks implementation source and MoE quantization risks. CX Codex +1 163installs huawei-cloud-cce-kubernetes-event-analyzer huawei-cloud-cce-kubernetes-event-analyzer reads Kubernetes Events from Huawei Cloud CCE clusters, groups repeated warnings and points at the pod or namespace that broke. CX Codex +1 162installs huawei-cloud-msot-msopprof-operator-profiler huawei-cloud-msot-msopprof-operator-profiler collects operator-level execution data on Ascend NPUs using msopprof in device or simulator mode and generates analysis reports. CX Codex +1 162installs

Project sponsors

Companies that keep this analytics open