waylong/basset
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/basset on Ascend NPU

模型与任务

  • 模型:multimolecule/basset
  • Revision:main
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "4.57.6",
  "multimolecule": "0.2.1",
  "npu_available": true,
  "device_name": "Ascend910_9362",
  "cann": "/usr/local/Ascend/cann-8.5.1"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "fixtures": [
    {
      "name": "synthetic_ACGTx150",
      "length": 600,
      "sha256": "e4a387752a4865282071c8f2f26b4d990db42b00a357a5080766f61ba6f02dbd",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT"
    },
    {
      "name": "p53_ENST00000269305_padded",
      "length": 600,
      "sha256": "9e12ec27708df048ff93a6d3da5e9e5468ee45379d4623ea4717c80952c46692",
      "preview": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAAGACCTGCCCTGTGCAGCTGT"
    },
    {
      "name": "HBB_padded",
      "length": 600,
      "sha256": "40a86f24159e5e7f2e9cd16b84fc4a98f54bdd1063e4529a4a5add93f6de464f",
      "preview": "CATTTGCTTCTGACACAACTGTGTTCACTAGCAACCTCAAACAGACACCATGGTGCATCT"
    }
  ],
  "primary": {
    "name": "synthetic_ACGTx150",
    "length": 600,
    "sha256": "e4a387752a4865282071c8f2f26b4d990db42b00a357a5080766f61ba6f02dbd"
  },
  "alphabet": "A/C/G/T/N",
  "direction": "5'->3'",
  "padding": "N pad to 600",
  "tokenizer": "DnaTokenizer 1-mer, replace_U_with_T=True",
  "input_ids_shape": [
    1,
    600
  ],
  "attention_mask_sum": 600
}

真实推理结果

{
  "logits_shape": [
    1,
    164
  ],
  "logits_dtype": "float32",
  "logits_device": "npu:0",
  "logits_first8": [
    -28.554784774780273,
    -50.88569259643555,
    -11.218734741210938,
    -25.927186965942383,
    -2.4466018676757812,
    -24.358234405517578,
    -37.0448112487793,
    -34.3331413269043
  ],
  "logits_stats": {
    "min": -64.06919860839844,
    "max": 4.81980562210083,
    "mean": -32.65049362182617
  },
  "top5_idx": [
    29,
    148,
    121,
    147,
    134
  ],
  "top5_logits": [
    4.81980562210083,
    0.2644076943397522,
    -0.4903729557991028,
    -1.5247011184692383,
    -1.8441112041473389
  ],
  "prob_first5": [
    3.9702198776844777e-13,
    7.954712440624018e-23,
    1.3420218238024972e-05,
    5.494975568315352e-12,
    0.07968740165233612
  ]
}

CPU-NPU 一致性

{
  "atol": 0.1,
  "rtol": 0.001,
  "max_abs_diff": 0.053066253662109375,
  "mean_abs_diff": 0.011313087814222507,
  "per_fixture_max": [
    0.053066253662109375,
    0.00344085693359375,
    0.004352569580078125
  ],
  "per_fixture_mean": [
    0.03097868329141198,
    0.001299703993448397,
    0.0016608761578071408
  ],
  "passed": true
}

性能

{
  "first_run_ms": 110.28,
  "stable_avg_ms": 2.16,
  "stable_min_ms": 2.02,
  "stable_max_ms": 2.77,
  "stable_p50_ms": 2.05,
  "windows_per_s": 463.6,
  "bases_per_s": 278152.0,
  "seq_len": 600,
  "batch": 1,
  "dtype": "float32",
  "device": "npu:0",
  "warmup": 3,
  "stable_runs": 10
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • Basset expects 600bp; shorter sequences padded with N.

标签

#NPU #Ascend #Ascend910