w
gcw_uQ09W7jl/multimolecule-basset-NPU-58b9134ab267
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/basset on Ascend NPU

模型与任务

  • 模型:multimolecule/basset
  • Revision:c5c82a89eec1ef04ba31017c4108f62da89086ac
  • 适配路线:regulatory-sequence
  • 设备: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",
  "multimolecule": "0.2.1",
  "hf_endpoint": "https://hf-mirror.com"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "num_sequences": 3,
  "sequence_length_fixed": 600,
  "alphabet": "ACGTN (N-> zero vector, U->T)",
  "strand": "5'->3' retained",
  "padding": "pad/crop to 600 with N (id=4 invalid zero vector)",
  "sequences": [
    {
      "name": "tumor_p53",
      "length": 184,
      "sha256": "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
      "preview": "ACTCCCCTGCCCTCAACAAGATGTTTTGCC"
    },
    {
      "name": "ACGT_repeat_600",
      "length": 600,
      "sha256": "e4a387752a4865282071c8f2f26b4d990db42b00a357a5080766f61ba6f02dbd",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTAC"
    },
    {
      "name": "HBB_142",
      "length": 142,
      "sha256": "8677bfc09d6f00304fc9d688164f02d66bee2593a2062940777f23cfe9416126",
      "preview": "CATTTGCTTCTGACACAACTGTGTTCACTA"
    }
  ],
  "tokenizer": "custom ACGT->0-3 mapping, N/invalid->4 zero-vector via one_hot clamp",
  "add_special_tokens": false
}

真实推理结果

{
  "output_shape": [
    1,
    164
  ],
  "dtype": "float32",
  "task": "regulatory-activity multilabel DNase accessibility 164 cell types",
  "logits_range": [
    -64.28,
    4.5
  ],
  "probs_range": [
    0.0,
    0.992
  ],
  "samples": [
    {
      "name": "tumor_p53",
      "logits_first5": [
        -33.997249603271484,
        -52.75730895996094,
        -30.10797119140625,
        -38.292991638183594,
        -17.01207160949707
      ],
      "top5_idx": [
        108,
        148,
        147,
        26,
        131
      ],
      "top5_probs": [
        0.04023,
        0.002885,
        0.000116,
        7.8e-06,
        6.7e-06
      ]
    },
    {
      "name": "ACGT_repeat_600",
      "logits_first5": [
        -28.554784774780273,
        -50.88569259643555,
        -11.218734741210938,
        -25.927186965942383,
        -2.4466018676757812
      ],
      "top5_idx": [
        29,
        148,
        121,
        147,
        134
      ],
      "top5_probs": [
        0.991996,
        0.565719,
        0.379805,
        0.17877,
        0.136565
      ]
    },
    {
      "name": "HBB_142",
      "logits_first5": [
        -41.49272918701172,
        -64.2824478149414,
        -36.87633514404297,
        -46.32374572753906,
        -22.934064865112305
      ],
      "top5_idx": [
        108,
        148,
        147,
        55,
        131
      ],
      "top5_probs": [
        0.001669,
        6.1e-05,
        9.6e-07,
        6.7e-08,
        5.6e-08
      ]
    }
  ],
  "device_proof": "first_param:npu:0, input_ids:npu:0, logits:npu:0"
}

CPU-NPU 一致性

{
  "atol": 0.1,
  "rtol": 0.001,
  "max_abs_diff": 0.053066253662109375,
  "mean_abs_diff": 0.03097868338227272,
  "pearson": 0.9999999,
  "passed": true,
  "shape": [
    1,
    164
  ],
  "elements": 164,
  "note": "worst case ACGT_repeat dense 600bp; padded sequences diff <0.005"
}

性能

{
  "first_run_ms": 186.07,
  "avg_ms": 1.77,
  "min_ms": 1.5,
  "max_ms": 2.5,
  "throughput_seq_per_s": 565.39,
  "throughput_bases_per_s": 339233.1,
  "batch_size": 1,
  "sequence_length": 600,
  "dtype": "float32",
  "warmup": 3,
  "iters": 10
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 固定 600bp 窗口,非可变长度;长序列需滑动窗口。
  • N 视为 zero vector (invalid token),与原实现 one_hot clamp 语义一致。

标签

#NPU #Ascend #Ascend910