mengsihan/bpnet
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/bpnet on Ascend NPU

模型与任务

  • 模型:multimolecule/bpnet
  • Revision:44aafb32fc6d71fcf12d0a73054d28e095fe3099
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1",
  "python": "3.11.14",
  "cann": "8.5.1",
  "npu": "Ascend910_9362",
  "device_count": 2,
  "transformers": "4.57.6",
  "safetensors": "0.6.2",
  "huggingface_hub": "0.36.2"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "primary": "p53",
  "sequence": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAAGACCTGCCCTGTGCAGCTGTGGGTTGATTCCACACCCCCGCCCGGCACCCGCGTCCGCGCCATGGCCATCTACAAGCAGTCACAGCACATGACGGAGGTTGTGAGGCGCTGCCCCCACCATGAGCGCTGCTCAGATAGCGATGG",
  "length": 184,
  "sha256": "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
  "sha256_short": "7a04b9f182884881",
  "alphabet": "ACGTN",
  "vocab_size": 5,
  "pad_token_id": 4,
  "attention_mask": "ones",
  "tasks": [
    "Oct4",
    "Sox2",
    "Nanog",
    "Klf4"
  ],
  "strands": [
    "plus",
    "minus"
  ],
  "num_labels": 8,
  "channels": [
    "Oct4_plus",
    "Oct4_minus",
    "Sox2_plus",
    "Sox2_minus",
    "Nanog_plus",
    "Nanog_minus",
    "Klf4_plus",
    "Klf4_minus"
  ]
}

真实推理结果

{
  "profile_logits": {
    "shape": [
      1,
      184,
      8
    ],
    "dtype": "float32",
    "device": "npu:0"
  },
  "count_logits": {
    "shape": [
      1,
      8
    ],
    "dtype": "float32",
    "device": "npu:0",
    "values": [
      3.6178059577941895,
      3.9031870365142822,
      3.3213720321655273,
      3.22078013420105,
      4.384504795074463,
      4.541057586669922,
      3.3915560245513916,
      3.1498897075653076
    ]
  },
  "track": {
    "shape": [
      1,
      184,
      8
    ],
    "dtype": "float32",
    "device": "npu:0",
    "sample": [
      [
        0.22789062559604645,
        0.22833538055419922
      ],
      [
        0.19804693758487701,
        0.43220290541648865
      ],
      [
        0.08275831490755081,
        0.5760406255722046
      ]
    ]
  },
  "postprocess": "softmax(profile_logits, dim=1)*exp(count_logits)",
  "profile_logits_sample_cpu": [
    13.2381,
    12.8288,
    14.2556,
    14.416,
    10.1519
  ]
}

CPU-NPU 一致性

{
  "profile_logits": {
    "max_abs_diff": 0.0009469986,
    "mean_abs_diff": 0.0002956915,
    "atol": 0.001,
    "rtol": 0.001,
    "passed": true
  },
  "count_logits": {
    "max_abs_diff": 0.0002090931,
    "mean_abs_diff": 0.0001241565,
    "atol": 0.0005,
    "passed": true
  },
  "track": {
    "max_abs_diff": 0.0003685951,
    "mean_abs_diff": 4.229426e-05,
    "atol": 0.0005,
    "passed": true
  },
  "overall": "PASS",
  "note": "CPU vs NPU same weights, same sequence, float32"
}

性能

{
  "first_inference_ms": 246.28,
  "avg_ms_per_seq": 1.229,
  "seq_per_s": 813.81,
  "bases_per_s": 149741.3,
  "warmup": 3,
  "iters": 10,
  "batch": 1,
  "length": 184,
  "dtype": "float32",
  "device": "npu:0",
  "synchronize": "torch.npu.synchronize() before and after timing"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • regulatory-sequence profile/count factorized output, valid for DNA alphabet ACGT N, length 184 example, longer sequences may increase memory linearly.

标签

#NPU #Ascend #Ascend910