liucu/a2zchromatin-methylation
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/a2zchromatin-methylation on Ascend NPU

模型与任务

  • 模型:multimolecule/a2zchromatin-methylation
  • Revision:47ae930b83f8e5264bd4a3cb58c11bc7caa19857
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "cann": "8.5.1",
  "soc": "Ascend910_9362",
  "npu_count": 2,
  "device_name": "Ascend910_9362",
  "hf_endpoint": "https://hf-mirror.com",
  "python": "3.11.14"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "alphabet": "A/C/G/T/N + IUPAC R/Y/S/W/K/M/B/D/H/V + pad '.'",
  "sequence_length": 600,
  "direction": "5'->3'",
  "sequences": [
    {
      "name": "synthetic_ACGTx150",
      "length": 600,
      "sha256": "e4a387752a4865282071c8f2f26b4d990db42b00a357a5080766f61ba6f02dbd",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT"
    },
    {
      "name": "p53_tumor_protein",
      "length": 184,
      "sha256": "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
      "preview": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAA"
    },
    {
      "name": "hemoglobin_beta",
      "length": 142,
      "sha256": "8677bfc09d6f00304fc9d688164f02d66bee2593a2062940777f23cfe9416126",
      "preview": "CATTTGCTTCTGACACAACTGTGTTCACTAGCAACCTCAA"
    }
  ],
  "tokenizer": "DnaTokenizer vocab=16 pad_token=. pad_id=15",
  "primary_used": "synthetic_ACGTx150 batch=1 attention_mask_sum=600"
}

真实推理结果

{
  "logits": [
    [
      0.009714861400425434
    ]
  ],
  "prob": [
    [
      0.5024287104606628
    ]
  ],
  "shape": [
    1,
    1
  ],
  "device": "npu:0",
  "dtype": "torch.float32",
  "description": "binary logit for lack of DNA methylation (unmethylated probability via sigmoid)",
  "additional": {
    "p53_logits": [
      -4.433578014373779
    ],
    "hbb_logits": [
      -5.420938968658447
    ]
  }
}

CPU-NPU 一致性

{
  "cpu_logits": [
    [
      0.009752139449119568
    ]
  ],
  "npu_logits": [
    [
      0.009714861400425434
    ]
  ],
  "max_abs_diff": 3.727804869413376e-05,
  "mean_abs_diff": 3.727804869413376e-05,
  "atol": 0.001,
  "rtol": 0.001,
  "passed": true,
  "dtype": "float32",
  "note": "NPU manual BiLSTM via F.linear on npu:0 due to ACL LSTM missing tbe; all tensors on npu:0"
}

性能

{
  "avg_time_ms": 19.503,
  "min_ms": 19.326,
  "max_ms": 19.672,
  "first_compile_ms": 229.383,
  "seq_per_s": 51.27,
  "bases_per_s": 30764.43,
  "batch": 1,
  "seq_len": 600,
  "dtype": "float32",
  "device": "npu:0",
  "warmup": 3,
  "stable_iters": 10
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • NPU LSTM 使用手动 matmul 实现以绕过 CANN 8.5.1 tbe 缺失导致的 ACL 编译失败,已验证与 CPU 数值一致性 <1e-03。

标签

#NPU #Ascend #Ascend910