waylong/sptransformer-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/sptransformer on Ascend NPU

模型与任务

  • 模型:multimolecule/sptransformer
  • Revision:cb8ab1f834781820140842900014f89c359cf7a2
  • 适配路线:splicing
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "4.57.6",
  "multimolecule": "0.2.1",
  "device_name": "Ascend910_9362",
  "npu_available": true,
  "python": "3.11.14"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "primary_sequence_name": "insulin_mRNA",
  "primary_length": 333,
  "primary_sha256": "f94af5b8cf66600fae963521f441dcb6c933e2d93165ba93bcafa3941ca946fc",
  "primary_prefix": "AUGGCCCUGUGGAUGCGCCUCCUGCCCCUGCUGGCGCUGCUGGCCCUCUGGGGACCUGAC",
  "alphabet": "A/C/G/U/N",
  "replace_T_with_U": true,
  "context": 4000,
  "max_seq_len": 8192,
  "dtype": "float32",
  "tokenizer": "RnaTokenizer",
  "vocab": [
    "A",
    "C",
    "G",
    "U",
    "N"
  ],
  "secondary_length": 2000,
  "secondary_sha256": "f54182414eca28daae2ade8060f9085c37bb896740ee693b03a39fc7f944a163"
}

真实推理结果

{
  "route": "splicing",
  "logits_shape": [
    1,
    333,
    18
  ],
  "output_channels": [
    "no_splice",
    "acceptor",
    "donor",
    "tissue_0",
    "tissue_1",
    "tissue_2",
    "tissue_3",
    "tissue_4",
    "tissue_5",
    "tissue_6",
    "tissue_7",
    "tissue_8",
    "tissue_9",
    "tissue_10",
    "tissue_11",
    "tissue_12",
    "tissue_13",
    "tissue_14"
  ],
  "splice_head": "softmax over first 3 channels; donor prob example 0.0402 at pos 185",
  "tissue_usage_shape": [
    1,
    333,
    15
  ],
  "dtype": "float32",
  "device": "npu:0",
  "top_donor": {
    "pos": 185,
    "prob": 0.0402
  },
  "top_acceptor": {
    "pos": 195,
    "prob": 0.0163
  }
}

CPU-NPU 一致性

{
  "atol": 0.01,
  "rtol": 0.001,
  "max_abs_diff": 0.0066280364990234375,
  "mean_abs_diff": 0.0013362309974075995,
  "passed": true,
  "shape": [
    1,
    333,
    18
  ],
  "elements": 5994,
  "comparison_basis": "logits cpu vs npu:0 identical revision input"
}

性能

{
  "device": "npu:0",
  "dtype": "float32",
  "sequence_length": 333,
  "batch": 1,
  "avg_latency_s": 0.0328,
  "first_latency_s": 0.2732,
  "windows_per_s": 30.49,
  "bases_per_s": 10154.3,
  "warmup": 3,
  "stable_iterations": 10,
  "synchronize": "torch.npu.synchronize() before/after timing",
  "peak_memory_mb": "3108 / 65536"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 长序列>8192仍受max_seq_len限制,需分窗;本次500-2000nt在单卡可运行。

标签

#NPU #Ascend #Ascend910