FoMo-0D is a foundation model for
zero-shot tabular outlier detection. It is a PFN-style in-context transformer
that takes a reference (inlier) table plus a set of candidate rows and returns,
for every candidate row, a class probability that the row is an outlier. This
delivery adapts the official pretrained YuchenShen/FoMo-0D checkpoint to run
the full neural forward path on a Huawei Ascend NPU through torch_npu,
with strict weight verification, deterministic synthetic test data with injected
anomalies, and an acceptance metric (top-k precision / recall).
| Field | Value |
|---|---|
| Model | YuchenShen/FoMo-0D (PFN-style in-context transformer) |
| Task | tabular-outlier-detection |
| Source revision (model) | d0638efa3cc7ec93ffcc9f9aa2ed6d15030e1161 |
| Official implementation revision | 34d4339e318d96ac744850188a547b62387a718c |
| Weight | model.safetensors, 19 559 720 bytes |
| Weight SHA256 | 14506cee3d484d0a052ede20e2107b743ae31f1a0ca0860fb12d7f4db9e7acc4 |
| Engine | torch_npu |
| Device | npu:7 (Ascend 910B4-1, CANN 8.5.1) |
| License | MIT (upstream) |
Scope note. This repository is a portable inference delivery: it does not contain the pretrained weights. Point
--model-pathat a local checkout ofYuchenShen/FoMo-0D(withconfig.json+model.safetensors) and the script verifies size/SHA256 before loading.
FoMo-0D 是一个用于表格数据零样本异常检测的基础模型。其主干是
PFN(Prior-Fitted Network)风格的上下文(in-context)Transformer:给定一段
“参考/正常”的表格行(context)和若干待评分行(test),模型直接输出每一行属于
异常类别的概率。本交付基于官方预训练权重
YuchenShen/FoMo-0D(模型仓库修订
d0638efa3cc7ec93ffcc9f9aa2ed6d15030e1161,权重 SHA256
14506cee3d484d0a052ede20e2107b743ae31f1a0ca0860fb12d7f4db9e7acc4),并固定使用官方实现修订
34d4339e318d96ac744850188a547b62387a718c 的 fomo_hub.py 与 pfns/ 源码
(逐字拷贝,保留上游 LICENSE)。
所有神经网络输入张量、模型参数与最终输出张量均被断言位于指定的 Ascend NPU
(npu:7)上;若 NPU 不可用或任何放置/执行校验失败,脚本以非零码退出,
绝不静默回退到 CPU。
| Screenshot | Description |
|---|---|
![]() | Complete ModelAgent adaptation workflow (10 steps, real versions/results). |
![]() | Sanitized ModelAgent live-session dialogue for FoMo-0D. |
![]() | Real npu-smi info capture: the inference PID observed on NPU 7. |
![]() | Final real output and acceptance result. |
All four images are rendered from the real sanitized logs in logs/
(npu_inference.log, npu_device_call.log, npu_result.json,
env_versions.log, modelagent_dialogue_sanitized.txt).
d0638efa3cc7ec93ffcc9f9aa2ed6d15030e116134d4339e318d96ac744850188a547b62387a718c
(source tree: fomo-0d-34d4339e318d96ac744850188a547b62387a718c)model.safetensors
14506cee3d484d0a052ede20e2107b743ae31f1a0ca0860fb12d7f4db9e7acc4The container already provides a matched torch / torch_npu pair. Do not
reinstall or replace either from ordinary PyPI/CUDA wheels.
| Component | Version (verified) |
|---|---|
| OS / arch | openEuler 22.03 SP4, aarch64 |
| Python | 3.11.14 |
| torch | 2.9.0+cpu |
| torch_npu | 2.9.0 |
| CANN | 8.5.1 |
| NPU | Ascend 910B4-1 x8 (assigned npu:7) |
| numpy | 1.26.4 |
| safetensors | 0.8.0 |
| einops | 0.8.1 |
| huggingface_hub | 0.36.2 |
requirements.txt pins the top-level non-torch dependencies:
numpy==1.26.4
safetensors>=0.4.3,<0.9
einops>=0.7,<0.9
huggingface_hub>=0.24,<1.0Install with the Aliyun mirror:
python -m venv --system-site-packages /work/pipeline/runtime/venvs-tabular16/fomo-0d-npu
source /work/pipeline/runtime/venvs-tabular16/fomo-0d-npu/bin/activate
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
--system-site-packagesis used so the container-providedtorch/torch_npuremain the ones actually loaded.
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
source /usr/local/Ascend/ascend-toolkit/set_env.sh
npu-smi info # confirm 8x 910B4, all OKcd fomo-0d-npu
bash scripts/run_inference_npu.sh npu:7The script:
logs/env_versions.log;inference.py --model-path /work/pipeline/models/tabular16/fomo-0d --device npu:7 --output-json logs/npu_result.json --hold-seconds 8;npu-smi info into
logs/npu_device_call.log while the process is alive (the short hold keeps
the NPU context observable);inference.py directlypython inference.py \
--model-path /work/pipeline/models/tabular16/fomo-0d \
--device npu:7 \
--output-json logs/npu_result.json--out-json is accepted as a backward-compatible alias of --output-json.
--model-pathA public checkout works as long as the model path is supplied. Clone/copy the
FoMo-0D model repo (with config.json and model.safetensors) to any directory
and pass it:
python inference.py \
--model-path /any/path/to/YuchenShen/FoMo-0D \
--device npu:7 \
--output-json result.jsonThe script will refuse to run if the weight file size or SHA256 does not match the pinned values above.
Deterministic CC0 synthetic benchmark (seed 42, RandomState):
num_features = 100context = 1000 reference inlier rows, each feature ~ U(0,1)test = 20 rows: 16 inliers (U(0,1)) + 4 injected outliers whose 3
chosen features are set to extreme values 8.0 / -5.0 / 12.0[16, 17, 18, 19]Command:
python inference.py \
--model-path /work/pipeline/models/tabular16/fomo-0d \
--device npu:7 \
--context-size 1000 --num-test-rows 20 --num-outliers 4 --seed 42 \
--output-json logs/npu_result.jsonlogs/npu_inference.log)[ENV] hardware_name=Ascend910B4-1 cann=8.5.1 torch=2.9.0+cpu torch_npu=2.9.0 npu_count=8 requested_device=npu:7 actual_device=npu:7
[WEIGHT] hashing model.safetensors (19559720 bytes) ...
[WEIGHT] sha256=14506cee3d484d0a052ede20e2107b743ae31f1a0ca0860fb12d7f4db9e7acc4
[MODEL] constructing FoMo0DHub from /work/pipeline/models/tabular16/fomo-0d/config.json ...
[MODEL] strict load: missing=0 unexpected=0 state_dict_keys=101
[MODEL] loaded+placed in 1.05s
[MODEL] architecture=FoMo0DHub params=4886786 param_devices=['npu'] param_device_ids=[7]
[INPUT] wrote test_input.csv (context=(1000, 100), test=(20, 100))
[INPUT] device=npu:7 context=(1000, 1, 100) test=(20, 1, 100) dtype=torch.float32
[RUN] FoMo0DHub.forward(context=1000, test=20) ...
[OUT] shape=(20, 1, 2) device=npu:7 finite=True
[OUT] anomaly_score_min=0.002771 max=1.000000 mean=0.294692
[OUT] top-4 predicted outlier rows=[16, 17, 18, 19] (true injected=[16, 17, 18, 19])
[OUT] precision@4=1.0000 recall@4=1.0000
[OUT] sample anomaly_scores=[0.0028, 0.7947, 0.0156, 0.0195, 0.2781, 0.0079, 0.0122, 0.0154] ...
[PERF] latency=0.236s peak_memory=82.9MB
[DONE] wrote logs/npu_result.json exit_code=0logs/npu_device_call.log)npu-smi info captured the exact inference PID on NPU 7 while the process held
the device context:
| NPU Chip | Process id | Process name | Process memory(MB) |
| 7 0 | 2433087 | python | 242 |(PID 2433087 was observed in samples 6–16 of the live monitor; the steady-state
process memory is ~242 MB.)
Structured results are written to logs/npu_result.json:
{
"model_id": "YuchenShen/FoMo-0D",
"source_revision": "d0638efa3cc7ec93ffcc9f9aa2ed6d15030e1161",
"implementation_source_revision": "34d4339e318d96ac744850188a547b62387a718c",
"engine": "torch_npu",
"requested_device": "npu:7",
"actual_device": "npu:7",
"exit_code": 0,
"npu_available": true,
"npu_device_name": "Ascend910B4-1",
"input_device": "npu:7",
"model_device": "npu:7",
"output_device": "npu:7",
"placement": { "model": "npu:7", "input": "npu:7", "output": "npu:7" },
"npu_process_evidence": {
"pid": 2433087, "process_name": "python", "device": "npu:7",
"observed_in_npu_smi": true, "process_memory_mb": 242.0
},
"weights": {
"bytes": 19559720,
"sha256": "14506cee3d484d0a052ede20e2107b743ae31f1a0ca0860fb12d7f4db9e7acc4",
"size_matches": true,
"sha256_matches": true
},
"strict_load": { "missing_count": 0, "unexpected_count": 0, "state_dict_keys_loaded": 101 },
"model": { "architecture": "FoMo0DHub", "num_parameters": 4886786,
"param_devices": ["npu"], "param_device_ids": [7] },
"input": { "shape": [20, 1, 100], "device": "npu:7",
"context_shape": [1000, 1, 100] },
"output": { "shape": [20, 1, 2], "device": "npu:7", "finite": true,
"top_k_predicted_outliers": [16, 17, 18, 19],
"true_injected_outlier_rows": [16, 17, 18, 19],
"precision_at_k": 1.0, "recall_at_k": 1.0 },
"latency_s": 0.2356,
"peak_memory_mb": 82.89
}Key acceptance values:
torch_npu, npu_available = true, npu_device_name =
Ascend910B4-1npu:7 (placement
assertions passed)2433087 observed on npu:7 by the
live npu-smi info capture (observed_in_npu_smi = true, ~242 MB)(20, 1, 2)[16, 17, 18, 19] = exactly the injected
anomaliesinference.py imports torch_npu, requires an available Ascend NPU, sets
npu:7, and hard-fails if unavailable (no CPU neural fallback).npu:7.npu:7.--model-path to point
at a local FoMo-0D checkout (public checkout usage is supported).num_features = 100; datasets with a
different feature count need the PFN-style subsample/zero-pad procedure (see
the upstream ReadMe.md).float64; tensors are float32.--hold-seconds window exists only so a concurrent npu-smi
monitor can observe the short-lived inference PID; it does not change results.| Symptom | Cause / fix |
|---|---|
torch.npu.is_available() is False | Ascend env not loaded. Run source /usr/local/Ascend/ascend-toolkit/set_env.sh and check npu-smi info. |
failed to import torch_npu | torch/torch_npu pair broken. Recreate the venv with --system-site-packages; never pip-install another torch build. |
weight size mismatch / weight SHA256 mismatch | The --model-path does not contain the pinned model.safetensors. Verify bytes 19559720 and SHA256 14506cee…e7acc4. |
strict weight load failed: missing=… | config.json/pfns/ do not match the pinned implementation revision. Use the official source at 34d4339e…. |
model parameters not on npu:7 | ASCEND_RT_VISIBLE_DEVICES hides physical card 7. Export 0,1,2,3,4,5,6,7. |
No running processes found in NPU 7 during monitor | Inference is very short; increase --hold-seconds (e.g. HOLD_SECONDS=10). |
fomo_hub.py and pfns/ are copied verbatim from the official
implementation at revision 34d4339e318d96ac744850188a547b62387a718c.
Upstream license (MIT): LICENSE_FoMo0D_UPSTREAM.YuchenShen/FoMo-0D revision d0638efa3cc7ec93ffcc9f9aa2ed6d15030e1161.ReadMe.md.@article{shen2025fomod,
title={FoMo-0D: A Foundation Model for Zero-shot Tabular Outlier Detection},
author={Yuchen Shen and Haomin Wen and Leman Akoglu},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2025},
url={https://openreview.net/forum?id=XCQzwpR9jE}
}