| name | model-migration |
| description | Model code migration for Ascend NPU. Invoke when user needs to clone open-source repo and apply NPU adaptation patches. |
Model Migration Skill
Clone open-source model repositories and apply NPU adaptation patches for Ascend NPU training.
When to Invoke
- User wants to migrate open-source model to Ascend NPU
- User needs to clone model repository
- User needs to apply DrivingSDK patches
- User asks about preparing model code for NPU training
Information to Collect
Ask user for the following:
1. Model name (e.g., BEVFormer)
2. Working directory path on server
3. Dataset path (if already prepared)
4. Pre-trained weights path (if available)
重要:DrivingSDK仓库地址为 https://gitcode.com/Ascend/DrivingSDK,包含所有必要的patch文件和训练脚本。
Workflow
Step 1: Clone Repository in DrivingSDK model_examples Directory
重要:必须在 DrivingSDK/model_examples/<model_name>/ 目录下克隆模型仓库,而不是在外部创建新目录。
cd <DrivingSDK_path>/model_examples/BEVFormer
git clone https://github.com/fundamentalvision/BEVFormer.git
Step 2: Copy Patch to Model Directory
cp bev_former_config.patch BEVFormer/
Step 3: Checkout Specific Commit
cd BEVFormer
git checkout 66b65f3a1f58caf0507cb2a971b9c0e7f842376c
Step 4: Apply NPU Patches
git apply --reject --whitespace=fix bev_former_config.patch
Step 5: Setup Dataset and Weight Links
mkdir -p data ckpts
ln -sf <dataset_path>/nuscenes data/nuscenes
ln -sf <dataset_path>/can_bus data/can_bus
ln -sf <weight_path>/r101_dcn_fcos3d_pretrain.pth ckpts/
Step 6: Return to Parent Directory for Training
cd ..
bash test/train_performance_8p_base_fp32.sh --batch-size=1 --num-npu=8
Supported Models
BEVFormer
Repository: https://github.com/fundamentalvision/BEVFormer.git
Commit: 66b65f3a1f58caf0507cb2a971b9c0e7f842376c
Patch: bev_former_config.patch
Dataset Required:
- nuscenes (processed)
- can_bus
Weights Required:
r101_dcn_fcos3d_pretrain.pth
Commands:
cd <DrivingSDK_path>/model_examples/BEVFormer
git clone https://github.com/fundamentalvision/BEVFormer.git
cp bev_former_config.patch BEVFormer/
cd BEVFormer
git checkout 66b65f3a1f58caf0507cb2a971b9c0e7f842376c
git apply --reject --whitespace=fix bev_former_config.patch
mkdir -p data ckpts
ln -sf <dataset_path>/nuscenes data/nuscenes
ln -sf <dataset_path>/can_bus data/can_bus
ln -sf <weight_path>/r101_dcn_fcos3d_pretrain.pth ckpts/
cd ..
bash test/train_performance_8p_base_fp32.sh --batch-size=1 --num-npu=8
Network Strategy
| Situation | Strategy |
|---|
| Server can access GitHub | Direct git clone on server |
| Server network timeout | Configure proxy or clone locally → scp to server |
| Proxy available | Configure proxy: export http_proxy=http://proxy:port |
重要:所有GitHub仓库克隆都应使用GitHub官方链接,不使用镜像站点。如果网络超时,优先配置代理。
Local Clone + SCP Transfer
If server cannot access GitHub:
git clone https://github.com/fundamentalvision/BEVFormer.git
cd BEVFormer
git checkout 66b65f3a1f58caf0507cb2a971b9c0e7f842376c
scp -r BEVFormer <user>@<server>:<working_directory>/
Verification
After migration, verify setup:
ls -la <model_directory>/
cd <model_directory> && git status
ls -la data/
ls -la ckpts/
Troubleshooting
Patch Application Fails
- Check if correct commit is checked out
- Check for
.rej files for manual merge
- Verify patch file is for correct model version
Dataset Not Found
- Verify dataset path exists
- Check symbolic link is correct
- Ask user for correct dataset path
Weights Not Found
- Verify weight file exists
- Check weight file name matches config
- Ask user for correct weight path
Reference
- DrivingSDK model examples:
DrivingSDK/model_examples/
- Model-specific README:
DrivingSDK/model_examples/<model>/README.md