m
mengsihan/optimus5prime
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/optimus5prime on Ascend NPU

模型与任务

  • 模型:multimolecule/optimus5prime
  • Revision:d16f284c759d0530b0b3391e2fe34ec9c136405f
  • 适配路线:utr-translation
  • 设备:npu:0

环境依赖

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

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sequences": [
    {
      "label": "ref_example",
      "sequence": "GGGACAUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGC",
      "length": 50,
      "sha256": "217b42655c86b30cd6b0835e3af600cca7664f3c77268b372779e7c5692e0e0f",
      "alphabet": "A/C/G/U"
    },
    {
      "label": "alt_variant",
      "sequence": "GGGACAUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGCUAGAUAGC",
      "length": 50,
      "sha256": "d0fe94bdccc4f3e9ee3997aa3ae20acc31282c6d3bd3a3f35507035906924d7c",
      "alphabet": "A/C/G/U"
    },
    {
      "label": "nras_5utr_trunc",
      "sequence": "GGGGCCGGAAGUGCCGCUCCUUGGUGGGGGCUGUUCAUGGCGGUUCCGGG",
      "length": 50,
      "sha256": "992eeba3372e7a30288e2a4be013eb8fd1968c204cdcf9ea780281c63573b0d5",
      "alphabet": "A/C/G/U"
    }
  ],
  "tokenizer": "RnaTokenizer",
  "padding": "N pad to 50, T->U, truncate first 50",
  "model_dir": "/tmp/optimus5prime_weights2",
  "batch_size": 3,
  "sequence_length": 50,
  "source": "README 5'UTR examples + synthetic 50nt, SHA256 recorded"
}

真实推理结果

{
  "logits_shape": [
    3,
    1
  ],
  "output_name": "logits",
  "problem_type": "regression",
  "npu_mrl": [
    1.2541437149047852,
    1.2631301879882812,
    -1.3085277080535889
  ],
  "cpu_mrl": [
    1.2541533708572388,
    1.2631158828735352,
    -1.3085063695907593
  ],
  "delta_alt_minus_ref_cpu": 0.008962512016296387,
  "delta_alt_minus_ref_npu": 0.008986473083496094,
  "npu_device": "npu:0",
  "dtype": "float32"
}

CPU-NPU 一致性

{
  "method": "np.allclose",
  "atol": 0.0001,
  "rtol": 0.0001,
  "shape": [
    3,
    1
  ],
  "elements": 3,
  "max_abs_diff": 2.1338463e-05,
  "mean_abs_diff": 1.5099843e-05,
  "passed": true,
  "delta_diff": 2.396106719970703e-05
}

性能

{
  "device": "npu:0",
  "dtype": "float32",
  "batch_size": 1,
  "sequence_length": 50,
  "warmup_iters": 3,
  "stable_iters": 10,
  "first_latency_ms": 0.795,
  "stable_avg_latency_ms": 0.878,
  "seq_per_sec": 1138.73,
  "bases_per_sec": 56936.5,
  "synchronize": "torch.npu.synchronize() before and after timing",
  "peak_hbm_mb": 3110
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910