waylong/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": "4.57.6",
  "multimolecule": "0.2.1",
  "npu_name": "Ascend910_9362",
  "npu_available": true,
  "device_count": 2
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "type": "RNA pre-mRNA, RnaTokenizer (A/C/G/U/N, T->U)",
  "context": 10000,
  "sequences": [
    {
      "name": "insulin mRNA",
      "length": 333,
      "sha256": "f94af5b8cf66600f",
      "source": "model card (AGPL, insulin)"
    },
    {
      "name": "synthetic 10k pre-mRNA",
      "length": 10000,
      "sha256": "f112381231344a20",
      "source": "synthetic seeded 42, GC 50.2%"
    },
    {
      "name": "variant 1k window REF/ALT",
      "length": 1000,
      "center_variant": "5000 C->G",
      "source": "synthetic 10k derived"
    }
  ],
  "tissues": [
    "heart",
    "liver",
    "brain",
    "testis"
  ],
  "output_channels": 12,
  "alphabet": "A/C/G/U/N, pad N, vocab_size 5"
}

真实推理结果

{
  "insulin_333_probabilities_shape": [
    1,
    333,
    12
  ],
  "10k_probabilities_shape": [
    1,
    10000,
    12
  ],
  "probabilities_dtype": "float32",
  "probabilities_device": "npu:0",
  "10k_mean": 0.33874714374542236,
  "10k_max": 0.9587808847427368,
  "per_channel_mean": [
    0.9497966766357422,
    0.05020333081483841,
    0.01731928251683712,
    0.9491901397705078,
    0.05080988258123398,
    0.011884518899023533,
    0.9496652483940125,
    0.05033481493592262,
    0.025545718148350716,
    0.9478689432144165,
    0.05213107913732529,
    0.010216089896857738
  ],
  "last_hidden_shape": [
    1,
    10000,
    32
  ],
  "insulin_probabilities": {
    "shape": [
      1,
      333,
      12
    ],
    "mean": 0.33752039074897766,
    "max": 0.9541811943054199
  },
  "10k": {
    "shape": [
      1,
      10000,
      12
    ],
    "mean": 0.33874714374542236,
    "max": 0.9587808847427368,
    "per_channel_mean": [
      0.9497966766357422,
      0.05020333081483841,
      0.01731928251683712,
      0.9491901397705078,
      0.05080988258123398,
      0.011884518899023533,
      0.9496652483940125,
      0.05033481493592262,
      0.025545718148350716,
      0.9478689432144165,
      0.05213107913732529,
      0.010216089896857738
    ]
  },
  "variant_delta": {
    "window": 1000,
    "variant": "5000 C->G",
    "max_abs": 0.010014571249485016,
    "mean_abs": 0.0001297384878853336
  }
}

CPU-NPU 一致性

{
  "compared": "probabilities [1,10000,12] tissue-specific splice logits/usage",
  "max_abs_diff": 0.0003357529640197754,
  "mean_abs_diff": 1.6775025869719684e-05,
  "atol": 0.001,
  "rtol": 0.001,
  "passed": true,
  "insulin_max_diff": 0.0002395511,
  "variant_delta_diff_max": 0.0001192689
}

性能

{
  "warmup": 3,
  "stable": 10,
  "sequence_length": 10000,
  "batch": 1,
  "dtype": "float32",
  "output_shape": [
    1,
    10000,
    12
  ],
  "avg_latency_ms": 1945.13,
  "min_latency_ms": 1944.63,
  "max_latency_ms": 1945.94,
  "seq_per_sec": 0.51,
  "bases_per_sec": 5141.0,
  "first_compile_ms": 1948.22,
  "device": "npu:0"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 长序列 10k 已验证单卡推理与显存;更长或批量需额外显存预判。

标签

#NPU #Ascend #Ascend910