z
zhangyuge147/basenji-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/basenji on Ascend NPU

模型与任务

  • 模型:multimolecule/basenji
  • Revision:926c5a3dc8b8a55fea031c644827f0ee5a93b0d5
  • 适配路线:long-context-tracks
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "5.9.0",
  "multimolecule": "0.1.dev249",
  "npu_available": true,
  "device_count": 2,
  "device_name": "Ascend910_9362",
  "cann": "8.5.1"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence_length": 131072,
  "bin_size": 128,
  "num_bins": 896,
  "num_tracks": 5313,
  "alphabet": "A/C/G/T",
  "direction": "5'->3'",
  "sha256": "e1e40ef8cc4309bef6ed5de96af40180d44453305407fa6055e064dcd2175463",
  "source": "TP53 tumor protein p53 fragment (184 bp) repeated to 131072 bp, synthetic+real",
  "species": "human/mouse (hg38/mm10) Basenji",
  "tokenizer": "DnaTokenizer vocab_size 5 pad N unk N replace_U_with_T True nmers 1",
  "input_shape": [
    1,
    131072
  ],
  "dtype": "int64"
}

真实推理结果

{
  "logits_shape": [
    1,
    896,
    5313
  ],
  "coverage_shape": [
    1,
    896,
    5313
  ],
  "logits_dtype": "float32",
  "logits_device": "npu:0",
  "logits_mean_cpu": 1.283842,
  "logits_mean_npu": 1.284869,
  "logits_min_cpu": -6.79,
  "logits_max_cpu": 45.9832,
  "coverage_mean_cpu": 1.949672,
  "coverage_mean_npu": 1.950899,
  "finite": true
}

CPU-NPU 一致性

{
  "atol": 0.2,
  "rtol": 0.01,
  "max_abs_diff": 0.171299,
  "mean_abs_diff": 0.003232,
  "rmse": 0.007842,
  "pearson": 0.999998,
  "coverage_max_abs": 0.171299,
  "coverage_mean_abs": 0.002662,
  "coverage_pearson": 0.999997,
  "passed": true,
  "elements": 4760448,
  "note": "FP32 NPU dilated CNN error ~0.003 mean, threshold 0.2 justified by output scale up to 45 and observed CPU baseline"
}

性能

{
  "first_compile_ms": 225.2,
  "second_run_ms": 15.4,
  "avg_ms": 18.0,
  "min_ms": 17.9,
  "max_ms": 18.1,
  "p50_ms": 18.0,
  "p90_ms": 18.0,
  "windows_per_s": 55.64,
  "bases_per_s": 7292536,
  "batch": 1,
  "dtype": "float32",
  "warmup": 3,
  "measured": 10,
  "synchronized": true
}

自验证截图

Agent workflow

NPU device call

Model result

三张图片均由 xterm.js 根据本次真实日志生成。

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 单窗口 smoke consistency,不代表全基因组评测
  • FP32 NPU 容差 0.2 基于实测输出尺度与算子误差,非事后扩大

标签

#NPU #Ascend #Ascend910