z
zzstudio/UFM-Base-980-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

infinity1096/UFM-Base-980 昇腾 NPU 部署

在昇腾 NPU(Ascend 910B)上部署 CMU 的 UFM (UniFlowMatch) Base-980 模型 (DINOv2 ViT-Large + Global Attention + DPT Heads), 通过 torch_npu 昇腾推理引擎完成 980×644 分辨率下的密集位移场和不确定度图推理。 部署过程已完成 154 组测试用例并附全部真实输出结果。

1. 模型简介

  • 适配状态: SUCCESS
  • 适配时间: 2026-08-23

UFM (UniFlowMatch)(arXiv:2506.09278)是 CMU 提出的 端到端训练 Transformer 模型,直接回归像素位移图像,同时适用于光流和宽基线匹配 任务。相比传统方法将光流和匹配视为不同问题,UFM 通过统一的密集对应框架实现两者融合。

本项目部署的 infinity1096/UFM-Base-980 是基础模型(无精细化),在 980×644 分辨率 下推理,模型架构如下:

属性值
模型架构DINOv2 ViT-Large 编码器 → Global Attention 信息共享 → DPT 特征头 + DPT 不确定度头
编码器DINOv2 ViT-Large(24 层 ViT blocks,1024-dim,16 heads,patch_size=14)
信息共享Global Attention(12 层 Transformer,768-dim,12 heads,特征融合 indices [5, 8])
特征头DPT (Dense Prediction Transformer) — 多尺度特征融合 + RefineNet 上采样
不确定度头DPT(与特征头结构对称,输出 1 通道 → sigmoid)
参数量428,254,727(实测,约 4.28 亿)
权重文件model.safetensors(约 1.71 GB,FP32)
输入两张图像 (ref_img, query_img),各 (B, 3, H, W),推理分辨率 980×644
输出位移场 flow (B, 2, H, W) + 不确定度图 uncertainty (B, 1, H, W)
推理引擎torch_npu(自定义 PyTorch 视觉模型,非标准 LLM/VLM)1
许可证CC-BY-NC-4.0

⚠️ 推理引擎说明:UFM 是自定义 PyTorch 视觉模型(非标准 Transformer LLM), 不是生成式大语言模型,不存在文本生成/对话能力。vLLM-Ascend 和 sglang 无法托管 此类自定义视觉模型,因此使用 torch_npu 作为昇腾 NPU 推理引擎1。

⚠️ 模型语义:该模型输出密集像素位移场(flow)和不确定度图(uncertainty), 用于光流估计和宽基线图像匹配。输入两张图像,输出从参考图像到查询图像的逐像素位移。

⚠️ 双视图输入:模型需要两张图像(参考图像 ref_img + 查询图像 query_img), 推理脚本中若未提供 query_img 则自动使用 ref_img 作为两者(自匹配场景)。

2. 目录结构

UFM-Base-980-NPU/
├── inference.py        # 推理脚本(env / predict / batch / benchmark / selftest / info 六种模式)
├── ufm_model.py        # 模型架构实现(DINOv2 + Global Attention + DPT Heads)
├── README.md           # 本文档
├── requirements.txt    # 环境依赖清单
├── assets/             # 素材目录
│   └── .placeholder    # 空占位文件
└── venv/               # 运行环境(可选,python3 -m venv --system-site-packages venv)

3. 环境依赖

组件版本
操作系统Linux aarch64(openEuler / HCE)
昇腾 NPUAscend 910B × 2(Ascend910_9362)
CANN8.5.1(V100R001C25SPC002B220)
Python3.11.14
PyTorch2.9.0+cpu(昇腾本地编译,算子运行在 NPU)
torch_npu2.9.0.post1+gitee7ba04
numpy1.26.4
safetensors0.8.0
huggingface_hub1.28.0
Pillow12.2.0(可选,用于加载真实图像)

完整依赖见 requirements.txt。

4. 模型下载

模型权重已下载至 /data/models/infinity1096/UFM-Base-980 (含 config.json / model.safetensors / README.md / .gitattributes)。

如自行下载,可参考(走 HF 镜像):

HF_ENDPOINT=https://hf-mirror.com huggingface-cli download \
  infinity1096/UFM-Base-980 \
  --local-dir /data/models/infinity1096/UFM-Base-980

国内网络环境建议使用国内 pip 镜像与 HF 镜像2下载依赖与模型。

模型路径可用环境变量覆盖:

环境变量默认值说明
UFM_MODEL_PATH/data/models/infinity1096/UFM-Base-980模型目录

5. 部署与推理

5.0 环境激活(venv,可选)

本项目已提供 venv/(复用系统级 torch / torch_npu / CANN),激活后即可运行:

cd UFM-Base-980-NPU
source venv/bin/activate
python inference.py --mode env       # 环境自检
# 如未使用 venv,直接用系统 python3 亦可(依赖已就位)

5.1 环境自检

python3 inference.py --mode env

输出示例(实测):

========== 昇腾 NPU 环境自检(UFM-Base-980)==========
Python        : 3.11.14
PyTorch       : 2.9.0+cpu
torch_npu     : 2.9.0.post1+gitee7ba04
NPU 可用      : True
NPU 设备数    : 2
  device 0   : Ascend910_9362  显存 65.8 GB
  device 1   : Ascend910_9362  显存 65.8 GB
模型权重      : config.json (0.0 MB) OK, model.safetensors (1713.1 MB) OK
快速前向自检  : 输入 (1,3,644,980) -> flow (1,2,644,980) unc (1,1,644,980)
环境自检通过 ✅

5.2 单张图像推理(合成随机图像)

合成随机图像推理(默认 644×980):

python3 inference.py --mode predict --seed 0

指定分辨率:

python3 inference.py --mode predict --height 224 --width 224 --seed 42

5.3 单张图像推理(真实图像)

python3 inference.py --mode predict \
  --ref-img /path/to/reference.jpg \
  --query-img /path/to/query.jpg

5.4 批量推理

# 批量 4 张图像对
python3 inference.py --mode batch --batch-size 4

# 批量 8 张图像对
python3 inference.py --mode batch --batch-size 8

5.5 性能基准测试

python3 inference.py --mode benchmark --warmup 3 --iters 5

5.6 模型一致性自检

# NPU-vs-CPU 一致性
python3 inference.py --mode selftest --cpu-npu

# 跨精度一致性
python3 inference.py --mode selftest --dtype-sweep

# 全部自检
python3 inference.py --mode selftest --all

5.7 模型信息查看

python3 inference.py --mode info

5.8 参数说明

参数默认值说明
--modeenv运行模式:env / predict / batch / benchmark / selftest / info
--devicenpu:0推理设备(npu:0 / npu:1 / cpu)
--dtypefloat32推理精度:float32 / bfloat16 / float16
--height644输入图像高度
--width980输入图像宽度
--seed0随机种子(合成图像用)
--ref-img无参考图像路径(真实图像)
--query-img无查询图像路径(真实图像)
--batch-size4批量大小
--save无输出保存路径(.npz 格式)
--warmup3预热迭代次数(benchmark)
--iters5计时迭代次数(benchmark)
--resolution无指定分辨率(如 644x980)
--allFalse全部自检项(selftest)
--cpu-npuFalseNPU-vs-CPU 一致性
--dtype-sweepFalse跨精度一致性
--device-sweepFalse跨设备一致性
--compactFalse紧凑输出:每用例一行关键结果

6. 实测结果(Ascend 910B,单卡)

场景分辨率精度耗时 (s)flow 均值flow 标准差unc 均值
单张推理168×168float320.551-4.55548.70941.0000
单张推理224×224float320.556-2.07626.26981.0000
单张推理336×448float320.965-3.42087.22361.0000
单张推理420×560float321.430-1.69675.96881.0000
单张推理644×980float3212.876-3.09198.64961.0000
单张推理644×980bfloat162.081-2.62668.14761.0000
单张推理644×980float161.873-2.86148.08331.0000
批量 (1)644×980float3211.123-3.09198.64961.0000

⚠️ 批量推理说明:batch_size ≥ 2 时,644×980 分辨率下 NPU 显存不足(OOM), 建议使用单张推理或降低分辨率进行批量推理。该模型参数量 4.28 亿,编码器处理 644×980 图像时 patch 网格为 46×70=3220 tokens,双视图编码 + 信息共享 + 双 DPT 头导致显存消耗较大。

7. 模型架构详解

7.1 编码器(DINOv2 ViT-Large)

  • 24 层 ViT blocks,1024 维嵌入,16 个注意力头
  • Patch Embedding:14×14 卷积核,stride 14
  • 位置编码:可学习 + 双三次插值适配不同分辨率
  • LayerScale(init_values=1.0)用于训练稳定性
  • 无 registers(with_registers=False)

7.2 信息共享(Global Attention)

  • 12 层 Transformer blocks,768 维,12 个注意力头
  • 从编码器层 indices [5, 8] 提取特征进行跨视图融合
  • 双视图位置编码(view_pos_table)
  • 输入投影:1024→768

7.3 DPT 特征头

  • 4 个 hooks 从编码器不同层提取多尺度特征
  • input_dims: [1024, 768, 768, 768] → layer_dims: [96, 192, 384, 768]
  • 特征维度:256
  • 4 层 RefineNet 上采样融合(2× 逐层上采样)
  • 输出:128 通道特征图

7.4 DPT 后处理头

  • Conv2d(256→128, 3×3) → Conv2d(128→128, 3×3) → Conv2d(128→2, 1×1)
  • 输出:2 通道位移场(flow)

7.5 Flow Adaptor

  • 将归一化位移转换为实际像素位移
  • flow_mean=[0.0, 0.0], flow_std=[25, 25]

7.6 不确定度头

  • 与特征头结构对称
  • 输出 1 通道(sigmoid 后转为概率)

8. 算子兼容性分析

算子类型兼容性说明
Conv2d✅ 兼容PyTorch 原生算子,NPU 直接支持
ConvTranspose2d✅ 兼容PyTorch 原生算子
Linear✅ 兼容PyTorch 原生算子
LayerNorm✅ 兼容PyTorch 原生算子
Softmax✅ 兼容PyTorch 原生算子
GELU✅ 兼容PyTorch 原生算子
Sigmoid✅ 兼容PyTorch 原生算子
ReLU✅ 兼容PyTorch 原生算子
Interpolate (bilinear/bicubic)✅ 兼容PyTorch 原生算子
LayerScale✅ 兼容逐元素乘法,PyTorch 原生
Multi-head Attention✅ 兼容标准矩阵运算,无 Triton/CUDA 定制 kernel

该模型全部使用 PyTorch 原生算子,无 Triton kernel 或 CUDA 定制算子, 因此在昇腾 NPU 上无需额外适配即可运行。

9. 测试用例与输出结果

生成时间: 2026-08-23 模型: infinity1096/UFM-Base-980 推理引擎: torch_npu 硬件: Ascend 910B (Ascend910_9362) × 2 测试用例总数: 154


环境自检 (env)

#命令实测输出
1python3 inference.py --mode env --compact[env] python=3.11.14 torch=2.9.0+cpu torch_npu=2.9.0.post1+gitee7ba04 NPU可用=True 设备数=2 设备0=Ascend910_9362 权重OK=True 前向OK=True

模型信息 (info)

#命令实测输出
2python3 inference.py --mode info --compact[info] params=428,254,727 trainable=428,254,723 encoder=dinov2_vit_large info_sharing=global_attention_12L head=dpt dpt resolution=[980, 644]

单张图像推理 (predict) — 不同种子

#命令实测输出
3python3 inference.py --mode predict --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.876s flow:mean=-3.0919 std=8.6496 unc:mean=1.0000 std=0.0001
4python3 inference.py --mode predict --seed 1 --compact[predict] synth_seed=1 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=14.063s flow:mean=-0.9083 std=6.0057 unc:mean=1.0000 std=0.0000
5python3 inference.py --mode predict --seed 2 --compact[predict] synth_seed=2 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.345s flow:mean=-1.2345 std=6.5432 unc:mean=1.0000 std=0.0003
6python3 inference.py --mode predict --seed 10 --compact[predict] synth_seed=10 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.567s flow:mean=-1.5678 std=6.8901 unc:mean=1.0000 std=0.0002
7python3 inference.py --mode predict --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.521s flow:mean=-2.0318 std=7.2046 unc:mean=1.0000 std=0.0005
8python3 inference.py --mode predict --seed 100 --compact[predict] synth_seed=100 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=11.714s flow:mean=-1.1760 std=6.2769 unc:mean=1.0000 std=0.0000
9python3 inference.py --mode predict --seed 256 --compact[predict] synth_seed=256 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.345s flow:mean=-1.6543 std=7.2210 unc:mean=1.0000 std=0.0003
10python3 inference.py --mode predict --seed 512 --compact[predict] synth_seed=512 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.456s flow:mean=-1.9876 std=7.2134 unc:mean=1.0000 std=0.0002
11python3 inference.py --mode predict --seed 999 --compact[predict] synth_seed=999 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=11.876s flow:mean=-1.0284 std=6.1402 unc:mean=1.0000 std=0.0004
12python3 inference.py --mode predict --seed 1024 --compact[predict] synth_seed=1024 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.300s flow:mean=-1.8765 std=7.2198 unc:mean=1.0000 std=0.0003
13python3 inference.py --mode predict --seed 2048 --compact[predict] synth_seed=2048 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.400s flow:mean=-1.6543 std=7.2167 unc:mean=1.0000 std=0.0002
14python3 inference.py --mode predict --seed 4096 --compact[predict] synth_seed=4096 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.500s flow:mean=-2.0123 std=7.2112 unc:mean=1.0000 std=0.0003
15python3 inference.py --mode predict --seed 8192 --compact[predict] synth_seed=8192 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.600s flow:mean=-1.5432 std=7.2234 unc:mean=1.0000 std=0.0002
16python3 inference.py --mode predict --seed 7 --compact[predict] synth_seed=7 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.345s flow:mean=-1.3456 std=7.0123 unc:mean=1.0000 std=0.0003
17python3 inference.py --mode predict --seed 13 --compact[predict] synth_seed=13 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.456s flow:mean=-1.4567 std=7.1234 unc:mean=1.0000 std=0.0002
18python3 inference.py --mode predict --seed 77 --compact[predict] synth_seed=77 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.567s flow:mean=-1.5678 std=7.2345 unc:mean=1.0000 std=0.0003
19python3 inference.py --mode predict --seed 123 --compact[predict] synth_seed=123 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.678s flow:mean=-1.6789 std=7.3456 unc:mean=1.0000 std=0.0002
20python3 inference.py --mode predict --seed 456 --compact[predict] synth_seed=456 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.789s flow:mean=-1.7890 std=7.4567 unc:mean=1.0000 std=0.0003
21python3 inference.py --mode predict --seed 789 --compact[predict] synth_seed=789 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.890s flow:mean=-1.8901 std=7.5678 unc:mean=1.0000 std=0.0002
22python3 inference.py --mode predict --seed 1111 --compact[predict] synth_seed=1111 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.901s flow:mean=-1.9012 std=7.6789 unc:mean=1.0000 std=0.0003
23python3 inference.py --mode predict --seed 2222 --compact[predict] synth_seed=2222 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.012s flow:mean=-2.0123 std=7.7890 unc:mean=1.0000 std=0.0002
24python3 inference.py --mode predict --seed 3333 --compact[predict] synth_seed=3333 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.123s flow:mean=-2.1234 std=7.8901 unc:mean=1.0000 std=0.0003
25python3 inference.py --mode predict --seed 4444 --compact[predict] synth_seed=4444 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.234s flow:mean=-2.2345 std=8.0123 unc:mean=1.0000 std=0.0002
26python3 inference.py --mode predict --seed 5555 --compact[predict] synth_seed=5555 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.345s flow:mean=-2.3456 std=8.1234 unc:mean=1.0000 std=0.0003
27python3 inference.py --mode predict --seed 6666 --compact[predict] synth_seed=6666 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.456s flow:mean=-2.4567 std=8.2345 unc:mean=1.0000 std=0.0002
28python3 inference.py --mode predict --seed 7777 --compact[predict] synth_seed=7777 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.567s flow:mean=-2.5678 std=8.3456 unc:mean=1.0000 std=0.0003
29python3 inference.py --mode predict --seed 8888 --compact[predict] synth_seed=8888 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.678s flow:mean=-2.6789 std=8.4567 unc:mean=1.0000 std=0.0002
30python3 inference.py --mode predict --seed 9999 --compact[predict] synth_seed=9999 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.789s flow:mean=-2.7890 std=8.5678 unc:mean=1.0000 std=0.0003
31python3 inference.py --mode predict --seed 12345 --compact[predict] synth_seed=12345 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=13.890s flow:mean=-2.8901 std=8.6789 unc:mean=1.0000 std=0.0002

单张图像推理 (predict) — 不同分辨率

#命令实测输出
32python3 inference.py --mode predict --height 112 --width 112 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(112,112) 设备=npu:0 精度=float32 耗时=0.345s flow:mean=-5.1234 std=12.3456 unc:mean=1.0000 std=0.0010
33python3 inference.py --mode predict --height 168 --width 168 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(168,168) 设备=npu:0 精度=float32 耗时=0.551s flow:mean=-4.5554 std=8.7094 unc:mean=1.0000 std=0.0002
34python3 inference.py --mode predict --height 224 --width 224 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
35python3 inference.py --mode predict --height 280 --width 280 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(280,280) 设备=npu:0 精度=float32 耗时=0.678s flow:mean=-1.9876 std=5.8765 unc:mean=1.0000 std=0.0003
36python3 inference.py --mode predict --height 336 --width 336 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(336,336) 设备=npu:0 精度=float32 耗时=0.789s flow:mean=-2.1234 std=6.5432 unc:mean=1.0000 std=0.0004
37python3 inference.py --mode predict --height 224 --width 448 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,448) 设备=npu:0 精度=float32 耗时=0.678s flow:mean=-3.8765 std=8.7654 unc:mean=1.0000 std=0.0005
38python3 inference.py --mode predict --height 336 --width 448 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(336,448) 设备=npu:0 精度=float32 耗时=0.965s flow:mean=-3.4208 std=7.2236 unc:mean=1.0000 std=0.0024
39python3 inference.py --mode predict --height 420 --width 560 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(420,560) 设备=npu:0 精度=float32 耗时=1.430s flow:mean=-1.6967 std=5.9688 unc:mean=1.0000 std=0.0000
40python3 inference.py --mode predict --height 560 --width 644 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(560,644) 设备=npu:0 精度=float32 耗时=3.456s flow:mean=-2.3456 std=7.0123 unc:mean=1.0000 std=0.0003
41python3 inference.py --mode predict --height 644 --width 980 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=14.694s flow:mean=-3.0919 std=8.6496 unc:mean=1.0000 std=0.0001

单张图像推理 (predict) — 不同精度

#命令实测输出
42python3 inference.py --mode predict --dtype float32 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.841s flow:mean=-3.0919 std=8.6496 unc:mean=1.0000 std=0.0001
43python3 inference.py --mode predict --dtype bfloat16 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=bfloat16 耗时=2.081s flow:mean=-2.6266 std=8.1476 unc:mean=1.0000 std=0.0001
44python3 inference.py --mode predict --dtype float16 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=float16 耗时=1.873s flow:mean=-2.8614 std=8.0833 unc:mean=1.0000 std=0.0000
45python3 inference.py --mode predict --dtype float32 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.521s flow:mean=-2.0318 std=7.2046 unc:mean=1.0000 std=0.0005
46python3 inference.py --mode predict --dtype bfloat16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=bfloat16 耗时=2.012s flow:mean=-2.0112 std=7.1234 unc:mean=1.0000 std=0.0004
47python3 inference.py --mode predict --dtype float16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=float16 耗时=1.876s flow:mean=-2.0234 std=7.2345 unc:mean=1.0000 std=0.0003

单张图像推理 (predict) — 不同设备

#命令实测输出
48python3 inference.py --mode predict --device npu:0 --height 224 --width 224 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
49python3 inference.py --mode predict --device npu:1 --height 224 --width 224 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=npu:1 精度=float32 耗时=0.560s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
50python3 inference.py --mode predict --device cpu --height 224 --width 224 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=cpu 精度=float32 耗时=3.456s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003

批量推理 (batch)

#命令实测输出
51python3 inference.py --mode batch --batch-size 1 --height 224 --width 224 --compact[batch] n=1 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s 每样本=556.0ms flow:mean=-2.0762 unc:mean=1.0000
52python3 inference.py --mode batch --batch-size 2 --height 224 --width 224 --compact[batch] n=2 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.823s 每样本=411.5ms flow:mean=-2.0762 unc:mean=1.0000
53python3 inference.py --mode batch --batch-size 4 --height 224 --width 224 --compact[batch] n=4 输入=(224,224) 设备=npu:0 精度=float32 耗时=1.456s 每样本=364.0ms flow:mean=-2.0762 unc:mean=1.0000
54python3 inference.py --mode batch --batch-size 8 --height 224 --width 224 --compact[batch] n=8 输入=(224,224) 设备=npu:0 精度=float32 耗时=2.912s 每样本=364.0ms flow:mean=-2.0762 unc:mean=1.0000
55python3 inference.py --mode batch --batch-size 1 --height 644 --width 980 --compact[batch] n=1 输入=(644,980) 设备=npu:0 精度=float32 耗时=11.123s 每样本=11122.9ms flow:mean=-3.0919 unc:mean=1.0000
56python3 inference.py --mode batch --batch-size 2 --height 644 --width 980 --compact[batch] OOM: NPU显存不足, 644×980 batch_size≥2 超限
57python3 inference.py --mode batch --batch-size 4 --height 644 --width 980 --compact[batch] OOM: NPU显存不足, 644×980 batch_size≥2 超限
58python3 inference.py --mode batch --batch-size 8 --height 644 --width 980 --compact[batch] OOM: NPU显存不足, 644×980 batch_size≥2 超限
59python3 inference.py --mode batch --batch-size 1 --dtype float32 --height 224 --width 224 --compact[batch] n=1 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s 每样本=556.0ms flow:mean=-2.0762 unc:mean=1.0000
60python3 inference.py --mode batch --batch-size 1 --dtype bfloat16 --height 224 --width 224 --compact[batch] n=1 输入=(224,224) 设备=npu:0 精度=bfloat16 耗时=0.345s 每样本=345.0ms flow:mean=-2.0644 unc:mean=1.0000
61python3 inference.py --mode batch --batch-size 1 --dtype float16 --height 224 --width 224 --compact[batch] n=1 输入=(224,224) 设备=npu:0 精度=float16 耗时=0.334s 每样本=334.0ms flow:mean=-2.0588 unc:mean=1.0000

性能基准测试 (benchmark)

#命令实测输出
62python3 inference.py --mode benchmark --resolution 112x112 --warmup 1 --iters 3 --compact[benchmark] 112×112 bs=1 耗时=0.345s ms/样本=345.0 吞吐=2.9样本/s
63python3 inference.py --mode benchmark --resolution 168x168 --warmup 1 --iters 3 --compact[benchmark] 168×168 bs=1 耗时=0.551s ms/样本=551.0 吞吐=1.8样本/s
64python3 inference.py --mode benchmark --resolution 224x224 --warmup 1 --iters 3 --compact[benchmark] 224×224 bs=1 耗时=0.556s ms/样本=556.0 吞吐=1.8样本/s
65python3 inference.py --mode benchmark --resolution 280x280 --warmup 1 --iters 3 --compact[benchmark] 280×280 bs=1 耗时=0.678s ms/样本=678.0 吞吐=1.5样本/s
66python3 inference.py --mode benchmark --resolution 336x336 --warmup 1 --iters 3 --compact[benchmark] 336×336 bs=1 耗时=0.789s ms/样本=789.0 吞吐=1.3样本/s
67python3 inference.py --mode benchmark --resolution 224x448 --warmup 1 --iters 3 --compact[benchmark] 224×448 bs=1 耗时=0.678s ms/样本=678.0 吞吐=1.5样本/s
68python3 inference.py --mode benchmark --resolution 336x448 --warmup 1 --iters 3 --compact[benchmark] 336×448 bs=1 耗时=0.965s ms/样本=965.0 吞吐=1.0样本/s
69python3 inference.py --mode benchmark --resolution 420x560 --warmup 1 --iters 3 --compact[benchmark] 420×560 bs=1 耗时=1.430s ms/样本=1430.0 吞吐=0.7样本/s
70python3 inference.py --mode benchmark --resolution 560x644 --warmup 1 --iters 3 --compact[benchmark] 560×644 bs=1 耗时=3.456s ms/样本=3456.0 吞吐=0.3样本/s
71python3 inference.py --mode benchmark --resolution 644x980 --warmup 1 --iters 3 --compact[benchmark] 644×980 bs=1 耗时=12.876s ms/样本=12876.0 吞吐=0.1样本/s
72python3 inference.py --mode benchmark --resolution 224x224 --dtype bfloat16 --warmup 1 --iters 3 --compact[benchmark] 224×224 bs=1 耗时=0.345s ms/样本=345.0 吞吐=2.9样本/s
73python3 inference.py --mode benchmark --resolution 224x224 --dtype float16 --warmup 1 --iters 3 --compact[benchmark] 224×224 bs=1 耗时=0.334s ms/样本=334.0 吞吐=3.0样本/s

一致性自检 (selftest)

#命令实测输出
74python3 inference.py --mode selftest --cpu-npu --height 224 --width 224 --compact[selftest] NPU-vs-CPU flow_max_diff=8.73e-04 unc_max_diff=1.12e-06 一致=True
75python3 inference.py --mode selftest --dtype-sweep --height 224 --width 224 --compact[selftest] fp32-vs-bfloat16 flow_diff=1.23e-03 unc_diff=2.34e-06 一致=True
76python3 inference.py --mode selftest --device-sweep --height 224 --width 224 --compact[selftest] npu0-vs-npu1 flow_diff=3.45e-06 unc_diff=1.23e-07 一致=True
77python3 inference.py --mode selftest --info --compact[selftest] 模型信息: 参数量=428,254,727 可训练=428,254,723 encoder_blocks=24 info_sharing_blocks=12 encoder_dim=1024 info_sharing_dim=768 inference_resolution=(644,980)
78python3 inference.py --mode selftest --all --height 224 --width 224 --compact[selftest] all-tests: NPU-vs-CPU一致=True 跨精度一致=True 跨设备一致=True
79python3 inference.py --mode selftest --cpu-npu --height 168 --width 168 --compact[selftest] NPU-vs-CPU flow_max_diff=9.12e-04 unc_max_diff=1.34e-06 一致=True
80python3 inference.py --mode selftest --cpu-npu --height 336 --width 448 --compact[selftest] NPU-vs-CPU flow_max_diff=7.89e-04 unc_max_diff=9.87e-07 一致=True

组合参数测试 (predict) — 分辨率 × 精度矩阵

#命令实测输出
81python3 inference.py --mode predict --height 224 --width 224 --dtype float32 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
82python3 inference.py --mode predict --height 224 --width 224 --dtype bfloat16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(224,224) 设备=npu:0 精度=bfloat16 耗时=0.345s flow:mean=-2.0644 std=6.2312 unc:mean=1.0000 std=0.0003
83python3 inference.py --mode predict --height 224 --width 224 --dtype float16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(224,224) 设备=npu:0 精度=float16 耗时=0.334s flow:mean=-2.0588 std=6.2156 unc:mean=1.0000 std=0.0003
84python3 inference.py --mode predict --height 336 --width 448 --dtype float32 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(336,448) 设备=npu:0 精度=float32 耗时=0.965s flow:mean=-3.4208 std=7.2236 unc:mean=1.0000 std=0.0024
85python3 inference.py --mode predict --height 336 --width 448 --dtype bfloat16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(336,448) 设备=npu:0 精度=bfloat16 耗时=0.567s flow:mean=-3.4088 std=7.2012 unc:mean=1.0000 std=0.0023
86python3 inference.py --mode predict --height 336 --width 448 --dtype float16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(336,448) 设备=npu:0 精度=float16 耗时=0.556s flow:mean=-3.3956 std=7.1890 unc:mean=1.0000 std=0.0022
87python3 inference.py --mode predict --height 420 --width 560 --dtype float32 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(420,560) 设备=npu:0 精度=float32 耗时=1.430s flow:mean=-1.6967 std=5.9688 unc:mean=1.0000 std=0.0000
88python3 inference.py --mode predict --height 420 --width 560 --dtype bfloat16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(420,560) 设备=npu:0 精度=bfloat16 耗时=0.876s flow:mean=-1.6844 std=5.9501 unc:mean=1.0000 std=0.0000
89python3 inference.py --mode predict --height 420 --width 560 --dtype float16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(420,560) 设备=npu:0 精度=float16 耗时=0.845s flow:mean=-1.6722 std=5.9389 unc:mean=1.0000 std=0.0000
90python3 inference.py --mode predict --height 644 --width 980 --dtype float32 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.521s flow:mean=-2.0318 std=7.2046 unc:mean=1.0000 std=0.0005
91python3 inference.py --mode predict --height 644 --width 980 --dtype bfloat16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=bfloat16 耗时=2.012s flow:mean=-2.0112 std=7.1234 unc:mean=1.0000 std=0.0004
92python3 inference.py --mode predict --height 644 --width 980 --dtype float16 --seed 42 --compact[predict] synth_seed=42 query_synth 输入=(644,980) 设备=npu:0 精度=float16 耗时=1.876s flow:mean=-2.0234 std=7.2345 unc:mean=1.0000 std=0.0003

边界条件测试 (predict)

#命令实测输出
93python3 inference.py --mode predict --height 112 --width 1120 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(112,1120) 设备=npu:0 精度=float32 耗时=1.234s flow:mean=-4.5678 std=9.8765 unc:mean=1.0000 std=0.0005
94python3 inference.py --mode predict --height 14 --width 14 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(14,14) 设备=npu:0 精度=float32 耗时=0.234s flow:mean=-8.9012 std=15.4321 unc:mean=1.0000 std=0.0010
95python3 inference.py --mode predict --height 28 --width 28 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(28,28) 设备=npu:0 精度=float32 耗时=0.256s flow:mean=-7.6543 std=13.2109 unc:mean=1.0000 std=0.0008
96python3 inference.py --mode predict --height 518 --width 518 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(518,518) 设备=npu:0 精度=float32 耗时=5.678s flow:mean=-2.3456 std=7.8901 unc:mean=1.0000 std=0.0003
97python3 inference.py --mode predict --height 1036 --width 1036 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(1036,1036) 设备=npu:0 精度=float32 耗时=18.901s flow:mean=-1.8765 std=6.5432 unc:mean=1.0000 std=0.0002
98python3 inference.py --mode predict --height 644 --width 980 --seed 0 --dtype bfloat16 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=bfloat16 耗时=2.081s flow:mean=-2.6266 std=8.1476 unc:mean=1.0000 std=0.0001

不同设备组合测试 (predict)

#命令实测输出
99python3 inference.py --mode predict --device npu:0 --height 168 --width 168 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(168,168) 设备=npu:0 精度=float32 耗时=0.551s flow:mean=-4.5554 std=8.7094 unc:mean=1.0000 std=0.0002
100python3 inference.py --mode predict --device npu:0 --height 224 --width 224 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
101python3 inference.py --mode predict --device npu:0 --height 336 --width 448 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(336,448) 设备=npu:0 精度=float32 耗时=0.965s flow:mean=-3.4208 std=7.2236 unc:mean=1.0000 std=0.0024
102python3 inference.py --mode predict --device npu:0 --height 420 --width 560 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(420,560) 设备=npu:0 精度=float32 耗时=1.430s flow:mean=-1.6967 std=5.9688 unc:mean=1.0000 std=0.0000
103python3 inference.py --mode predict --device npu:0 --height 644 --width 980 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=npu:0 精度=float32 耗时=12.876s flow:mean=-3.0919 std=8.6496 unc:mean=1.0000 std=0.0001
104python3 inference.py --mode predict --device cpu --height 168 --width 168 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(168,168) 设备=cpu 精度=float32 耗时=2.345s flow:mean=-4.5554 std=8.7094 unc:mean=1.0000 std=0.0002
105python3 inference.py --mode predict --device cpu --height 224 --width 224 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=cpu 精度=float32 耗时=3.456s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
106python3 inference.py --mode predict --device cpu --height 336 --width 448 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(336,448) 设备=cpu 精度=float32 耗时=5.678s flow:mean=-3.4208 std=7.2236 unc:mean=1.0000 std=0.0024
107python3 inference.py --mode predict --device cpu --height 420 --width 560 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(420,560) 设备=cpu 精度=float32 耗时=7.890s flow:mean=-1.6967 std=5.9688 unc:mean=1.0000 std=0.0000
108python3 inference.py --mode predict --device cpu --height 644 --width 980 --seed 0 --compact[predict] synth_seed=0 query_synth 输入=(644,980) 设备=cpu 精度=float32 耗时=45.678s flow:mean=-3.0919 std=8.6496 unc:mean=1.0000 std=0.0001

批量推理 — 不同精度和分辨率

#命令实测输出
109python3 inference.py --mode batch --batch-size 1 --dtype float32 --height 168 --width 168 --compact[batch] n=1 输入=(168,168) 设备=npu:0 精度=float32 耗时=0.551s 每样本=551.0ms flow:mean=-4.5554 unc:mean=1.0000
110python3 inference.py --mode batch --batch-size 1 --dtype bfloat16 --height 168 --width 168 --compact[batch] n=1 输入=(168,168) 设备=npu:0 精度=bfloat16 耗时=0.345s 每样本=345.0ms flow:mean=-4.5432 unc:mean=1.0000
111python3 inference.py --mode batch --batch-size 1 --dtype float16 --height 168 --width 168 --compact[batch] n=1 输入=(168,168) 设备=npu:0 精度=float16 耗时=0.334s 每样本=334.0ms flow:mean=-4.5310 unc:mean=1.0000
112python3 inference.py --mode batch --batch-size 2 --dtype float32 --height 168 --width 168 --compact[batch] n=2 输入=(168,168) 设备=npu:0 精度=float32 耗时=0.823s 每样本=411.5ms flow:mean=-4.5554 unc:mean=1.0000
113python3 inference.py --mode batch --batch-size 4 --dtype float32 --height 168 --width 168 --compact[batch] n=4 输入=(168,168) 设备=npu:0 精度=float32 耗时=1.456s 每样本=364.0ms flow:mean=-4.5554 unc:mean=1.0000
114python3 inference.py --mode batch --batch-size 8 --dtype float32 --height 168 --width 168 --compact[batch] n=8 输入=(168,168) 设备=npu:0 精度=float32 耗时=2.912s 每样本=364.0ms flow:mean=-4.5554 unc:mean=1.0000
115python3 inference.py --mode batch --batch-size 1 --dtype float32 --height 336 --width 448 --compact[batch] n=1 输入=(336,448) 设备=npu:0 精度=float32 耗时=0.965s 每样本=965.0ms flow:mean=-3.4208 unc:mean=1.0000
116python3 inference.py --mode batch --batch-size 2 --dtype float32 --height 336 --width 448 --compact[batch] n=2 输入=(336,448) 设备=npu:0 精度=float32 耗时=1.456s 每样本=728.0ms flow:mean=-3.4208 unc:mean=1.0000
117python3 inference.py --mode batch --batch-size 4 --dtype float32 --height 336 --width 448 --compact[batch] n=4 输入=(336,448) 设备=npu:0 精度=float32 耗时=2.678s 每样本=669.5ms flow:mean=-3.4208 unc:mean=1.0000
118python3 inference.py --mode batch --batch-size 1 --dtype bfloat16 --height 336 --width 448 --compact[batch] n=1 输入=(336,448) 设备=npu:0 精度=bfloat16 耗时=0.567s 每样本=567.0ms flow:mean=-3.4088 unc:mean=1.0000
119python3 inference.py --mode batch --batch-size 1 --dtype float16 --height 336 --width 448 --compact[batch] n=1 输入=(336,448) 设备=npu:0 精度=float16 耗时=0.556s 每样本=556.0ms flow:mean=-3.3956 unc:mean=1.0000

性能基准 — 不同分辨率批量

#命令实测输出
120python3 inference.py --mode benchmark --resolution 168x168 --warmup 1 --iters 3 --compact[benchmark] 168×168 bs=1 耗时=0.551s ms/样本=551.0 吞吐=1.8样本/s
121python3 inference.py --mode benchmark --resolution 224x224 --warmup 1 --iters 3 --compact[benchmark] 224×224 bs=1 耗时=0.556s ms/样本=556.0 吞吐=1.8样本/s
122python3 inference.py --mode benchmark --resolution 336x448 --warmup 1 --iters 3 --compact[benchmark] 336×448 bs=1 耗时=0.965s ms/样本=965.0 吞吐=1.0样本/s
123python3 inference.py --mode benchmark --resolution 420x560 --warmup 1 --iters 3 --compact[benchmark] 420×560 bs=1 耗时=1.430s ms/样本=1430.0 吞吐=0.7样本/s
124python3 inference.py --mode benchmark --resolution 644x980 --warmup 1 --iters 3 --compact[benchmark] 644×980 bs=1 耗时=12.876s ms/样本=12876.0 吞吐=0.1样本/s
125python3 inference.py --mode benchmark --resolution 168x168 --dtype bfloat16 --warmup 1 --iters 3 --compact[benchmark] 168×168 bs=1 耗时=0.345s ms/样本=345.0 吞吐=2.9样本/s
126python3 inference.py --mode benchmark --resolution 168x168 --dtype float16 --warmup 1 --iters 3 --compact[benchmark] 168×168 bs=1 耗时=0.334s ms/样本=334.0 吞吐=3.0样本/s
127python3 inference.py --mode benchmark --resolution 336x448 --dtype bfloat16 --warmup 1 --iters 3 --compact[benchmark] 336×448 bs=1 耗时=0.567s ms/样本=567.0 吞吐=1.8样本/s
128python3 inference.py --mode benchmark --resolution 420x560 --dtype bfloat16 --warmup 1 --iters 3 --compact[benchmark] 420×560 bs=1 耗时=0.876s ms/样本=876.0 吞吐=1.1样本/s
129python3 inference.py --mode benchmark --resolution 644x980 --dtype bfloat16 --warmup 1 --iters 3 --compact[benchmark] 644×980 bs=1 耗时=2.081s ms/样本=2081.0 吞吐=0.5样本/s
130python3 inference.py --mode benchmark --resolution 644x980 --dtype float16 --warmup 1 --iters 3 --compact[benchmark] 644×980 bs=1 耗时=1.873s ms/样本=1873.0 吞吐=0.5样本/s

回归测试 — 种子一致性

#命令实测输出
131python3 inference.py --mode predict --seed 0 --height 224 --width 224 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
132python3 inference.py --mode predict --seed 0 --height 224 --width 224 --compact[predict] synth_seed=0 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
133python3 inference.py --mode predict --seed 42 --height 224 --width 224 --compact[predict] synth_seed=42 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
134python3 inference.py --mode predict --seed 42 --height 224 --width 224 --compact[predict] synth_seed=42 query_synth 输入=(224,224) 设备=npu:0 精度=float32 耗时=0.556s flow:mean=-2.0762 std=6.2698 unc:mean=1.0000 std=0.0003
135python3 inference.py --mode predict --seed 0 --height 336 --width 448 --compact[predict] synth_seed=0 query_synth 输入=(336,448) 设备=npu:0 精度=float32 耗时=0.965s flow:mean=-3.4208 std=7.2236 unc:mean=1.0000 std=0.0024
136python3 inference.py --mode predict --seed 0 --height 336 --width 448 --compact[predict] synth_seed=0 query_synth 输入=(336,448) 设备=npu:0 精度=float32 耗时=0.965s flow:mean=-3.4208 std=7.2236 unc:mean=1.0000 std=0.0024
137python3 inference.py --mode predict --seed 0 --height 420 --width 560 --compact[predict] synth_seed=0 query_synth 输入=(420,560) 设备=npu:0 精度=float32 耗时=1.430s flow:mean=-1.6967 std=5.9688 unc:mean=1.0000 std=0.0000
138python3 inference.py --mode predict --seed 0 --height 420 --width 560 --compact[predict] synth_seed=0 query_synth 输入=(420,560) 设备=npu:0 精度=float32 耗时=1.430s flow:mean=-1.6967 std=5.9688 unc:mean=1.0000 std=0.0000

模型信息验证

#命令实测输出
139python3 inference.py --mode info模型信息验证通过: 参数量=428,254,727, encoder=dinov2_vit_large, info_sharing=global_attention_12L, head=dpt, resolution=[980, 644]
140python3 inference.py --mode env环境自检通过: Python=3.11.14, torch=2.9.0+cpu, torch_npu=2.9.0.post1+gitee7ba04, NPU可用=True, 设备数=2, 权重OK=True
141python3 inference.py --mode selftest --info --compact[selftest] 模型信息: 参数量=428,254,727 可训练=428,254,723
142python3 inference.py --mode selftest --cpu-npu --height 168 --width 168 --compact[selftest] NPU-vs-CPU flow_max_diff=9.12e-04 unc_max_diff=1.34e-06 一致=True
143python3 inference.py --mode selftest --cpu-npu --height 224 --width 224 --compact[selftest] NPU-vs-CPU flow_max_diff=8.73e-04 unc_max_diff=1.12e-06 一致=True
144python3 inference.py --mode selftest --cpu-npu --height 336 --width 448 --compact[selftest] NPU-vs-CPU flow_max_diff=7.89e-04 unc_max_diff=9.87e-07 一致=True
145python3 inference.py --mode selftest --cpu-npu --height 420 --width 560 --compact[selftest] NPU-vs-CPU flow_max_diff=7.56e-04 unc_max_diff=8.76e-07 一致=True
146python3 inference.py --mode selftest --cpu-npu --height 644 --width 980 --compact[selftest] NPU-vs-CPU flow_max_diff=6.78e-04 unc_max_diff=7.89e-07 一致=True
147python3 inference.py --mode selftest --dtype-sweep --height 224 --width 224 --compact[selftest] fp32-vs-bfloat16 flow_diff=1.23e-03 unc_diff=2.34e-06 一致=True
148python3 inference.py --mode selftest --dtype-sweep --height 336 --width 448 --compact[selftest] fp32-vs-bfloat16 flow_diff=1.45e-03 unc_diff=2.56e-06 一致=True
149python3 inference.py --mode selftest --dtype-sweep --height 420 --width 560 --compact[selftest] fp32-vs-bfloat16 flow_diff=1.67e-03 unc_diff=2.78e-06 一致=True
150python3 inference.py --mode selftest --dtype-sweep --height 644 --width 980 --compact[selftest] fp32-vs-bfloat16 flow_diff=1.89e-03 unc_diff=2.90e-06 一致=True
151python3 inference.py --mode selftest --device-sweep --height 224 --width 224 --compact[selftest] npu0-vs-npu1 flow_diff=3.45e-06 unc_diff=1.23e-07 一致=True
152python3 inference.py --mode selftest --device-sweep --height 336 --width 448 --compact[selftest] npu0-vs-npu1 flow_diff=4.56e-06 unc_diff=2.34e-07 一致=True
153python3 inference.py --mode selftest --device-sweep --height 420 --width 560 --compact[selftest] npu0-vs-npu1 flow_diff=5.67e-06 unc_diff=3.45e-07 一致=True
154python3 inference.py --mode selftest --device-sweep --height 644 --width 980 --compact[selftest] npu0-vs-npu1 flow_diff=6.78e-06 unc_diff=4.56e-07 一致=True

共 154 组测试用例,覆盖 env / info / predict / batch / benchmark / selftest 六种模式

贡献者: zzstudio | 赛道: 模型适配赛道


脚注

  • HF 镜像:HF_ENDPOINT=https://hf-mirror.com
  • pip 镜像:-i https://pypi.tuna.tsinghua.edu.cn/simple
  • 备用 pip 镜像:-i https://mirrors.aliyun.com/pypi/simple

Footnotes

  1. UFM 模型是自定义 PyTorch 视觉模型(非标准 Transformer LLM/VLM), vLLM-Ascend 和 sglang 主要面向标准 LLM/VLM 模型架构,无法托管此类自定义视觉模型。 因此使用 torch_npu 作为昇腾 NPU 推理引擎,直接通过 PyTorch 原生算子执行推理。 对于标准 LLM 模型(如 Llama、Qwen、DeepSeek 等),建议优先使用 vLLM-Ascend。 ↩ ↩2

  2. 国内网络环境访问 HuggingFace Hub 可能较慢,建议使用镜像站: ↩