模型: facebook/webssl-mae700m-full2b-224
任务: 视觉特征提取 (Vision Transformer)
硬件: 昇腾 Ascend 910
适配组织: Ascend-SACT
报告日期: 2026-05-20
| 属性 | 值 |
|---|---|
| 模型架构 | ViT-Huge (Vision Transformer) |
| 参数量 | 700M |
| 输入分辨率 | 224×224 |
| 隐藏层大小 | 1280 |
| 层数 | 32 |
| 补丁大小 | 14 |
| 预训练方法 | Web-MAE (掩码自编码器) |
| 适用任务 | 图像特征提取、视觉表征学习 |
| 项目 | 配置 |
|---|---|
| NPU 型号 | Ascend 910 / 910B |
| NPU 数量 | ≥ 1 卡 |
| 内存 | ≥ 16 GB |
| 存储 | ≥ 10 GB(模型文件约 2.5 GB) |
| 项目 | 版本 |
|---|---|
| 操作系统 | EulerOS 2.10 / CentOS 7.6 / Ubuntu 22.04 |
| CANN | ≥ 8.0 |
| Python | 3.9 / 3.10 / 3.11 |
| PyTorch | 2.9.0+cpu |
| torch_npu | 2.9.0.post1 |
| transformers | 4.57.6 |
# 激活 CANN 环境
source /usr/local/Ascend/ascend-toolkit/set_env.sh
# 安装 PyTorch
pip install torch==2.9.0 --index-url https://download.pytorch.org/whl/cpu
# 安装 torch_npu
pip install torch_npu==2.9.0.post1
# 安装 transformers 及其他依赖
pip install transformers==4.57.6 Pillow numpy scipynpu-smi info确认 NPU 状态为 OK 且温度正常。
将模型权重与配置文件放置于 model_files/ 目录下:
model_files/
├── config.json
├── preprocessor_config.json
└── model.safetensors# NPU FP32 推理
python inference.py \
--model_path ./model_files \
--device npu \
--precision fp32 \
--image path/to/your/image.jpg \
--save_features \
--output_dir ./outputs
# NPU FP16 推理
python inference.py \
--model_path ./model_files \
--device npu \
--precision fp16 \
--image path/to/your/image.jpg \
--save_features \
--output_dir ./outputspython accuracy_run.py --precision fp32 --output_dir ./logs
python accuracy_run.py --precision fp16 --output_dir ./logspython accuracy_run_perf.py --device npu --precision fp32 --output_dir ./logs
python accuracy_run_perf.py --device npu --precision fp16 --output_dir ./logspython check_accuracy_run_perf.py --precision both --output_dir ./logs| 精度模式 | 余弦相似度 | 最大差值 | 平均差值 | 判定 |
|---|---|---|---|---|
| FP32 | 1.00000322 | 2.90e-02 | 1.76e-03 | 通过 |
| FP16 | 0.99999934 | 4.59e-02 | 1.82e-03 | 通过 |
| 精度模式 | 平均延迟 | 吞吐量 | 延迟标准差 |
|---|---|---|---|
| FP32 | 15.13 ms | 66.09 img/s | 0.33 ms |
| FP16 | 14.91 ms | 67.05 img/s | 0.48 ms |
| 阶段 | 耗时 | 占比 |
|---|---|---|
| 预处理(CPU) | 1.52 ms | 9.2% |
| H2D 数据拷贝 | 0.10 ms | 0.6% |
| 纯推理(NPU) | 14.97 ms | 90.2% |
.
├── inference.py # 标准推理脚本
├── accuracy_run.py # 精度评测脚本
├── accuracy_run_perf.py # 性能评测脚本
├── check_accuracy_run_perf.py # 验收检查脚本
├── logs/ # 评测日志与报告
│ ├── accuracy_report_fp32.json
│ ├── accuracy_report_fp16.json
│ ├── perf_report_npu:0_fp32.json
│ ├── perf_report_npu:0_fp16.json
│ └── run_*.log
├── screenshots/ # 自验证截图
│ ├── inference_success.png
│ ├── accuracy_passed.png
│ └── perf_benchmark.png
├── model_files/ # 模型权重(用户自备)
└── readme.md # 本部署文档Q1: NPU 推理时出现 LOG_WARNING
A: 检查 CANN 环境是否激活。LOG_WARNING 不影响推理功能。
Q2: FP16 为什么没有明显加速?
A: 当前 torch_npu 2.9.0 版本中部分 ViT 算子的 FP16 融合优化有限。建议后续升级 torch_npu/CANN。
Q3: 如何验证模型是否正确加载?
A: 运行 python inference.py --device npu --precision fp32,检查输出特征形状是否为 [1, 257, 1280]。
@article{fan2025scaling,
title={Scaling Language-Free Visual Representation Learning},
author={David Fan and Shengbang Tong and Jiachen Zhu and Koustuv Sinha and Zhuang Liu and Xinlei Chen and Michael Rabbat and Nicolas Ballas and Yann LeCun and Amir Bar and Saining Xie},
year={2025},
eprint={2504.01017},
archivePrefix={arXiv},
primaryClass={cs.CV}
}本文档由 Model Agent 自动生成,用于昇腾 NPU 模型适配交付。