ascend-ai-coding/awesome-ascend-skills/mindspeed-mm-vlm

Claude Code and agent skill by ascend-ai-coding/awesome-ascend-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Universal VLM (vision-language understanding model) training guide for Huawei Ascend NPU using MindSpeed-MM. Covers all three framework patterns (Megatron, FSDP2, Custom trainers), weight conversion, dataset preparation (MLLM JSON format), fine-tuning, inference, and evaluation. Supports Qwen2.5VL, Qwen2VL, Qwen3VL, InternVL2.5/3/3.5, GLM4.1V, GLM4.5V, DeepSeekVL2, DeepSeekOCR, Ming, and more. Use when training or fine-tuning any multimodal understanding model on Ascend NPU.

Install

npx vskill@latest install ascend-ai-coding/awesome-ascend-skills/mindspeed-mm-vlm

SKILL.md

MindSpeed-MM VLM (Vision-Language Model) Training

This Skill guides users through training multimodal understanding (VLM) models on Huawei Ascend NPU using MindSpeed-MM. It uses Qwen2.5VL-3B as the flagship example and covers the end-to-end fine-tuning workflow.

Prerequisites

Critical: For most VLMs (Qwen2.5VL, Qwen2VL, InternVL, GLM4V, DeepSeekVL2), follow the manual install flow below. Do NOT use bash scripts/install.sh — official MindSpeed-MM docs state it only fully supports Qwen3/Qwen3.5. (For Qwen3VL / Qwen3.5, use one-click install + bash examples/qwen3_5/install_extensions.sh.)
Step P1: Clone repositories
bash
git clone https://gitcode.com/Ascend/MindSpeed-MM.git /root/workspace/MindSpeed-MM
git clone https://github.com/NVIDIA/Megatron-LM.git /root/workspace/Megatron-LM
cd /root/workspace/Megatron-LM && git checkout core_v0.12.1
cp -r megatron /root/workspace/MindSpeed-MM/
cd /root/workspace/MindSpeed-MM
Step P2: Install PyTorch + torch_npu

Always use pre-built wheels from Ascend PyTorch Releases. Do not use pip install torch==2.7.1 — aarch64 wheels on PyPI are unreliable.

bash
# Download matching wheels from https://gitcode.com/Ascend/pytorch/releases
# Replace cp310 with cp311 if using Python 3.11
pip install torch-2.7.1-cp310-cp310-manylinux_2_28_aarch64.whl
pip install torch_npu-2.7.1rc1-cp310-cp310-manylinux_2_28_aarch64.whl
# For x86_64: same naming pattern with _x86_64 suffix
# Required by torch_npu and other components:
pip install numpy pyyaml scipy attrs decorator psutil
Step P3: Install MindSpeed
bash
git clone https://gitcode.com/Ascend/MindSpeed.git /root/workspace/MindSpeed
cd /root/workspace/MindSpeed
git checkout 93c45456c7044bacddebc5072316c01006c938f9
pip install -r requirements.txt
pip install -e .
cd /root/workspace/MindSpeed-MM
Step P4: Install MindSpeed-MM base dependencies
bash
# Installs base stack from pyproject.toml: transformers==4.57.0, diffusers==0.30.3, peft==0.7.1, etc.
pip install -e .
Step P5: Activate CANN environment
bash
source /usr/local/Ascend/cann/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh
Step P6: Smoke test
bash
python3 -c "
import torch, torch_npu
assert torch.npu.is_available(), 'NPU not available'
print(f'NPU count: {torch_npu.npu.device_count()}')
import transformers, diffusers, mindspeed
print(f'transformers={transformers.__version__}, diffusers={diffusers.__version__}')
"

Then proceed to Step 0 below for model-specific dependencies. For Qwen2.5VL the base is sufficient; other models need overlays (see Step 0 table).

For detailed troubleshooting and alternative install paths, see mindspeed-mm-env-setup.

Supported VLM Models

ModelFrameworkEntry ScriptSizesStatus
Qwen2.5VLMegatronpretrain_vlm.py3B/7B/32B/72BReleased
Qwen2VLMegatronpretrain_vlm.py2B/7B/72BReleased
Qwen3VLFSDP2pretrain_transformers.py8B/30B/32B/235BReleased
InternVL2.5Megatronpretrain_internvl.py4B/78BReleased
InternVL3Megatronpretrain_vlm.py8B/78BReleased
InternVL3.5FSDP2pretrain_transformers.py--Released
GLM4.1VMegatronpretrain_vlm.py9BReleased
GLM4.5VFSDP2pretrain_transformers.py--Released
DeepSeekVL2Megatronpretrain_deepseekvl.py--Released
DeepSeekOCRCustomfinetune_ocr.py--Prototype
DeepSeekOCR2Customfinetune_ocr2.py--Prototype
MingCustomfinetune_vl.py--Prototype
Entry Script Note: VLM models use different entry scripts. Check the shell script in examples/<model_name>/ for the exact command — do not assume from the model name.

How to Train Any VLM Model

The workflow for training any VLM model in MindSpeed-MM follows a universal pattern:

  1. Find the example: Look in examples/<model_name>/ for available shell scripts (finetune, pretrain, inference, evaluate)
  2. Read the shell script: Identify the entry script, config files, and parallelism settings
  3. Check weight conversion: Determine if the model needs mm-convert (Megatron models), DCP conversion (FSDP2 models), or uses HF weights directly (custom trainer models)
  4. Modify config files: Update data paths and weight paths in the config files (JSON or YAML depending on the framework)
  5. Launch the shell script: bash examples/<model_name>/finetune_<model>_<size>.sh

For other models, adapt the Qwen2.5VL quick start below. Use the Model Registry to look up the exact entry script, converter, and backend for your target model.

Framework Patterns

All VLM models in MindSpeed-MM follow one of three framework patterns:

Pattern 1: Megatron (Qwen2.5VL, Qwen2VL, InternVL2.5, InternVL3, GLM4.1V, DeepSeekVL2)

bash
# Uses JSON config files: data.json + model.json
# Weight conversion: mm-convert <Converter> hf_to_mm
torchrun $DISTRIBUTED_ARGS pretrain_vlm.py \
--mm-data examples/<model>/data.json \
--mm-model examples/<model>/model.json \
--load $MM_WEIGHT_PATH ...

Pattern 2: FSDP2 (Qwen3VL, InternVL3.5, GLM4.5V)

bash
# Uses YAML config file; requires CUDA_DEVICE_MAX_CONNECTIONS=2
# Weight conversion: mm-convert <Converter> hf_to_dcp
# MoE models may need: --init-model-with-meta-device
CUDA_DEVICE_MAX_CONNECTIONS=2 torchrun $DISTRIBUTED_ARGS pretrain_transformers.py \
--fsdp2-config-path examples/<model>/fsdp2_config.yaml ...

Pattern 3: Custom Trainers (DeepSeekOCR, DeepSeekOCR2, Ming)

bash
# Standalone entry scripts; uses HF weights directly (no conversion needed)
torchrun $DISTRIBUTED_ARGS examples/<model>/finetune_<model>.py <args>

Quick Start: Qwen2.5VL-3B Fine-Tuning (End-to-End)

This is the flagship Megatron-pattern example. For other models, follow the same workflow structure but use configs and scripts from examples/<model_name>/. FSDP2 models use YAML configs instead of JSON; Custom trainer models skip weight conversion entirely. See the "Framework Patterns" section above.
Step 0: Model-Specific Dependencies

Different VLM models have different version requirements for libraries such as transformers. Some of these requirements conflict, so environment isolation is necessary.

ModelAdditional DependenciesNotes
Qwen2.5VLNone requiredBase environment is sufficient
Qwen3VLpip install -r examples/qwen3vl/requirements.txtRequires latest transformers; may conflict with other models
DeepSeekOCRpip install -r examples/deepseekocr/requirements.txtDowngrades transformers to 4.46.3; must use isolated environment
InternVL3None requiredBase environment is sufficient (directory is examples/internvl3/, no extra requirements.txt)
Important: Qwen3VL and DeepSeekOCR have conflicting transformers version requirements. If you need to support both, use separate Docker containers or conda environments. See per-model-deps.md for details.
Step 1: Weight Download and Conversion
1.1 Download HuggingFace Weights
bash
# Download from HuggingFace (requires proxy)
http_proxy=http://127.0.0.1:58232 https_proxy=http://127.0.0.1:58232 \
huggingface-cli download Qwen/Qwen2.5-VL-3B-Instruct \
--local-dir ckpt/hf_path/Qwen2.5-VL-3B-Instruct
1.2 HF to MM Format Conversion

MindSpeed-MM uses its own weight format (MM format). Weights must be converted before training.

bash
mm-convert Qwen2_5_VLConverter hf_to_mm \
--cfg.mm_dir "ckpt/mm_path/Qwen2.5-VL-3B-Instruct" \
--cfg.hf_config.hf_dir "ckpt/hf_path/Qwen2.5-VL-3B-Instruct" \
--cfg.parallel_config.llm_pp_layers [[36]] \
--cfg.parallel_config.vit_pp_layers [[32]] \
--cfg.parallel_config.tp_size 1

Key parameter descriptions:

ParameterDescription
--cfg.mm_dirOutput directory for converted MM format weights
--cfg.hf_config.hf_dirSource HF weight directory
--cfg.parallel_config.llm_pp_layersPP partitioning for LLM layers. [[36]] means all 36 layers on one device when PP=1
--cfg.parallel_config.vit_pp_layersPP partitioning for ViT layers. [[32]] means all 32 layers on one device when PP=1
--cfg.parallel_config.tp_sizeTensor parallelism degree; must match the training configuration
Important: llm_pp_layers and vit_pp_layers must match the pipeline_num_layers in model.json. When PP > 1, you need to split the layer counts, e.g., [[18,18]] for PP=2.
1.3 Converters for Different Models
ModelConverter NameDirectionNotes
Qwen2.5VLQwen2_5_VLConverterhf_to_mm / mm_to_hfSee example above
Qwen2VLQwen2VLConverterhf_to_mm / mm_to_hfSame pattern as Qwen2.5VL
Qwen3VLQwen3VLConverterhf_to_dcp / dcp_to_hfFSDP2: uses DCP format, not mm format
Qwen3VL (Megatron)Qwen3VLMegatronConverterhf_to_mm / mm_to_hfAlternative Megatron-path converter
InternVL2.5/3InternVLConverterhf_to_mm / mm_to_hf--cfg.parallel_config.vit_pp_layers [[45]]
InternVL3.5ExpertMergeDcpConverterhf_to_dcp / dcp_to_hfFSDP2 path; MoE model uses expert merge converter
DeepSeekVL2DeepSeekVLConverterhf_to_mm onlymm_to_hf is unimplemented (stub). Note MoE expert layers
GLM4.1VGlmConverterhf_to_mm / mm_to_hfGeneric Megatron converter
GLM4.5VExpertMergeDcpConverterhf_to_dcp / dcp_to_hfFSDP2 path; MoE model uses expert merge converter
MoE modelsExpertMergeDcpConvertermerge / splitMerge/split MoE expert weights for DCP checkpoints
DeepSeekOCR/OCR2None--Uses HF weights directly; no conversion needed
MingNone--Uses HF weights directly; no conversion needed
Step 2: Dataset Preparation

VLM training uses the MLLM JSON format. This example uses COCO2017 + LLaVA-Instruct-150K.

2.1 Download Data
bash
# 1. Download COCO2017 training images
mkdir -p data/COCO2017/train2017
# Extract to data/COCO2017/train2017/
# 2. Download LLaVA-Instruct-150K
# Download llava_instruct_150k.json to data/
2.2 Convert to MLLM Format
Important: The conversion script uses hardcoded relative paths. It expects ./data/llava_instruct_150k.json as input and ./data/COCO2017/train2017/ for image lookup. Run it from the MindSpeed-MM root directory, and ensure data is at ./data/ (or create symlinks).
bash
cd /root/workspace/MindSpeed-MM # Must run from repo root
python examples/qwen2vl/llava_instruct_2_mllm_demo_format.py

Output: data/mllm_format_llava_instruct_data.json

The script converts LLaVA format (conversations/image) to MLLM format (messages/images), which is what MindSpeed-MM expects.

2.3 Data Directory Structure
data/
├── COCO2017/train2017/ # Image files
│ ├── 000000000009.jpg
│ ├── 000000000025.jpg
│ └── ...
├── llava_instruct_150k.json # Original data (for conversion)
└── mllm_format_llava_instruct_data.json # MLLM format (for training)
Field name matching: The field names in your data JSON must match the attr section in data.json config. Default mapping: messages for conversations, images for image paths. Using different field names (e.g., conversations instead of messages) will cause KeyError.
For detailed MLLM JSON format specifications, see data-format.md.
Step 3: Configuration Files

Qwen2.5VL-3B fine-tuning requires two JSON configuration files:

3.1 data.json (Data Configuration)

Path: examples/qwen2.5vl/data_3b.json

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
161
Repository forks
55
7-day trend score
25

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Aug 2026, 2 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ascend-ai-coding/awesome-ascend-skills/mindspeed-mm-vlm/badge)](https://verified-skill.com/skills/ascend-ai-coding/awesome-ascend-skills/mindspeed-mm-vlm)

Something wrong with this skill or its page? Tell us.