gcw_6a3w2yXz/ufold-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/ufold on Ascend NPU

模型与任务

  • 模型:multimolecule/ufold
  • Revision:538de5c2f48e56731c092e40d54c641ff84a2154
  • 适配路线:rna-secondary-structure
  • 设备:npu:0

环境依赖

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

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequences": [
    {
      "name": "tRNA-Phe (74nt)",
      "sequence": "GGGCUAUUAGCUCAGUUGGUUAGAGCGCACCCCUGAUAAGGGUGAGGUCGCUGAUUCGAAUUCAGCAUAGCUCA",
      "length": 74,
      "sha256_prefix": "8d767029505e05b5"
    },
    {
      "name": "microRNA 21 (22nt)",
      "sequence": "UAGCUUAUCAGACUGAUGUUGA",
      "length": 22
    },
    {
      "name": "microRNA 155 (24nt)",
      "sequence": "UUAAUGCUAAUCGUGAUAGGGGUU",
      "length": 24
    }
  ],
  "batch_size": 3,
  "max_length_padded": 74,
  "alphabet": "A/C/G/U/N",
  "tokenizer": "RnaTokenizer",
  "attention_mask_sums": [
    74,
    22,
    24
  ]
}

真实推理结果

{
  "type": "LxL contact_map",
  "shape": [
    3,
    74,
    74
  ],
  "dtype": "float32",
  "device": "npu:0",
  "min": 0.0,
  "max": 1.0,
  "mean": 0.307284,
  "threshold": 0.5,
  "sample0_pairs_gt0.5": 21,
  "sample0_contact_3x3": [
    [
      0.5001803636550903,
      3.405505391573804e-11,
      5.169838943649055e-22
    ],
    [
      3.405505391573804e-11,
      0.5000002980232239,
      3.8285784183808916e-14
    ],
    [
      5.169838943649055e-22,
      3.8285784183808916e-14,
      0.500238299369812
    ]
  ]
}

CPU-NPU 一致性

{
  "atol": 0.0001,
  "rtol": 0.0001,
  "per_sample_max_abs": [
    1.77088659e-05,
    1.93382148e-05,
    6.36442564e-06
  ],
  "per_sample_mean_abs": [
    4.92282162e-08,
    1.91126617e-07,
    9.46417629e-08
  ],
  "full_batch_max_abs": 1.93382148e-05,
  "full_batch_mean_abs": 2.5358696e-08,
  "per_sample_pass": [
    true,
    true,
    true
  ],
  "shape_match": true,
  "finite": true,
  "passed": true
}

性能

{
  "device": "npu:0",
  "first_latency_ms": 254.54,
  "stable_avg_ms": 11.27,
  "stable_p50_ms": 11.17,
  "stable_p95_ms": 11.82,
  "warmup": 3,
  "iterations": 10,
  "batch_size": 3,
  "total_bases": 120,
  "sequence_per_s": 266.09,
  "bases_per_s": 10643.69,
  "dtype": "float32",
  "npu_memory_allocated_MB": 34.19,
  "synchronize": true
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。

标签

#NPU #Ascend #Ascend910