
Huawei Cloud Msmodelslim Model Analysis
- 48 installs
- 19 repo stars
- Updated July 31, 2026
- huaweicloud/huaweicloud-skills
Analyze candidate models before msModelSlim adapter work: detect implementation source, classify structure, and assess MoE quantization risks.
About
Analyzes candidate models before adapter implementation for msModelSlim, determining implementation source, structural features, layer-by-layer loading needs, and MoE fused-weight risks. A developer uses it to assess model adaptation feasibility before building a quantization adapter.
- Detects implementation source and classifies model type
- Flags MoE fused-weight and layer-loading risks
Huawei Cloud Msmodelslim Model Analysis by the numbers
- 48 all-time installs (skills.sh)
- +4 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #942 of 2,101 Data Science & ML skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-msmodelslim-model-analysisAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 48 |
|---|---|
| repo stars | ★ 19 |
| Last updated | July 31, 2026 |
| Repository | huaweicloud/huaweicloud-skills ↗ |
What it does
Analyze candidate models before msModelSlim adapter work: detect implementation source, classify structure, and assess MoE quantization risks.
Files
Huawei Cloud msModelSlim Model Analysis
Overview
This skill analyzes candidate models before adapter implementation for msModelSlim.
Architecture: Implementation Source Detection → Model Type Classification → Structural Feature Analysis → Risk Assessment
Related Skills:
huawei-cloud-msmodelslim-model-adapt- Adapter creation based on analysis
results
Architecture Components
This skill involves the following cloud services and components:
- msModelSlim: Huawei Cloud's model quantization framework
- Transformers Library: Hugging Face Transformers for model loading
- ModelScope: Model download and management platform
- config.json: Model configuration file for analysis
Architecture Diagram:
┌─────────────────────────────────────────────────────────────┐
│ msModelSlim Model Analysis Skill │
├─────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Model │───▶│ Source │───▶│ Structure │ │
│ │ Input │ │ Detection │ │ Analysis │ │
│ │ (config) │ │ │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Type │ │ MoE │ │ Risk │ │
│ │ Classification│ │ Assessment │ │ Assessment │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘Use Cases
Typical Problem Scenarios:
- Assessing model adaptation feasibility before creating msModelSlim adapters
- Analyzing model structure and type classification
- Evaluating MoE compatibility for quantization
- Determining if a model can be quantized with msModelSlim
- Identifying potential risks before adapter development
Typical User Phrases:
- "Analyze my model for msModelSlim compatibility"
- "Check if this model can be quantized"
- "Evaluate MoE fused weights risk"
- "Assess model adaptation feasibility"
- "Analyze model structure for quantization"
- "AnalysisModelmsModelSlim"
- "ModelQuantization"
- "CheckMoE"
Scope
Supported:
- Decoder-only LLM
- VLM text backbone analysis (LLM/text path only)
Not supported:
- Non-transformers implementations
- Multimodal generation models (image/video/audio generation)
Required Input
- Model path or model repository identifier
config.json- Optional:
modeling_*.py,model.safetensors.index.jsonin the model
directory
- If files are missing locally:
- Download non-weight files using:
modelscope download --model <org>/<model> --local_dir ./models/<name> --exclude '*.safetensors'
- Read
config.jsonandmodeling_*.pyfrom the download directory as input
for analysis.
Hard Requirement: Parse Implementation Source First
Must complete before any structural analysis. Agent should manually parse following these steps:
1. Read `config.json`:
- Get
model_type - Get
auto_map(if present)
2. Try parsing from transformers:
- Check if
transformerslibrary supports themodel_type. - Check if path exists:
transformers/models/<model_type>/modeling_<model_type>.py.
- If exists, record as
transformersimplementation.
3. If not parsed, try model-local implementation:
- Check if files pointed by
auto_mapexist in the model directory. - Check if
modeling_*.pyfiles exist in the model directory. - If exists, record as
model-localimplementation.
4. If neither path available:
- Stop analysis.
- Request user to provide readable model implementation code.
Minimum Workflow
1. Parse implementation source (complete hard requirement above).
2. Determine model type, structural differences, and connections:
- Type: Pure LLM / Multimodal understanding / Multimodal generation
- Compare with common Qwen2-like LLMs, record special structural designs
(e.g., MoE, non-standard attention, SSM/hybrid blocks, additional heads or parallel branches)
- Check special structure connections (location, dependencies,
serial/parallel/residual connections, impact on backbone traversal)
3. Identify structural features:
- Decoder layer class, attention/MLP module naming, forward signature
4. Determine features affecting adaptation:
- Layer traversal path and order
- Whether layer-by-layer loading is needed
- MoE fused expert weight risk
- Quantized model dequantization script risk
- MTP structure implementation availability and weight handling risk
5. Output structured analysis results (refer to template below).
6. Provide next steps:
- Proceed to adapter creation workflow
- Or block and explain what user needs to provide
Model Type, Structural Differences, and Connection Determination
(relative to common Qwen2)
- Pure LLM: Text token input only, backbone is decoder-only language model.
- Multimodal understanding: Contains vision/audio encoders, but generation
path centers on text backbone; only text portion can be analyzed and adapted.
- Multimodal generation: Core goal is image/video/audio generation; current
workflow does not support, should block and explain reason directly.
- Structural differences only need to record "existence + impact direction",
no deep implementation details required.
- Connection relationships should record at minimum: which stage special
structure is located in backbone, which modules it connects to, connection type (serial/parallel/residual), and impact on traversal/forward alignment.
MoE Layout Determination
- Non-fused MoE: Experts expanded by module/list (commonly each expert has
its own gate/up/down linear layers).
- Fused MoE: Multiple expert weights packaged as tensor parameters, no
longer independent linear layers.
- If any of
gate/up/downstored in[..., num_experts, ...]or
[num_experts, ...] form, treat as "fused".
- Three-dimensional expert weights (e.g., gate/up/down each fused into 3D
parameters) uniformly classified as MoE fused, with "may need unpack" marked in report.
Required Output: Analysis Report
Agent should directly generate analysis report (Markdown format), must include following elements. Refer to template below:
# Analysis Report
## Model Identification
- Model Path/Repository: {model_path}
- `model_type`: {model_type}
- `architectures`: {architectures}
## Implementation Source Analysis
- Result: `transformers` | `model-local` | `unsupported`
- Basis:
- Resolved file path: {path}
- Related configuration fields (`model_type`, `auto_map`): {details}
## Model Features and Specifications
- Hidden size: {hidden_size}
- Number of layers: {num_layers}
- Attention heads / KV heads: {num_heads} / {num_kv_heads}
- Analyze only VLM text portion: Yes/No
## Model Type, Structural Differences and Connections
- Model type: Pure LLM | Multimodal understanding | Multimodal generation
- Special structures vs common Qwen2: {special_structures}
- Special structure connections: {special_structure_connections}
- Impact on adaptation workflow: {structure_impact}
## Layer-by-Layer Loading Assessment
- Need layer-by-layer loading: Yes/No
- Reason: {reason}
- Constraints (memory/runtime environment): {constraints}
## MoE Assessment
- Contains MoE: Yes/No
- Layout type: No MoE | Non-fused MoE | Fused MoE
- Suspected fused keys/modules: {keys}
- Expert weight form: Independent linear layers | Packaged tensors
- Needs unpack: Yes/No
## Adaptation Impact Points
- Decoder traversal path: {traversal_path}
- Attention module naming: {attn_module}
- MLP module naming: {mlp_module}
- `visit/forward` strict alignment points: {alignment_points}
## Quantization and MTP Risk Assessment
- Model already quantized: Yes/No
- Quantization determination basis: {quant_evidence}
- Dequantization script provided: Yes/No
- Dequantization script status: {dequant_status}
- MTP structure exists: Yes/No
- MTP implementation code accessibility: Accessible/Not accessible
- MTP risk description: {mtp_risk}
## Risks and Next Steps
- Risk level: Low | Medium | High
- Blockers: {blockers}
- Recommended next steps:
- Proceed to adapter creation workflow
- Or request user to provide implementation codeRisk Identification and User Communication Requirements (Mandatory)
- If identified as "model already quantized", must mark "missing dequantization
script" as blocker, explicitly requiring user to actively provide dequantization script before continuing adaptation.
- If MTP structure identified but implementation code inaccessible, must
explicitly inform:
- Agent may not be able to fully implement MTP structure adaptation;
- To continue, user needs to copy MTP-related weights themselves (map
according to user-side implementation).
- When at least one of above two risk types hits,
risk levelmust not be
lower than "Medium".
Pass/Fail Criteria
- Pass: Implementation source is
transformersormodel-local, model
type is pure LLM or multimodal understanding, and report is complete; if quantization/MTP risks hit, clear user action requirements given in report.
- Fail: Source not parsed, unsupported implementation type, determined as
multimodal generation model, or hits "quantized model without dequantization script" blocking condition.
Enhanced Features
Automated Compatibility Checker
This skill includes an automated model compatibility checker that scans model architectures before migration:
Features:
- Migration Blocker Detection: Identifies unsupported operators, custom
layers, and framework-specific features
- Early Warning System: Provides early warning for known issues with
suggested workarounds
- Compatibility Score: Generates compatibility score with detailed breakdown
- Operator Coverage Analysis: Reports operator coverage rate for Ascend NPU
support
Compatibility Check Categories:
| Category | Check Items |
|---|---|
| Operator Support | Transformer layers, attention, normalization |
| Framework Features | Custom ops, dynamic shapes, control flow |
| Weight Formats | Safetensors, PyTorch, HF format compatibility |
| Special Structures | MoE, MTP, hybrid architectures |
Output Format:
## Compatibility Check Result
- Overall Score: XX/100
- Passed: X/XX checks
- Warning: X items require attention
- Blockers: X items preventing migration
### Detailed Results
| Check Item | Status | Details |
|-------------------|------------|-----------------------------------|
| Operator coverage | ✓ Pass | 95% of operators supported |
| Custom layers | ⚠️ Warning | 2 custom ops need AscendC impl |
| Weight format | ✓ Pass | Standard Hugging Face format |Reference Documents
- Analysis Checklist - Analysis verification
checklist
- Acceptance Criteria - Functional
acceptance criteria
- Verification Method - Verification approach
- Troubleshooting - Common issues and solutions
Prerequisites
- transformers >= 4.40.0 installed
- Model code available for analysis
- Basic understanding of model structure
Analysis Workflow
The analysis workflow follows these steps:
1. Parse model configuration (config.json) 2. Determine implementation source (transformers or model-local) 3. Analyze model architecture and structural features 4. Assess MoE layout and fused weight risks 5. Generate structured analysis report 6. Provide adaptation recommendations
Parameter Reference
| Parameter | Description | Required |
|---|---|---|
| model | Model name or path | Yes |
| output | Analysis report output path | No |
| detailed | Output detailed information | No |
Acceptance Criteria
Functional Acceptance Criteria
1. Implementation Source Detection
- AC-1.1: Identify transformers source
- Verification: Check model_type in transformers.models/
- AC-1.2: Identify model-local source
- Verification: Check auto_map and local files
- AC-1.3: Handle unsupported implementations
- Verification: Verify error handling
2. Model Type Classification
- AC-2.1: Classify as pure LLM
- Verification: Check architectures
- AC-2.2: Classify as multimodal understanding
- Verification: Check vision components
- AC-2.3: Classify as multimodal generation
- Verification: Check generation capabilities
3. Structural Feature Analysis
- AC-3.1: Identify special structures
- Verification: Check model config
- AC-3.2: Document connections
- Verification: Verify connection report
- AC-3.3: Assess adaptation impact
- Verification: Check analysis report
4. MoE Analysis
- AC-4.1: Detect MoE presence
- Verification: Check expert modules
- AC-4.2: Identify fused vs unfused
- Verification: Check weight shapes
- AC-4.3: Assess unpack requirements
- Verification: Check unpack recommendation
5. Report Generation
- AC-5.1: Generate complete analysis report
- Verification: Verify all sections present
- AC-5.2: Include risk assessment
- Verification: Check risk level
- AC-5.3: Provide next steps
- Verification: Verify recommendations
Correct/Error Pattern Comparison
Source Detection
Correct: Check transformers models directory
import transformers
import os
model_type = config.get("model_type")
path = f"transformers/models/{model_type}/modeling_{model_type}.py"
if os.path.exists(path):
source = "transformers"Error: Assume transformers without verification
source = "transformers" # Wrong: no verificationModel Type Detection
Correct: Check vision components separately
has_vision = "vision" in config.get("architectures", [])
has_text = "language_model" in dir(model)
if has_vision and has_text:
model_type = "multimodal_understanding"Error: Treat all VLMs the same
if "vision" in str(config):
model_type = "multimodal_generation" # Wrong: too broadMoE Detection
Correct: Check weight dimensions
# For gate/up/down weights
if weight.ndim == 3 and "gate" in name:
# 3D weight suggests fused MoE
moe_type = "fused"Error: Only check module name
if "MoE" in module_name:
moe_type = "fused" # Wrong: unfused also has MoE in nameNon-Functional Acceptance Criteria
- NAC-1.1: Analysis completion time < 5 minutes
- NAC-1.2: Report completeness - All sections present
- NAC-1.3: Risk assessment accuracy > 90%
Test Cases Summary
Positive Test Cases
1. TC-001: Qwen3 LLM analysis 2. TC-002: Qwen3-VL analysis 3. TC-003: MoE fused model analysis 4. TC-004: MoE unfused model analysis 5. TC-005: Layer-by-layer loading assessment
Negative Test Cases
1. TC-N01: Unsupported implementation source 2. TC-N02: Multimodal generation model 3. TC-N03: Quantized model without dequant script 4. TC-N04: MTP structure without code access
Analysis Checklist
Use this checklist before implementing model adaptation.
1. Implementation Source
- [ ] Read
config.json - [ ] Parse only one kind of source:
- [ ]
transformers/models/<model_type>/modeling_<model_type>.py - [ ] Through
auto_mapdefined in model directorymodeling_*.py
- [ ] If no method parsed, stop and require user to provide implementation code
2. Model Type, Structural Differences and Connections
(relative to common Qwen2)
- [ ] Determine model type: pure LLM / multimodal understanding /
multimodal generation
- [ ] If multimodal understanding, confirm only analyzing text backbone scope
- [ ] If multimodal generation, mark as not supported and stop adaptation
- [ ] Document special structures vs common Qwen2 and their impact
- [ ] Document special structure connections (location, dependencies,
serial/parallel/residual) and impact on traversal/forward
3. Structural Features
- [ ] Confirm decoder layer type
- [ ] Confirm attention and MLP module naming
- [ ] Confirm forward signature and key return values
- [ ] Confirm layer container path for traversal
4. Layer-by-Layer Loading Requirements
- [ ] Evaluate total loading memory and runtime environment
- [ ] Determine if layer-by-layer loading is required
- [ ] Document constraints and impact
5. MoE Fused Weight Risk
- [ ] Check if model contains MoE
- [ ] If contains MoE, check expert weight layout (independent linear layers
vs packaged tensors)
- [ ] Check if
gate/up/downare packaged as 3D weights along expert dimension - [ ] Mark as: no MoE / MoE non-fused / MoE fused
- [ ] Document if unpack is required
6. Adaptation Impact Points
- [ ] Document
generate_model_visittraversal sequence - [ ] Document
generate_model_forwardalignment constraints - [ ] Output impact on weight consistency verification
7. Quantized Model Risk (Dequantization Script)
- [ ] Check if model is "already quantized"
- [ ] If already quantized, require user to provide dequantization script
- [ ] If user cannot provide script, mark as blocker and stop adaptation
8. MTP Structure Risk (Implementation Missing)
- [ ] Check if model contains MTP structure
- [ ] If contains MTP, check if implementation code is accessible
- [ ] If no implementation code, clearly report that agent cannot fully
implement MTP structure adaptation
- [ ] If user wants to continue, inform user they need to manually handle
MTP weights
Troubleshooting
1. Model Loading Issues
Issue: transformers version too old
Symptom: AttributeError: 'xxx' object has no attribute 'yyy'
Solution:
# Upgrade transformers
pip install --upgrade transformers
# Or specific version
pip install transformers>=4.40.0Issue: config.json not found
Symptom: FileNotFoundError: config.json
Solution:
# Download model non-weight files
modelscope download --model <org>/<model> --local_dir ./models/<name> \
--exclude '*.safetensors'
# Or from HuggingFace
huggingface-cli download <org>/<model> --include "config.json" \
--local-dir ./models/<name>Issue: trust_remote_code required
Symptom: OSError: xxx requires trust_remote_code=True
Solution:
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained(path, trust_remote_code=True)2. Implementation Source Issues
Issue: Cannot determine source
Symptom: Both transformers and model-local paths exist
Solution:
# Check auto_map first
if auto_map and any(auto_map.values()):
source = "model-local"
else:
source = "transformers"Issue: Model type not in transformers
Symptom: Modeling file not found
Solution:
# List available models
ls transformers/models/
# Check for similar model types
# May need model-local implementation3. Model Type Classification Issues
Issue: Cannot distinguish VLM types
Symptom: Multimodal generation vs understanding unclear
Solution:
# Check generation capability
has_generate = 'generate' in dir(model)
has_vision = hasattr(model, 'visual') or hasattr(model, 'vision_tower')
if has_generate and has_vision:
model_type = "multimodal_generation"
elif has_vision:
model_type = "multimodal_understanding"Issue: Mixed architectures
Symptom: Model has both LLM and vision components
Solution:
# Check primary use case
if 'vision' in architectures[0].lower():
primary = "vision"
else:
primary = "language"4. MoE Analysis Issues
Issue: Cannot detect MoE type
Symptom: Unclear if fused or unfused
Solution:
# Check weight shapes
for name, tensor in state_dict.items():
if 'gate' in name.lower():
print(f"{name}: {tensor.shape}")
# [num_experts, hidden, intermediate] -> fused
# [hidden, intermediate] -> unfusedIssue: MoE unpack requirements unclear
Solution:
# Check for 3D expert weights
if any(t.ndim == 3 and 'expert' in k.lower()
for k, t in state_dict.items()):
needs_unpack = True
# Document which weights need unpack5. Report Generation Issues
Issue: Report missing sections
Solution:
# Check required sections
required_sections = [
"Model Identification",
"Implementation Source Analysis",
"Model Features and Specifications",
"Model Type",
"Layer-by-Layer Loading Assessment",
"MoE Assessment",
"Adaptation Impact Points",
"Quantization and MTP Risk Assessment",
"Risks and Next Steps",
]Issue: Risk level too high/low
Solution:
# Re-evaluate blockers
blockers = []
if quantized_without_script:
blockers.append("Quantized model without dequant script")
if mtp_without_code:
blockers.append("MTP structure without implementation code")
risk_level = "High" if len(blockers) >= 2 else "Medium" if blockers else "Low"Quick Diagnostic Commands
# Check model structure
ls -la models/<model>/
# Read config
cat models/<model>/config.json | python3 -m json.tool | head -50
# Check transformers support
python3 -c "
import transformers
import os
ct = 'Qwen2ForCausalLM'
path = os.path.join(os.path.dirname(transformers.__file__), 'models', ct)
print(f'Exists: {os.path.exists(path)}')
"
# Analyze model
python3 scripts/analyze_model.py --model-path models/<model> --verboseVerification Methods
Prerequisite Verification
1. Verify Model Files
# Check model directory
ls -la models/<model_name>/
# Verify config.json exists
cat models/<model_name>/config.json
# Check model_type field
python3 -c "import json; c=json.load(open('models/<model_name>/config.json')); \
print(c.get('model_type'))"2. Verify transformers Installation
# Check transformers version
pip show transformers
# Check transformers models directory
python3 -c "import transformers; print(transformers.__file__)"
ls -la $(python3 -c "import transformers; print(transformers.__file__)" \
| tr -d '\n')/../models/3. Verify Python Environment
# Python version
python3 --version # Should be >= 3.8
# Required packages
pip list | grep -E "torch|transformers"Functional Verification
1. Implementation Source Verification
# Read config.json
import json
config = json.load(open('models/<model_name>/config.json'))
model_type = config.get('model_type')
architectures = config.get('architectures')
# Check transformers source
import transformers
import os
transformers_path = os.path.dirname(transformers.__file__)
model_path = f"{transformers_path}/models/{model_type}/modeling_{model_type}.py"
if os.path.exists(model_path):
print(f"Source: transformers ({model_path})")
else:
print("Source: model-local")
# Check auto_map
auto_map = config.get('auto_map', {})
if auto_map:
print(f"Source: model-local (auto_map)")2. Model Type Verification
# Check architectures
if any(x in architectures for x in ['LlamaForCausalLM', 'Qwen2ForCausalLM']):
model_type = "pure_LLM"
elif any(x in architectures for x in ['Qwen2VLForConditionalGeneration']):
model_type = "multimodal_understanding"
elif any(x in architectures for x in ['LlamaForCausalLM']):
# Check if has vision
if 'vision' in str(config):
model_type = "multimodal_understanding"3. MoE Verification
# Check for expert modules
import torch
state_dict = torch.load('model.safetensors', map_location='cpu')
# Check weight shapes
for name, tensor in list(state_dict.items())[:10]:
print(f"{name}: {tensor.shape}")
# Look for MoE indicators
has_moe = any('expert' in k.lower() for k in state_dict.keys())
print(f"Has MoE: {has_moe}")4. Report Verification
# Generate analysis report
python3 scripts/analyze_model.py --model-path models/<model_name> \
--output analysis_report.md
# Verify report structure
head -50 analysis_report.md
# Check all sections present
grep -E "^## " analysis_report.mdEnd-to-End Verification Script
#!/bin/bash
set -e
MODEL_PATH="models/Qwen3-14B"
echo "=== 1. Verify Prerequisites ==="
python3 --version
pip list | grep -E "torch|transformers"
echo "=== 2. Verify Model Files ==="
ls -la ${MODEL_PATH}/config.json
cat ${MODEL_PATH}/config.json | grep -E "model_type|architectures"
echo "=== 3. Analyze Implementation Source ==="
python3 -c "
import json
import os
import transformers
config = json.load(open('${MODEL_PATH}/config.json'))
model_type = config.get('model_type')
path = os.path.join(os.path.dirname(transformers.__file__), \
'models', model_type, f'modeling_{model_type}.py')
print(f'Model type: {model_type}')
print(f'Transformers path exists: {os.path.exists(path)}')
"
echo "=== 4. Generate Analysis Report ==="
python3 scripts/analyze_model.py --model-path ${MODEL_PATH} \
--output analysis_report.md
echo "=== 5. Verify Report ==="
grep -E "^## " analysis_report.md
echo "=== All verifications passed ==="Verification Checklist
- Python version: >= 3.8
- transformers installed: Import successful
- config.json exists: File readable
- model_type identified: Valid type string
- Source detected: transformers or model-local
- Report generated: File created
- All sections present: 10+ sections
- Risk level assigned: Low/Medium/High