jsjs1258/sptransformer
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/sptransformer on Ascend NPU

模型与任务

  • 模型:multimolecule/sptransformer
  • Revision:cb8ab1f834781820140842900014f89c359cf7a2
  • 适配路线:splicing
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "npu_name": "Ascend910_9362",
  "npu_count": 2,
  "python": "3.11"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequence": "UAGCUUAUCAGACUGAUGUUGA",
  "length": 22,
  "sequence_sha256": "9c1b1cd23c45d39dd0b1fb28d72c49c0edcc57a16cb61c96119f84676c4b5b1c",
  "tokenizer": "RnaTokenizer",
  "vocab_size": 5,
  "input_ids_shape": [
    1,
    22
  ],
  "attention_mask_sum": 22,
  "alphabet": "A/C/G/U/N",
  "direction": "5'->3'",
  "source": "model card widget: microRNA 21",
  "replace_T_with_U": true
}

真实推理结果

{
  "logits_shape": [
    1,
    22,
    18
  ],
  "splice_head": "0:3 (non-splice/donor/acceptor)",
  "tissue_head": "3:18 (15 tissues)",
  "dtype": "float32",
  "device": "npu:0",
  "logits_mean_npu": -9.11,
  "logits_max_npu": 7.447,
  "example_splice_logits_first_pos": [
    5.899,
    -5.971,
    -3.729
  ],
  "predicted_labels_first_22": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ]
}

CPU-NPU 一致性

{
  "atol": 0.005,
  "rtol": 0.001,
  "max_abs_diff": 0.00596,
  "mean_abs_diff": 0.001326,
  "splice_max_diff": 0.002769,
  "tissue_max_diff": 0.00596,
  "allclose": true,
  "passed": true,
  "comparison": "CPU vs NPU same weights, same input, same tokenizer, float32"
}

性能

{
  "device": "npu:0",
  "first_compile_ms": 272.43,
  "stable_avg_ms": 24.78,
  "warmup_runs": 3,
  "stable_runs": 10,
  "seq_per_sec": 40.35,
  "bases_per_sec": 887.75,
  "input_length": 22,
  "batch_size": 1,
  "dtype": "float32",
  "long_seq_512_latency_ms": 22.77,
  "synchronize": "torch.npu.synchronize() before/after timing"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • Long sequence > context cropping follows model definition (output length = input - 2*context handling via pad/crop).

标签

#NPU #Ascend #Ascend910