liucu/bpfold
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/bpfold on Ascend NPU

模型与任务

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

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "device_name": "Ascend910_9362",
  "device_count": 2,
  "python": "3.11.14",
  "cann": "8.5.1",
  "model_dir": "/opt/atomgit/.cache/huggingface/hub/models--multimolecule--bpfold/snapshots/b78209659805196964fc82a201e4d01a7d15e503",
  "dtype": "float32"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "route": "rna-secondary-structure",
  "alphabet": "RNA A/C/G/U/N (vocab 11, replace_T_with_U true)",
  "strand": "5'->3'",
  "sequence_length": 22,
  "batch": 1,
  "primary_sequence": "UAGCUUAUCAGACUGAUGUUGA",
  "primary_sha256": "9c1b1cd23c45d39dd0b1fb28d72c49c0edcc57a16cb61c96119f84676c4b5b1c",
  "secondary_sequence": "GGUCUCUCUGGUUAGACCAGAUCUGAGCCUGGGAGCUCUCUGGCUAACUAGGGAACC",
  "secondary_sha256": "d98dc16a5bdf653371f61d4bf9aac95685c05e55604e2a5ef0b1ca28ea174396",
  "secondary_len": 57,
  "valid_tokens_mask": "all bases valid; padding via attention_mask",
  "threshold": 0.5,
  "species": "human microRNA-21 + HIV-1 TAR widget example",
  "tokenizer": "RnaTokenizer 1-mer, pad=<pad> id0, replace_T_with_U true",
  "dtype": "float32",
  "source": "model card widget microRNA-21 22 nt (primary), HIV TAR 57 nt (secondary check)"
}

真实推理结果

{
  "contact_map_shape": [
    1,
    22,
    22
  ],
  "contact_map_dtype": "float32",
  "contact_map_device": "npu:0",
  "contact_map_stats": {
    "min": 0.22520843148231506,
    "max": 0.9963423609733582,
    "mean": 0.5129372477531433,
    "std": 0.175866961479187
  },
  "candidates_above_threshold": 74,
  "total_pairs": 231,
  "top_pairs": [
    {
      "pair": [
        8,
        14
      ],
      "score": 0.97907555103302
    },
    {
      "pair": [
        9,
        19
      ],
      "score": 0.9761072397232056
    },
    {
      "pair": [
        6,
        16
      ],
      "score": 0.9675018787384033
    },
    {
      "pair": [
        7,
        15
      ],
      "score": 0.9649519324302673
    },
    {
      "pair": [
        9,
        13
      ],
      "score": 0.961707353591919
    }
  ],
  "postprocess": "raw contact_map sigmoid, threshold 0.5 for pair counting",
  "num_labels": 1,
  "threshold": 0.5
}

CPU-NPU 一致性

{
  "passed": true,
  "shape": [
    1,
    22,
    22
  ],
  "elements": 484,
  "max_abs_diff": 0.0008955597877502441,
  "mean_abs_diff": 0.00015353356138803065,
  "atol": 0.005,
  "rtol": 0.005
}

性能

{
  "avg_ms": 78.4510612487793,
  "p50_ms": 77.34107971191406,
  "min_ms": 76.50947570800781,
  "max_ms": 81.50720596313477,
  "seq_per_s": 12.746800159004351,
  "bases_per_s": 280.42960349809573,
  "input_length": 22,
  "batch_size": 1,
  "dtype": "float32",
  "device": "npu:0",
  "warmup": 3,
  "stable_runs": 10,
  "peak_memory_mb": 3200,
  "first_compile_ms": 81.50720596313477
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 单序列 22 nt smoke consistency;完整精度需 RNAStrAlign/bpRNA 数据集。
  • LxL 输出 O(L^2) 随长度增长,600 nt 峰值显存需预判。

标签

#NPU #Ascend #Ascend910