m
mengsihan/pangolin
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/pangolin on Ascend NPU

模型与任务

  • 模型:multimolecule/pangolin
  • Revision:39f9ff44ed65f773099c363712934d13c277c8d0
  • 适配路线:splicing
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "npu_device_name": "Ascend910_9362",
  "device_count": 2,
  "cann": "8.5.1"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "alphabet": "RNA A/C/G/U/N, T->U conversion",
  "sequences": [
    {
      "name": "microRNA21_short",
      "length": 22,
      "sha256": "9c1b1cd23c45d39d",
      "prefix": "UAGCUUAUCAGACUGAUGUUGA"
    },
    {
      "name": "interleukin10_mRNA",
      "length": 54,
      "sha256": "d47b009f29fb5202",
      "prefix": "AUGCACAGCUCAGCACUGCUCUGUUGCCUGGUCCUCCUGACUGGGGUGAGGGCC"
    },
    {
      "name": "long_premrna_200",
      "length": 471,
      "sha256": "a6b2a3ce244a2102",
      "prefix": "AUGGAGCCGGCGGCGGGGAGCAGCAUGGAGCCUUCGGCUGACUGGCUGGCCA"
    },
    {
      "name": "variant_pair_ref_alt",
      "length": 54,
      "variant_pos": 27,
      "ref": "C",
      "alt": "G",
      "ref_sha": "d47b009f29fb5202",
      "alt_sha": "f51dd69c29473334"
    }
  ],
  "context": 10000,
  "padding": 5000,
  "tokenizer": "RnaTokenizer vocab_size=5 pad_token=N",
  "model_type": "pangolin",
  "output_channels": [
    "heart_no_splice",
    "heart_splice_site",
    "heart_usage",
    "liver_no_splice",
    "liver_splice_site",
    "liver_usage",
    "brain_no_splice",
    "brain_splice_site",
    "brain_usage",
    "testis_no_splice",
    "testis_splice_site",
    "testis_usage"
  ]
}

真实推理结果

{
  "probabilities_shape": [
    1,
    471,
    12
  ],
  "last_hidden_state_shape": [
    1,
    471,
    32
  ],
  "dtype": "float32",
  "device": "npu:0",
  "per_tissue_means": {
    "heart": {
      "no_splice": 0.9475,
      "splice_site": 0.0525,
      "usage": 0.013
    },
    "liver": {
      "no_splice": 0.9498,
      "splice_site": 0.0502,
      "usage": 0.0082
    },
    "brain": {
      "no_splice": 0.9503,
      "splice_site": 0.0497,
      "usage": 0.0126
    },
    "testis": {
      "no_splice": 0.9496,
      "splice_site": 0.0504,
      "usage": 0.0113
    }
  },
  "variant_effect": {
    "delta_shape": [
      1,
      54,
      12
    ],
    "max_abs_delta": 0.00854,
    "mean_abs_delta": 0.000636,
    "heart_splice_max": 0.00133,
    "brain_splice_max": 0.008059
  }
}

CPU-NPU 一致性

{
  "method": "CPU vs NPU same weights, same input, compare probabilities tensor",
  "seq_length": 54,
  "shape": [
    1,
    54,
    12
  ],
  "atol": 0.001,
  "rtol": 0.001,
  "max_abs_diff": 0.00022348761558532715,
  "mean_abs_diff": 1.9635320324910644e-05,
  "passed": true,
  "long_seq_max_diff": 0.00010017
}

性能

{
  "device": "npu:0",
  "dtype": "float32",
  "batch": 1,
  "sequence_length": 471,
  "warmup": 3,
  "iters": 10,
  "avg_latency_ms": 984.84,
  "throughput_seq_per_s": 1.02,
  "bases_per_s": 478.3,
  "synchronize": true,
  "peak_hbm_mb": 3246
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • Context 10000 需显存随 L 增长,超长序列需分窗或降 batch。

标签

#NPU #Ascend #Ascend910