waylong/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",
  "npu_available": true,
  "device_count": 2,
  "device_name": "Ascend910_9362",
  "python": "3.11.14",
  "multimolecule": "0.2.1",
  "transformers": "4.57.1"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence_preview": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAAGACCTGCCCTGTGCAGCTGT...TGCCCTGTGCAGCTGTGGGT",
  "sequence_length": 131072,
  "sequence_sha256": "e1e40ef8cc4309bef6ed5de96af40180d44453305407fa6055e064dcd2175463",
  "source": "TP53_exon_repeated (model card example)",
  "alphabet": "ACGTN",
  "direction": "5'->3'",
  "vocab_size": 5,
  "pad_token": "N",
  "tokenization": "DnaTokenizer add_special_tokens=False",
  "input_shape": [
    1,
    131072
  ],
  "dtype": "int64",
  "species": "human",
  "genome": "hg38"
}

真实推理结果

{
  "output_type": "TokenPredictorOutput",
  "logits_shape": [
    1,
    896,
    5313
  ],
  "logits_dtype": "float32",
  "coverage_shape": [
    1,
    896,
    5313
  ],
  "output_act": "softplus",
  "logits_sample_0_0_0_5": [
    -6.994517803192139,
    -7.662332057952881,
    -8.934393882751465,
    -6.769481182098389,
    -6.993365287780762
  ],
  "npu_logits_sample_0_0_0_5": [
    -6.993350982666016,
    -7.661088943481445,
    -8.933524131774902,
    -6.76840877532959,
    -6.992232799530029
  ],
  "coverage_sample_0_0_0_5": [
    0.0009164747316390276,
    0.00047009906847961247,
    0.00013176904758438468,
    0.0011476314393803477,
    0.0009175310842692852
  ],
  "npu_coverage_sample_0_0_0_5": [
    0.0009175442392006516,
    0.0004706836771219969,
    0.00013188370212446898,
    0.001148862182162702,
    0.0009185702656395733
  ],
  "finite": true,
  "bins": 896,
  "tracks": 5313,
  "crop_bins": 64,
  "sequence_length": 131072
}

CPU-NPU 一致性

{
  "passed": true,
  "atol": 0.02,
  "rtol": 0.02,
  "max_abs_diff": 0.00740814208984375,
  "mean_abs_diff": 0.00049156062137814,
  "shape": [
    1,
    896,
    5313
  ],
  "elements": 4760448,
  "pearson_r_sampled_200k": 1.0,
  "dtype": "float32",
  "comparison": "logits pre-softplus CPU vs NPU"
}

性能

{
  "batch": 1,
  "sequence_length": 131072,
  "bins": 896,
  "tracks": 5313,
  "dtype": "float32",
  "first_run_ms": 144.54,
  "stable_avg_ms": 17.14,
  "stable_min_ms": 16.91,
  "stable_max_ms": 17.98,
  "stable_p50_ms": 17.08,
  "windows_per_s": 58.34,
  "bases_per_s": 7646713,
  "seq_per_s": 58.34,
  "peak_npu_memory_MB": 565.8,
  "device": "npu:0",
  "warmup": 3,
  "stable_runs": 10,
  "synchronize": "torch.npu.synchronize() before/after timing"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 长上下文 131072 已验证单卡显存可运行,未测试更大 batch。

标签

#NPU #Ascend #Ascend910