waylong/malinois
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/malinois on Ascend NPU

模型与任务

  • 模型:multimolecule/malinois
  • Revision:0c670497e829ec4db586900ff35e89cf3666aa3e
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "python": "3.11.14",
  "npu_available": true,
  "device_count": 2,
  "device_name": "Ascend910_9362",
  "cann": "8.5.1",
  "npu_smi": "Ascend910 OK 174W 47C"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequences": [
    {
      "name": "synthetic_600bp",
      "length": 600,
      "sha256": "e4a387752a486528",
      "description": "ACGT*150 exact 600 bp, regulatory-sequence fixed input"
    },
    {
      "name": "TP53_184bp",
      "length": 184,
      "sha256": "7a04b9f182884881",
      "description": "tumor protein p53 184 bp, padded to 600 with N"
    },
    {
      "name": "KRAS_122bp",
      "length": 122,
      "sha256": "20d02a436ec189f8",
      "description": "KRAS proto-oncogene 122 bp, padded to 600"
    },
    {
      "name": "HBB_110bp",
      "length": 142,
      "sha256": "8677bfc09d6f0030",
      "description": "hemoglobin subunit beta fragment, padded to 600"
    }
  ],
  "selected": "synthetic_600bp",
  "tokenizer": "DnaTokenizer vocab 5 (A/C/G/T/N) pad N, model_max_length 600",
  "input_ids_shape": [
    1,
    600
  ],
  "attention_mask_shape": [
    1,
    600
  ],
  "dtype": "int64",
  "padding": "max_length 600 with N, truncation True",
  "alphabet": "DNA A/C/G/T/N, replace_U_with_T true, 5'->3' direction"
}

真实推理结果

{
  "logits_shape": [
    1,
    3
  ],
  "logits_dtype": "float32",
  "logits_device": "npu:0",
  "cell_lines": [
    "K562",
    "HepG2",
    "SK-N-SH"
  ],
  "logits_cpu": [
    [
      8.419232368469238,
      7.512470722198486,
      15.247061729431152
    ]
  ],
  "logits_npu": [
    [
      8.421932220458984,
      7.5143890380859375,
      15.25162124633789
    ]
  ],
  "finite": true,
  "output_type": "regression CRE activity logits"
}

CPU-NPU 一致性

{
  "max_abs_diff": 0.004559516906738281,
  "mean_abs_diff": 0.0030592281837016344,
  "threshold": 0.01,
  "result": "PASS",
  "per_sequence": [
    {
      "name": "TP53_184bp",
      "max_diff": 0.000111,
      "result": "PASS"
    },
    {
      "name": "KRAS_122bp",
      "max_diff": 2.9e-05,
      "result": "PASS"
    },
    {
      "name": "synthetic_600bp",
      "max_diff": 0.00456,
      "result": "PASS"
    },
    {
      "name": "HBB_110bp",
      "max_diff": 3.7e-05,
      "result": "PASS"
    }
  ],
  "note": "CPU and NPU used identical weights, sequences, tokenizer padding, dtype float32, seed 42; comparison on logits"
}

性能

{
  "first_run_ms": 109.62,
  "warmup": 3,
  "stable_runs": 10,
  "avg_ms": 3.05,
  "min_ms": 3.05,
  "max_ms": 3.07,
  "p50_ms": 3.05,
  "sequences_per_s": 327.6,
  "bases_per_s": 196574,
  "batch": 1,
  "input_length": 600,
  "dtype": "float32",
  "device": "npu:0",
  "peak_memory_MB": 15.7,
  "sync": "torch.npu.synchronize() before and after timed region"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910