w
gcw_uQ09W7jl/basenji-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/basenji on Ascend NPU

模型与任务

  • 模型:multimolecule/basenji
  • Revision:926c5a3dc8b8a55fea031c644827f0ee5a93b0d5
  • 适配路线:long-context-tracks
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu_available": true,
  "device_name": "Ascend910_9362",
  "device_count": 2,
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "5.9.0",
  "multimolecule": "0.1.dev1+gf46a10b1f",
  "huggingface_hub": "1.5.0",
  "numpy": "1.26.4"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "num_windows": 3,
  "alphabet": "ACGTN",
  "replace_U_with_T": true,
  "sequence_length": 131072,
  "bin_size": 128,
  "num_bins": 896,
  "crop_bins": 64,
  "num_tracks": 5313,
  "species": "human/mouse",
  "strand_handling": "forward only, no reverse-complement average",
  "sequences": [
    {
      "name": "TP53_centered_131k",
      "length": 131072,
      "sha256": "19debcbb90a1ad3ecb30d042954083fd9b5fa6c7e2233e775f8eea21850bf63a",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTAC",
      "gc_percent": 50.02
    },
    {
      "name": "ACGT_repeat_131k",
      "length": 131072,
      "sha256": "32595d062a0538f68ba01abef1a132e3a1a3776699ca16025b51407f9aad46d5",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTAC",
      "gc_percent": 50.0
    },
    {
      "name": "BRCA1_centered_131k",
      "length": 131072,
      "sha256": "87ec52bba65895594f60c6b70047d0868888e5056df186e1e088d0a53ca09a6b",
      "preview": "TGCATGCATGCATGCATGCATGCATGCATG",
      "gc_percent": 49.99
    }
  ],
  "tokenizer": "DnaTokenizer vocab A0 C1 G2 T3 N4, one-hot, no specials",
  "add_special_tokens": false
}

真实推理结果

{
  "output_shape": [
    1,
    896,
    5313
  ],
  "output_shape_logits": [
    1,
    896,
    5313
  ],
  "output_shape_coverage": [
    1,
    896,
    5313
  ],
  "dtype": "float32",
  "bin_size": 128,
  "coverage_stats": {
    "min": 0.0008,
    "max": 96.8553,
    "mean": 2.2158,
    "std": 3.5571
  },
  "logits_stats": {
    "min": -7.1046,
    "max": 96.8553,
    "mean": 1.4906,
    "std": 3.9919
  },
  "center_bin_448_top_tracks": {
    "indices": [
      3234,
      2385,
      2832,
      3690,
      4764
    ],
    "values": [
      87.4192,
      78.0473,
      75.828,
      74.0393,
      71.4424
    ]
  },
  "first_bin_coverage_sample": [
    1.00567,
    0.90439,
    0.56245,
    0.11385,
    0.43996
  ],
  "first_bin_logits_sample": [
    0.55028,
    0.38555,
    -0.28106,
    -2.1154,
    -0.59302
  ],
  "device_proof": "first_param:npu:0, input:npu:0, logits:npu:0, coverage:npu:0",
  "compare_sequence": "TP53_centered_131k",
  "activation": "softplus"
}

CPU-NPU 一致性

{
  "atol": 0.1,
  "rtol": 0.01,
  "max_abs_diff_logits": 0.06860733,
  "mean_abs_diff_logits": 0.002031,
  "max_abs_diff_coverage": 0.06860733,
  "mean_abs_diff_coverage": 0.001498,
  "pearson_logits_20k": 1.0,
  "pearson_coverage_20k": 1.0,
  "passed": true,
  "shape": [
    1,
    896,
    5313
  ],
  "dtype": "float32"
}

性能

{
  "first_run_ms": 220.85,
  "second_run_ms": 14.21,
  "avg_ms": 14.21,
  "min_ms": 14.16,
  "max_ms": 14.27,
  "p50_ms": 14.2,
  "p90_ms": 14.26,
  "throughput_windows_per_s": 70.38,
  "throughput_bases_per_s": 9224756.38,
  "throughput_bins_per_s": 63059.86,
  "batch_size": 1,
  "sequence_length": 131072,
  "num_bins": 896,
  "num_tracks": 5313,
  "dtype": "float32",
  "npu_memory_allocated_MB": 173.55,
  "npu_memory_reserved_MB": 856.0
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910