liucu/enformer
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/enformer on Ascend NPU

模型与任务

  • 模型:multimolecule/enformer
  • Revision:20daa9146973633a4a0d8afbd9aa93e9efa41de6
  • 适配路线:long-context-tracks
  • 设备:npu:0

环境依赖

{
  "python": "3.11.14",
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "device_name": "Ascend910_9362"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "route": "long-context-tracks",
  "sequence_length_bp": 196608,
  "alphabet": "ACGT",
  "source": "human HBB CDS NM_000518.5 tiled to the fixed Enformer window",
  "sequence_sha256_prefix": "8227f2a86294fb83",
  "input_ids_shape": [
    1,
    196608
  ],
  "dtype": "float32"
}

真实推理结果

{
  "logits_shape": [
    1,
    896,
    5313
  ],
  "bins": 896,
  "tracks": 5313,
  "species": "human",
  "spot_checks": [
    {
      "bin": 0,
      "track": 0,
      "cpu": -2.367642,
      "npu": -2.367878
    },
    {
      "bin": 0,
      "track": 500,
      "cpu": -3.397499,
      "npu": -3.397642
    },
    {
      "bin": 0,
      "track": 2000,
      "cpu": 0.956868,
      "npu": 0.95675
    },
    {
      "bin": 0,
      "track": 4000,
      "cpu": 1.240314,
      "npu": 1.240315
    },
    {
      "bin": 0,
      "track": 5312,
      "cpu": -4.975804,
      "npu": -4.975885
    },
    {
      "bin": 224,
      "track": 0,
      "cpu": -2.483006,
      "npu": -2.483219
    },
    {
      "bin": 224,
      "track": 500,
      "cpu": -3.486245,
      "npu": -3.486492
    },
    {
      "bin": 224,
      "track": 2000,
      "cpu": 0.998108,
      "npu": 0.99798
    },
    {
      "bin": 224,
      "track": 4000,
      "cpu": 1.275888,
      "npu": 1.275744
    },
    {
      "bin": 224,
      "track": 5312,
      "cpu": -4.593945,
      "npu": -4.593998
    },
    {
      "bin": 448,
      "track": 0,
      "cpu": -2.392922,
      "npu": -2.393126
    },
    {
      "bin": 448,
      "track": 500,
      "cpu": -3.430028,
      "npu": -3.430064
    },
    {
      "bin": 448,
      "track": 2000,
      "cpu": 1.042302,
      "npu": 1.042146
    },
    {
      "bin": 448,
      "track": 4000,
      "cpu": 1.175803,
      "npu": 1.175741
    },
    {
      "bin": 448,
      "track": 5312,
      "cpu": -4.080796,
      "npu": -4.080259
    },
    {
      "bin": 672,
      "track": 0,
      "cpu": -2.410372,
      "npu": -2.410436
    },
    {
      "bin": 672,
      "track": 500,
      "cpu": -3.473439,
      "npu": -3.473474
    },
    {
      "bin": 672,
      "track": 2000,
      "cpu": 0.991997,
      "npu": 0.991888
    },
    {
      "bin": 672,
      "track": 4000,
      "cpu": 1.392119,
      "npu": 1.392553
    },
    {
      "bin": 672,
      "track": 5312,
      "cpu": -4.777987,
      "npu": -4.777665
    },
    {
      "bin": 895,
      "track": 0,
      "cpu": -2.350616,
      "npu": -2.35057
    },
    {
      "bin": 895,
      "track": 500,
      "cpu": -3.375608,
      "npu": -3.375662
    },
    {
      "bin": 895,
      "track": 2000,
      "cpu": 0.983255,
      "npu": 0.983025
    },
    {
      "bin": 895,
      "track": 4000,
      "cpu": 1.30934,
      "npu": 1.309815
    },
    {
      "bin": 895,
      "track": 5312,
      "cpu": -5.010758,
      "npu": -5.010633
    }
  ],
  "logits_min": -7.838399,
  "logits_max": 7.753926
}

CPU-NPU 一致性

{
  "backend_cpu_vs_npu": true,
  "same_weights_revision": "20daa9146973633a4a0d8afbd9aa93e9efa41de6",
  "same_input_sha256": "8227f2a86294fb83",
  "max_abs_err": 0.00629663,
  "mean_abs_err": 0.00013704,
  "pearson_sampled_stride37": 0.99999999,
  "finite_ratio": 1.0,
  "thresholds": {
    "max_abs_tol": 0.05,
    "pearson_min": 0.999
  }
}

性能

{
  "warmup_runs": 3,
  "stable_runs": 10,
  "mean_latency_ms": 138.8,
  "std_latency_ms": 0.4,
  "windows_per_s": 7.2051,
  "bases_per_s": 1416578,
  "input_window_bp": 196608,
  "peak_npu_memory_mb": 3871,
  "timing_sync": "torch.npu.synchronize() before/after every timed run"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • smoke consistency against the fp32 CPU baseline only; not a full accuracy benchmark
  • single Ascend910 npu:0, fp32, batch size 1, fixed 196608 bp window

标签

#NPU #Ascend #Ascend910