waylong/multimolecule-deepstarr-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/deepstarr on Ascend NPU

模型与任务

  • 模型:multimolecule/deepstarr
  • Revision:f52a09a023db34889a8e6a60aa8e0ffe87c59b98
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "python": "3.11.14",
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "4.57.6",
  "multimolecule": "0.2.1",
  "cann": "8.5.1",
  "npu_device": "Ascend910_9362",
  "npu_count": 2,
  "dtype": "float32",
  "hardware": "Ascend910"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "primary_sequence": "synthetic_acgt_249",
  "length": 249,
  "padded_to": 249,
  "alphabet": "DNA A/C/G/T/N",
  "strand": "5'->3'",
  "species": "Drosophila melanogaster S2",
  "sequences": [
    {
      "name": "synthetic_acgt_249",
      "length": 249,
      "sha256": "d29e7c41c3673fc32dd3d68c460678f2b5399b7548d7c8b1ad9d3d7f04da5ea2",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACG..."
    },
    {
      "name": "synthetic_tgca_249",
      "length": 249,
      "sha256": "ada116d96e3c980cd79554eeba07e173f86549cd02613f7d7fb91325cf16b772",
      "preview": "TGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGA..."
    },
    {
      "name": "p53_fragment_184_padded",
      "length": 184,
      "padded_to": 249,
      "sha256": "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
      "preview": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAAGACCTGCCCT..."
    }
  ],
  "batch": 1,
  "input_ids_shape": [
    1,
    249
  ],
  "vocab_size": 5,
  "tokenizer": "DnaTokenizer",
  "output_labels": [
    "developmental",
    "housekeeping"
  ],
  "problem_type": "regression"
}

真实推理结果

{
  "logits_shape": [
    1,
    2
  ],
  "dtype": "float32",
  "device": "npu:0",
  "logits": [
    3.635379,
    1.900541
  ],
  "batch_logits_shape": [
    3,
    2
  ],
  "batch_results": [
    {
      "name": "synthetic_acgt_249",
      "developmental": 3.635379,
      "housekeeping": 1.900541
    },
    {
      "name": "synthetic_tgca_249",
      "developmental": 0.039185,
      "housekeeping": -0.576978
    },
    {
      "name": "p53_fragment_184_padded",
      "developmental": 0.802681,
      "housekeeping": -0.351009
    }
  ],
  "interpretation": "log2 enrichment over input for developmental and housekeeping enhancer activity"
}

CPU-NPU 一致性

{
  "single_sequence": {
    "shape": [
      1,
      2
    ],
    "max_abs_diff": 0.00018024444580078125,
    "mean_abs_diff": 0.00014960765838623047,
    "atol": 0.001,
    "rtol": 0.001,
    "passed": true
  },
  "batch_3": {
    "shape": [
      3,
      2
    ],
    "max_abs_diff": 0.0004477500915527344,
    "mean_abs_diff": 0.00023202660183111826,
    "atol": 0.001,
    "rtol": 0.001,
    "passed": true
  },
  "dtype": "float32",
  "backend": "CPU vs NPU float32"
}

性能

{
  "warmup": 3,
  "stable": 10,
  "avg_time_ms": 2.969,
  "throughput_seq_per_sec": 336.84,
  "throughput_bases_per_sec": 83874.3,
  "input_length": 249,
  "batch": 1,
  "dtype": "float32",
  "peak_memory": "N/A (Ascend910 64GB HBM, model 2.4MB weights, O(1) activation)",
  "synchronize": "torch.npu.synchronize() before and after timing"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 输入固定 249 bp,短序列用 N pad,长序列截断;物种为果蝇 S2,跨物种需重新校准阈值。

标签

#NPU #Ascend #Ascend910