gcw_6a3w2yXz/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",
  "transformers": "4.57.6",
  "multimolecule": "0.2.1",
  "device_name": "Ascend910_9362",
  "npu_available": true,
  "device_count": 2,
  "soc_version": "ascend910_9391",
  "dtype": "float32"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence_length": 600,
  "alphabet": "ACGTN",
  "direction": "5'->3'",
  "tokenizer": "DnaTokenizer",
  "nmers": 1,
  "pad_token": "N",
  "batch": 6,
  "sequences_sha256": [
    "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
    "f60583147541647f44153ef3ff53c06dc45585703484619fffdc9a6c4e2bf5fb",
    "8677bfc09d6f00304fc9d688164f02d66bee2593a2062940777f23cfe9416126",
    "cb090ed3985228b90a13d5057750cd0e9c2f8edd5ec7db97efe9d1e916c46be0",
    "e4a387752a4865282071c8f2f26b4d990db42b00a357a5080766f61ba6f02dbd",
    "277f872a2452b2107bf050002df32bb79ec2603a8e741d45abc4e01d4690dd14"
  ],
  "input_shape": [
    6,
    600
  ],
  "dtype": "int64",
  "source": "model card examples (TP53/BRCA1/HBB/CFTR) + synthetic ACGT/A*600",
  "species": "human (K562/HepG2/SK-N-SH MPRA)",
  "num_labels": 3,
  "task": "cis-regulatory element activity regression (3 cell lines)"
}

真实推理结果

{
  "output_type": "logits",
  "shape": [
    6,
    3
  ],
  "dtype": "float32",
  "logits_mean_cpu": 2.438061,
  "logits_mean_npu": 2.438499,
  "logits_range_cpu": [
    0.237387,
    15.247066
  ],
  "labels": [
    "K562",
    "HepG2",
    "SK-N-SH"
  ],
  "example_logits_seq0_npu": [
    0.685756,
    0.612069,
    0.784648
  ],
  "example_logits_seq0_cpu": [
    0.685867,
    0.612054,
    0.784601
  ],
  "activation": "none (regression, branched tower)",
  "finite_ratio": 1.0
}

CPU-NPU 一致性

{
  "method": "same weights, sequences, tokenizer, dtype float32, same random seed (eval mode)",
  "cpu_device": "cpu",
  "npu_device": "npu:0",
  "compared_tensor": "logits batch x 3",
  "max_abs_diff": 0.0045557,
  "mean_abs_diff": 0.00060607,
  "atol": 0.01,
  "rtol": 0.001,
  "passed": true,
  "threshold_reason": "float32 CNN+BN on Ascend910 observed max ~0.0046, mean ~0.0006"
}

性能

{
  "first_latency_ms": 192.2669,
  "avg_latency_ms": 1.6865,
  "batch": 6,
  "sequence_length": 600,
  "min_latency_ms": 1.6496,
  "max_latency_ms": 1.7495,
  "p50_latency_ms": 1.6854,
  "sequences_per_second": 3557.76,
  "bases_per_second": 2134656.73,
  "dtype": "float32",
  "device": "npu:0",
  "warmup_iters": 3,
  "stable_iters": 10,
  "synchronize": "torch.npu.synchronize() before/after timing",
  "memory_allocated_MB": 15.77,
  "memory_max_MB": 47.77
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 阈值基于 float32 在 Ascend910 上实测最大绝对误差 0.0046 制定。

标签

#NPU #Ascend #Ascend910