#NPU
FoMo-0D 是面向**表格数据零样本异常检测(outlier detection)**的先验数据拟合网络(Prior-data Fitted Network, PFN)。模型基于 RouterAttention 的 Transformer 骨干网络,在大规模合成 GMM 先验数据上预训练,推理时无需任何训练或超参搜索,仅需一次前向即可为每条测试样本输出异常评分。
YuchenShen/FoMo-0D使用 sklearn 内置的真实医学数据 load_breast_cancer(Wisconsin 乳腺肿瘤数据,可溯源,569 行 × 30 特征):
num_features=100推理脚本会校验 NPU 可用性;若 NPU 不可用直接退出,不做 CPU fallback。
npu:0,本验证为 Ascend910,HBM 64GB)HF_ENDPOINT 指向的国内镜像下载(huggingface_hub snapshot_download)pip install torch torch-npu huggingface_hub numpy scikit-learn pandaspython inference.py # 默认 npu:0,context=500
python inference.py --context-size 500脚本会:
~/.cache/fomo-0d-srcnpu:0,模型参数与全部输入 Tensor 均位于 npu:0,dtype=float32[model] repo=YuchenShen/FoMo-0D task=tabular-outlier-detection backend=torch_npu device=npu:0
[model] dtype=torch.float32 params=4.89M first-param-device=npu:0
[data] context=212 test=569 num_features=100
[perf] compile(first-run)=160.9ms rows=568
[perf] stable avg=4.7ms/row min=4.6ms max=6.2ms p50=4.7ms p90=4.7ms p95=5.5ms
[perf] throughput=211.7 rows/s (NPU inference only)
[result] aucroc=0.9678 aucpr=0.9764 f1=0.9468 num_anomalies=357
[status] OK异常检测效果:AUCROC=0.9678,AUCPR=0.9764,F1=0.9468。得分概率范围为 [0.0016, 1.0000]。
同一权重、同一预处理、同一 seed、同一输入(context=200,569 行)下对比 CPU 与 NPU 的异常评分(概率,范围 [0,1]):
atol=0.02, rtol=0.02;compare_outputs.py 校验通过(passed=true)以下三张 PNG 由 xterm.js 根据本次真实执行日志生成(非模拟截图):
:侦察、数据检查、下载、加载、NPU 推理、一致性、benchmark、提交校验全流程
:npu-smi、NPU 可用性、模型参数 device/dtype、输入/输出 Tensor device
:默认 python inference.py 的真实完整输出(schema、真实评分、同步耗时、状态)num_features=100:特征数 >100 需采样投影,<100 需补零;本验证使用 30 特征补零到 100