waylong/aparent2-npu
模型介绍
文件和版本
Pull Requests
讨论
分析

multimolecule/aparent2 在 Ascend NPU 上的适配

模型与任务

  • 模型:multimolecule/aparent2
  • Revision:7ce086836126386421cb9f277c25461bdc6a1b7a
  • 适配路线:polyadenylation
  • 设备: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",
  "device_name": "Ascend910_9362",
  "npu_available": true,
  "device_count": 2
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence_ref": "A*70+AAUAAA+A*129",
  "sequence_alt": "A*70+AAUACA+A*129",
  "length": 205,
  "hexamer_position": 70,
  "alphabet": "A/C/G/U/N",
  "tokenizer": "RnaTokenizer",
  "vocab_size": 5,
  "sha256_ref": "c04a456284ac1eb2",
  "source": "synthetic fixed window per model card, variant effect pair"
}

真实推理结果

{
  "logits_shape": [
    1,
    206
  ],
  "iso_ref": 0.07777586579322815,
  "iso_alt": 0.015994712710380554,
  "delta_logodds": -1.6464157104492188,
  "profile": "cleavage distribution 206-dim (205 positions + no cleavage bucket)",
  "iso_window": "77:127",
  "example_logits_ref_cpu": [
    4.457043170928955,
    -5.991365909576416,
    -3.0637643337249756,
    -3.17375111579895,
    -1.8348164558410645
  ],
  "example_logits_ref_npu": [
    4.460202693939209,
    -5.9926910400390625,
    -3.0633773803710938,
    -3.17043399810791,
    -1.8316755294799805
  ]
}

CPU-NPU 一致性

{
  "method": "compare_outputs.py",
  "cpu": "multimolecule/aparent2 on cpu",
  "npu": "multimolecule/aparent2 on npu:0",
  "shape": [
    1,
    206
  ],
  "max_abs_diff": 0.006558418273925781,
  "mean_abs_diff": 0.0026144396979361773,
  "atol": 0.01,
  "rtol": 0.005,
  "passed": true,
  "variant_delta_cpu": -1.645439,
  "variant_delta_npu": -1.646416,
  "variant_delta_diff": 0.000977
}

性能

{
  "device": "npu:0",
  "dtype": "float32",
  "sequence_length": 205,
  "warmup": 3,
  "repeats": 10,
  "avg_latency_ms": 6.38,
  "first_compile_ms": "~214",
  "throughput_sequences_per_sec": 156.0,
  "synchronize": true
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 输入固定为 205 nt 窗口,hexamer 位于 70,超出长度需裁剪或补齐。
  • 变异效应需分别对 reference/alternative 序列进行推理,再按官方公式计算 delta logodds。

标签

#NPU #Ascend #Ascend910