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

multimolecule/bpfold on Ascend NPU

模型与任务

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

环境依赖

{
  "npu_name": "Ascend910_9362",
  "torch_version": "2.9.0+cpu",
  "torch_npu_version": "2.9.0.post1",
  "transformers_version": "5.9.0",
  "multimolecule_version": "0.2.1",
  "python_version": "3.11",
  "dtype": "float32"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "alphabet": "RNA A/C/G/U, tokenized by RnaTokenizer with official T-to-U replacement and <cls>/<eos> special tokens",
  "sequences": [
    {
      "name": "hsa-mir-21",
      "sequence": "UAGCUUAUCAGACUGAUGUUGA",
      "length_nt": 22,
      "sha256": "9c1b1cd23c45d39dd0b1fb28d72c49c0edcc57a16cb61c96119f84676c4b5b1c",
      "source": "multimolecule/bpfold model card example (microRNA 21)"
    },
    {
      "name": "hiv1-tar-wt",
      "sequence": "GGUCUCUCUGGUUAGACCAGAUCUGAGCCUGGGAGCUCUCUGGCUAACUAGGGAACC",
      "length_nt": 57,
      "sha256": "d98dc16a5bdf653371f61d4bf9aac95685c05e55604e2a5ef0b1ca28ea174396",
      "source": "multimolecule/bpfold model card example (HIV-1 TAR-WT)"
    },
    {
      "name": "vault-rna-2-1",
      "sequence": "CGGGUCGGAGUUAGCUCAAGCGGUUACCUCCUCAUGCCGGACUUUCUAUCUGUCCAUCUCUGUGCUGGGGUUCGAGACCCGCGGGUGCUUACUGACCCUUUUAUGCAA",
      "length_nt": 108,
      "sha256": "03106f8c8f0afec7e2c639d61c3809b14541dc6f54d4b4973ee4fa8f1bf90393",
      "source": "multimolecule/bpfold model card example (vault RNA 2-1)"
    }
  ],
  "direction": "5'->3'",
  "max_context_tokens": 600
}

真实推理结果

{
  "output_type": "contact_map: (L, L) base-pair probability matrix, special tokens stripped by the model",
  "per_sequence": {
    "hsa-mir-21": {
      "shape": [
        22,
        22
      ],
      "device": "npu:0",
      "finite": true,
      "pred_pairs_at_0.5": 74
    },
    "hiv1-tar-wt": {
      "shape": [
        57,
        57
      ],
      "device": "npu:0",
      "finite": true,
      "pred_pairs_at_0.5": 200
    },
    "vault-rna-2-1": {
      "shape": [
        108,
        108
      ],
      "device": "npu:0",
      "finite": true,
      "pred_pairs_at_0.5": 1027
    }
  },
  "structure_constraints": {
    "symmetric": true,
    "max_asymmetry": 1.19e-07,
    "no_self_pairs": true
  }
}

CPU-NPU 一致性

{
  "comparison": "CPU vs npu:0 with identical weights revision, sequences, preprocessing, dtype float32 and fixed inputs",
  "tolerance_policy": "atol=2e-3 rtol=1e-2 declared before measurement; fp32 probability-scale outputs in [0,1]",
  "results": [
    {
      "sequence": "hsa-mir-21",
      "elements": 484,
      "max_abs_diff": 0.000896,
      "mean_abs_diff": 0.000154,
      "passed": true
    },
    {
      "sequence": "hiv1-tar-wt",
      "elements": 3249,
      "max_abs_diff": 0.002423,
      "mean_abs_diff": 0.0001,
      "passed": true
    },
    {
      "sequence": "vault-rna-2-1",
      "elements": 11664,
      "max_abs_diff": 0.0018,
      "mean_abs_diff": 6.58e-05,
      "passed": true
    }
  ],
  "pair_agreement_f1_cpu_vs_npu_threshold_0.5": {
    "hsa-mir-21": 1.0,
    "hiv1-tar-wt": 0.9975,
    "vault-rna-2-1": 0.9995
  },
  "task_metrics_vs_model_card_annotations": {
    "note": "raw threshold=0.5 without post-processing refinement (config use_postprocessing=false); sensitivity=1.0 on all three annotated examples, low PPV is expected for raw maps before constrained refinement",
    "hsa-mir-21": {
      "ppv": 0.1486,
      "sensitivity": 1.0,
      "f1": 0.2588
    },
    "hiv1-tar-wt": {
      "ppv": 0.14,
      "sensitivity": 1.0,
      "f1": 0.2456
    },
    "vault-rna-2-1": {
      "ppv": 0.0516,
      "sensitivity": 1.0,
      "f1": 0.0981
    }
  }
}

性能

{
  "sequence": "vault-rna-2-1",
  "length_nt": 108,
  "warmup_runs": 3,
  "stable_runs": 10,
  "mean_latency_ms": 259.77,
  "throughput_seq_per_s": 3.85,
  "throughput_bases_per_s": 415.8,
  "dtype": "float32",
  "peak_npu_memory_mb": 217.3
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 验证覆盖 revision b78209659805196964fc82a201e4d01a7d15e503、float32 dtype、单序列 batch 与最长 108 nt 输入;未覆盖全部 600 nt 上限与批量推理场景。
  • 一致性比较为 smoke consistency:三条模型卡示例上的 CPU-NPU 数值对齐,非完整精度评测。
  • 原始 contact map 阈值化未启用 BPfold 约束后处理(use_postprocessing=false),配对 PPV 偏低属预期;结构约束(对称性、无自配对)已验证。

标签

#NPU #Ascend #Ascend910