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

multimolecule/scbasset on Ascend NPU

模型与任务

  • 模型:multimolecule/scbasset
  • Revision:ce1cc2bc0ceb24c7d11919a6308411715a240186
  • 适配路线: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"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "num_sequences": 8,
  "sequence_length_fixed": 1344,
  "sequence_length_source": "pad_center with N, center crop if longer",
  "alphabet": "ACGTN",
  "replace_U_with_T": true,
  "direction": "5'->3' forward",
  "strand_handling": "forward only, no RC ensemble",
  "species": "human (Buenrostro2018 hematopoiesis peaks)",
  "num_labels": 2034,
  "output_description": "per-cell accessibility logits [batch, 2034], sigmoid => prob",
  "dataset": "Buenrostro2018 2034 single cells, dataset-specific head",
  "sequences": [
    {
      "name": "TP53_tumor_p53",
      "raw_length": 184,
      "padded_length": 1344,
      "sha256": "4a565c985c665ac33877def96e1cc38a723e9f2b8dcdcfa4ea4621cf9bd9158b",
      "preview": "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
    },
    {
      "name": "BRCA1",
      "raw_length": 99,
      "padded_length": 1344,
      "sha256": "5cb8eede3dca2ffbaadf926cb7037c2d71d0073c04be46cf958996efacc57860",
      "preview": "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
    },
    {
      "name": "HBB_beta",
      "raw_length": 142,
      "padded_length": 1344,
      "sha256": "ed07a162f10ac7b73d60fb7676d2f8e34d30b9693dd41c07fe788558d0fed219",
      "preview": "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
    },
    {
      "name": "CFTR",
      "raw_length": 192,
      "padded_length": 1344,
      "sha256": "13f9090ca4c77f68e413f8c7562c8f9be5eaef8eafe2b780ef50fdc96f8ab0ab",
      "preview": "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
    },
    {
      "name": "KRAS",
      "raw_length": 122,
      "padded_length": 1344,
      "sha256": "7f666727dd00c64b317965b0363feaefed9d850a6d801a1545440769ec6a6543",
      "preview": "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
    },
    {
      "name": "ACGT_repeat_1344",
      "raw_length": 1344,
      "padded_length": 1344,
      "sha256": "8cea68b943344807fed6a965c8a10889db13e4514e8c30c9a75d0fd3b2d9ab43",
      "preview": "ACGTACGTACGTACGTACGTACGTACGTAC"
    },
    {
      "name": "N_masked_1344",
      "raw_length": 1344,
      "padded_length": 1344,
      "sha256": "3a936f3b1af609eb86cfcf6e265794c16cf8f7e7de42b533ccfa839115d6e8fa",
      "preview": "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
    },
    {
      "name": "GC_rich_1344",
      "raw_length": 1344,
      "padded_length": 1344,
      "sha256": "590d524bdc158991b801a963314e2e50fff130704b453b29329fad275feb4f3b",
      "preview": "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG"
    }
  ],
  "tokenizer": "DnaTokenizer vocab ACGT+N (A0 C1 G2 T3 N4), pad N, model_max_length 1344",
  "add_special_tokens": false
}

真实推理结果

{
  "output_shape": [
    1,
    2034
  ],
  "output_tracks": 2034,
  "dtype": "float32",
  "logits_stats": {
    "min": -9.825761795043945,
    "max": -0.6998799443244934,
    "mean": -3.998962640762329
  },
  "prob_stats": {
    "min": 5.4038388043409213e-05,
    "max": 0.33183884620666504,
    "mean": 0.031368132680654526
  },
  "top_cells": {
    "indices": [
      1300,
      1681,
      1224,
      631,
      770
    ],
    "logits": [
      -0.6998799443244934,
      -0.7036049365997314,
      -0.759493887424469,
      -0.7723084092140198,
      -0.8519067764282227
    ]
  },
  "device_proof": "first_param:npu:0, logits:npu:0, input:npu:0",
  "compare_sequence": "TP53_tumor_p53",
  "compare_length": 1344
}

CPU-NPU 一致性

{
  "atol": 0.001,
  "rtol": 0.001,
  "max_abs_diff": 0.002841949462890625,
  "mean_abs_diff": 0.0006645453128608396,
  "passed": true,
  "pearson": 0.9999998357862031,
  "pearson_prob": 0.9999997459219598,
  "shape": [
    1,
    2034
  ],
  "top5_overlap": 5,
  "prob_max_diff": 0.000367969274520874,
  "prob_mean_diff": 2.1874237063457258e-05
}

性能

{
  "first_run_ms": 187.1206760406494,
  "second_run_ms": 3.3593177795410156,
  "avg_ms": 3.3222198486328125,
  "min_ms": 3.270864486694336,
  "max_ms": 3.3979415893554688,
  "p50_ms": 3.308892250061035,
  "p90_ms": 3.384852409362793,
  "throughput_seq_per_s": 301.00355953611205,
  "throughput_bases_per_s": 404548.7840165346,
  "batch_size": 1,
  "sequence_length": 1344,
  "dtype": "float32"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910