gcw_6a3w2yXz/basset-NPU
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": "2.9.0.post1+gitee7ba04",
  "transformers": "4.57.6",
  "multimolecule": "0.2.1",
  "device_name": "Ascend910_9362",
  "npu_available": true,
  "device_count": 2,
  "soc_version": "ascend910_9391",
  "dtype": "float32"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence_length": 600,
  "alphabet": "ACGTN",
  "direction": "5'->3'",
  "tokenizer": "DnaTokenizer",
  "nmers": 1,
  "pad_token": "N",
  "batch": 6,
  "sequences_sha256": [
    "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
    "f60583147541647f44153ef3ff53c06dc45585703484619fffdc9a6c4e2bf5fb",
    "8677bfc09d6f00304fc9d688164f02d66bee2593a2062940777f23cfe9416126"
  ],
  "input_shape": [
    6,
    600
  ],
  "dtype": "int64",
  "source": "model card examples + synthetic",
  "species": "human (generic, ENCODE/DNase)",
  "num_labels": 164,
  "task": "chromatin accessibility (DNase I) multilabel"
}

真实推理结果

{
  "output_type": "logits",
  "shape": [
    6,
    164
  ],
  "dtype": "float32",
  "logits_mean_cpu": -43.171879,
  "logits_mean_npu": -43.17485,
  "logits_range_cpu": [
    -112.408165,
    4.828699
  ],
  "top5_idx_seq0": [
    108,
    148,
    147,
    26,
    131
  ],
  "example_logits_seq0_npu_first10": [
    -33.997249603271484,
    -52.75730895996094,
    -30.10797119140625,
    -38.292991638183594,
    -17.01207160949707,
    -15.983203887939453,
    -38.22380065917969,
    -44.71244812011719,
    -46.62736892700195,
    -31.382984161376953
  ],
  "activation": "sigmoid per-track (MultiLabelSoftMarginLoss training)",
  "finite_ratio": 1.0
}

CPU-NPU 一致性

{
  "method": "same weights, sequences, tokenizer, dtype float32, same random seed (eval mode)",
  "cpu_device": "cpu",
  "npu_device": "npu:0",
  "compared_tensor": "logits batch x 164",
  "max_abs_diff": 0.05295944,
  "mean_abs_diff": 0.00734043,
  "atol": 0.1,
  "rtol": 0.001,
  "passed": true,
  "threshold_reason": "float32 conv+BN on Ascend910 observed variance ~0.05, mean ~0.007"
}

性能

{
  "first_latency_ms": 179.3067,
  "avg_latency_ms": 1.3,
  "batch": 6,
  "sequence_length": 600,
  "min_latency_ms": 1.26,
  "max_latency_ms": 1.33,
  "p50_latency_ms": 1.307,
  "sequences_per_second": 4615.3,
  "bases_per_second": 2769177.55,
  "dtype": "float32",
  "device": "npu:0",
  "warmup_iters": 3,
  "stable_iters": 10,
  "synchronize": "torch.npu.synchronize() before/after timing",
  "memory_allocated_MB": 15.87,
  "memory_max_MB": 47.87
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 阈值基于 float32 在 Ascend910 上实测最大绝对误差 0.053 制定。

标签

#NPU #Ascend #Ascend910