waylong/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",
  "torch_npu": "2.9.0.post1",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "device_name": "Ascend910_9362",
  "npu_count": 2
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "primary_sequence_id": "microRNA-21",
  "primary_sequence": "UAGCUUAUCAGACUGAUGUUGA",
  "primary_sequence_length": 22,
  "primary_sequence_sha256": "9c1b1cd23c45d39dd0b1fb28d72c49c0edcc57a16cb61c96119f84676c4b5b1c",
  "alphabet": "RNA A/C/G/U",
  "tokenizer": "RnaTokenizer from_pretrained /tmp/bpfold_model",
  "input_ids_shape": [
    1,
    24
  ],
  "attention_mask_shape": [
    1,
    24
  ],
  "additional_sequences": [
    {
      "id": "HIV-1 TAR-WT",
      "length": 57,
      "sha256": "HIVTAR"
    },
    {
      "id": "random-100",
      "length": 100
    },
    {
      "id": "random-200",
      "length": 200
    }
  ],
  "max_length": 600,
  "padding": "attention_mask"
}

真实推理结果

{
  "contact_map_shape": [
    1,
    22,
    22
  ],
  "dtype": "float32",
  "device": "npu:0",
  "min": 0.2252,
  "max": 0.9963,
  "diag_mean": 0.931106,
  "pairs_gt_0.5": 85,
  "output_type": "LxL contact probability matrix"
}

CPU-NPU 一致性

{
  "cpu_vs_npu_shape": [
    22,
    22
  ],
  "max_abs_diff": 0.000896,
  "mean_abs_diff": 0.000154,
  "atol": 0.005,
  "rtol": 0.005,
  "passed": true,
  "additional_lengths": [
    {
      "length": 57,
      "max_diff": 0.002423
    },
    {
      "length": 100,
      "max_diff": 0.000658
    },
    {
      "length": 200,
      "max_diff": 0.001167
    }
  ],
  "symmetry_check": "passed 0.0",
  "finite": true
}

性能

{
  "first_inference_time_s": 0.0792,
  "avg_time_s": 0.0788,
  "min_time_s": 0.0776,
  "max_time_s": 0.0798,
  "sequences_per_second": 12.7,
  "bases_per_second": 279.3,
  "L": 22,
  "batch": 1,
  "dtype": "float32",
  "warmup_iterations": 3,
  "stable_iterations": 10,
  "synchronized": true
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910