m
mengsihan/basenji
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": "2.9.0.post1+gitee7ba04",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "cann": "8.5.1",
  "npu": "Ascend910_9362",
  "device_count": 2,
  "python": "3.11.14"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence_source": "TP53 fragment extended - multimolecule/basenji README example",
  "sequence_sha256": "e1e40ef8cc4309bef6ed5de96af40180d44453305407fa6055e064dcd2175463",
  "sequence_length": 131072,
  "alphabet": "ACGTN",
  "direction": "5'->3'",
  "vocab_size": 5,
  "tokenizer": "DnaTokenizer",
  "input_ids_shape": [
    1,
    131072
  ],
  "input_ids_sample_first10": [
    0,
    1,
    3,
    1,
    1,
    1,
    1,
    3,
    2,
    1
  ],
  "input_ids_dtype": "int64",
  "crop_bins": 64,
  "bin_size_bps": 128,
  "species": "human hg38"
}

真实推理结果

{
  "logits_shape": [
    1,
    896,
    5313
  ],
  "logits_dtype": "float32",
  "output_act": "softplus",
  "coverage_shape": [
    1,
    896,
    5313
  ],
  "logits_mean_cpu": 1.283842,
  "logits_std_cpu": 3.221547,
  "logits_mean_npu": 1.284869,
  "logits_std_npu": 3.225801,
  "central_bin": 448,
  "top5_track_indices": [
    3888,
    1704,
    3822,
    2189,
    3603
  ],
  "top5_track_values": [
    42.053,
    36.401,
    35.117,
    31.413,
    29.028
  ],
  "output_bins": 896,
  "num_tracks": 5313
}

CPU-NPU 一致性

{
  "method": "CPU vs NPU with same weights, sequence, float32",
  "max_abs_diff": 0.171299,
  "mean_abs_diff": 0.003232,
  "pearson": 0.999998,
  "atol": 0.5,
  "rtol": 0.01,
  "passed": true,
  "finite_ratio": 1.0,
  "compare_script": "scripts/compare_outputs.py --atol 0.5 --rtol 0.01"
}

性能

{
  "device": "npu:0 Ascend910_9362",
  "dtype": "float32",
  "batch": 1,
  "sequence_length": 131072,
  "warmup_iterations": 3,
  "stable_iterations": 10,
  "first_latency_ms": 14.16,
  "stable_avg_latency_ms": 14.25,
  "windows_per_sec": 70.18,
  "bases_per_sec": 9199102.0,
  "bins_per_sec": 62884.49,
  "memory_allocated_MiB": 174.5,
  "memory_reserved_MiB": 856.0,
  "synchronize": true
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910