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

multimolecule/spotrna on Ascend NPU

模型与任务

  • 模型:multimolecule/spotrna
  • Revision:ea6e067d459da10f3e9154c90dd822ece47cf522
  • 适配路线:rna-secondary-structure
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "npu_name": "Ascend910_9362",
  "device_count": 2,
  "dtype": "float32"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "short_seq": "UAGCUUAUCAGACUGAUGUUGA",
  "short_len": 22,
  "short_sha256": "9c1b1cd23c45d39dd0b1fb28d72c49c0edcc57a16cb61c96119f84676c4b5b1c",
  "long_seq": "GGGCAUUUAGCUCAUGGUAGAGCGCUCGCUUAGCAUGCGAGAGGUAGCGGGACCCUCUGGUUCGAAUCCAGAGAAUGCCACCA",
  "long_len": 83,
  "alphabet": "A/C/G/U/N",
  "tokenizer": "RnaTokenizer",
  "threshold": 0.335
}

真实推理结果

{
  "logits_shape": [
    1,
    22,
    22
  ],
  "contact_map_shape": [
    1,
    22,
    22
  ],
  "contact_max": 0.98324,
  "contact_mean": 0.012928,
  "dot_bracket": ".(((..(((((.)))))))).",
  "predicted_pairs": [
    [
      9,
      13
    ],
    [
      10,
      12
    ],
    [
      8,
      14
    ],
    [
      7,
      15
    ],
    [
      6,
      16
    ],
    [
      1,
      19
    ],
    [
      2,
      18
    ],
    [
      3,
      17
    ]
  ],
  "num_pairs": 8
}

CPU-NPU 一致性

{
  "logits_max_abs_diff": 0.00907,
  "logits_mean_abs_diff": 0.001808,
  "contact_max_abs_diff": 0.000119,
  "contact_mean_abs_diff": 1.45e-06,
  "atol": 0.001,
  "rtol": 0.001,
  "passed": true,
  "note": "contact_map compared; LSTM member 3 BLSTM executed on CPU due to Ascend910 LSTM precision-mode limitation, remainder on npu:0 - explicit hybrid"
}

性能

{
  "device": "npu:0",
  "seq_len": 22,
  "dtype": "float32",
  "warmup": 3,
  "iters": 10,
  "avg_ms_per_seq": 87.9,
  "seq_per_s": 11.38,
  "bases_per_s": 250,
  "first_compile_ms": 366.89,
  "long_L83_ms": 284.78,
  "peak_memory_mb": "3110 / 65536"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • Member 3 的 2D BLSTM 因 Ascend 910 LSTM 精度模式限制在 CPU 执行,其余算子在 npu:0。

标签

#NPU #Ascend #Ascend910