jsjs1258/deepcpgdna-smallwood2014-2i-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/deepcpgdna-smallwood2014-2i on Ascend NPU

模型与任务

  • 模型:multimolecule/deepcpgdna-smallwood2014-2i
  • Revision:646ae5817a52f8da18622583a02e48d047dda217
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "python": "3.11.14",
  "torch": "2.9.0+cpu",
  "torch_npu": "installed, Ascend910_9362",
  "transformers": "5.9.0",
  "multimolecule": "0.2.1",
  "huggingface_hub": "1.28.0",
  "tokenizers": "0.22.2",
  "safetensors": "0.8.0",
  "numpy": "2.4.6",
  "device": "npu:0",
  "device_name": "Ascend910_9362",
  "hf_endpoint": "https://hf-mirror.com",
  "hf_hub_disable_xet": "1"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "route": "regulatory-sequence",
  "task_type": "regulatory-sequence methylation prediction",
  "sequence_length": 1001,
  "num_labels": 12,
  "alphabet": "A/C/G/T/N",
  "tokenizer": "DnaTokenizer",
  "model": "DeepCpgDnaForSequencePrediction",
  "primary_sequence": {
    "label": "synthetic_1001",
    "length": 1001,
    "sha256": "f8eb0ec2263e2a459afe3969c0588c3570c56e27701298aa1189bb0ebbbd2734",
    "prefix": "AAGCCCAATAAACCACTCTGACTGGCCGAATAGGGATATAGGCAACGACATGTGCGGCGA",
    "source": "deterministic synthetic (seed 42, 1001 bp)",
    "strand": "5'->3'",
    "padding": "none (full length)"
  },
  "secondary_sequences": [
    {
      "label": "p53_fragment_padded",
      "original_length": 184,
      "sha256": "7a04b9f182884881e3dc7870767e85cf13f1ef93901512f927ca48ef8271903d",
      "padded_to": 1001,
      "pad_token": "N",
      "source": "model card tumor protein p53"
    },
    {
      "label": "brca1_fragment_padded",
      "original_length": 99,
      "sha256": "f60583147541647f44153ef3ff53c06dc45585703484619fffdc9a6c4e2bf5fb",
      "padded_to": 1001,
      "pad_token": "N",
      "source": "model card BRCA1"
    }
  ],
  "dtype": "float32",
  "device_preprocessing": "CPU tokenizer, then moved to npu:0"
}

真实推理结果

{
  "primary_output": {
    "sequence": "synthetic_1001",
    "logits_shape": [
      1,
      12
    ],
    "logits_dtype": "float32",
    "logits_npu": [
      -0.9755814671516418,
      -0.9104466438293457,
      -1.0188024044036865,
      -0.81661456823349,
      -0.9148839116096497,
      -0.20740002393722534,
      -0.5697927474975586,
      -0.8304398059844971,
      -0.7612520456314087,
      -0.55109703540802,
      -0.5483856797218323,
      -0.8946041464805603
    ],
    "logits_cpu": [
      -0.975226879119873,
      -0.9100978374481201,
      -1.0184332132339478,
      -0.8162952065467834,
      -0.914531409740448,
      -0.20715802907943726,
      -0.5694949626922607,
      -0.8301463723182678,
      -0.7609310746192932,
      -0.550806999206543,
      -0.5480936169624329,
      -0.8942392468452454
    ],
    "probs_shape": [
      1,
      12
    ],
    "probs_npu": [
      0.27376940846443176,
      0.28690844774246216,
      0.2652607560157776,
      0.3064827620983124,
      0.2860014736652374,
      0.44833505153656006,
      0.36128467321395874,
      0.3035520911216736,
      0.31837448477745056,
      0.36560991406440735,
      0.3662390112876892,
      0.290160596370697
    ],
    "id2label": {
      "0": "BS24_1_2I",
      "1": "BS24_2_2I",
      "2": "BS24_4_2I",
      "3": "BS24_6_2I",
      "4": "BS24_8_2I",
      "5": "BS25_10_2I",
      "6": "BS25_2_2I",
      "7": "BS25_6_2I",
      "8": "BS25_7_2I",
      "9": "BS25_8_2I",
      "10": "BS26_1_2I",
      "11": "BS26_2_2I"
    },
    "predicted_methylation_states": [
      false,
      false,
      false,
      false,
      false,
      false,
      false,
      false,
      false,
      false,
      false,
      false
    ],
    "device": "npu:0",
    "note": "12 binary heads per cell; sigmoid>0.5 indicates predicted methylated"
  },
  "p53_padded_logits_npu": [
    [
      -0.9755814671516418,
      -0.9104466438293457,
      -1.0188024044036865,
      -0.81661456823349,
      -0.9148839116096497,
      -0.20740002393722534,
      -0.5697927474975586,
      -0.8304398059844971,
      -0.7612520456314087,
      -0.55109703540802,
      -0.5483856797218323,
      -0.8946041464805603
    ]
  ],
  "note_output_axes": "batch=1, num_labels=12 (regulatory-sequence methylation heads)",
  "secondary_outputs": [
    {
      "label": "p53_fragment_padded",
      "logits_shape": [
        1,
        12
      ],
      "logits": [
        -1.5578216314315796,
        -1.501266598701477,
        -1.5273687839508057,
        -1.3917871713638306,
        -1.5535252094268799,
        -1.2918280363082886,
        -0.36853164434432983,
        -1.7564599514007568,
        -1.7258129119873047,
        -1.1115272045135498,
        -1.2708491086959839,
        -1.4118808507919312
      ]
    },
    {
      "label": "brca1_fragment_padded",
      "logits_shape": [
        1,
        12
      ],
      "logits": [
        -1.7974436283111572,
        -1.7544444799423218,
        -1.7612441778182983,
        -1.6479676961898804,
        -1.8268741369247437,
        -1.5252317190170288,
        -0.5884062051773071,
        -2.028883218765259,
        -2.0225706100463867,
        -1.3639124631881714,
        -1.538027048110962,
        -1.6995525360107422
      ]
    }
  ]
}

CPU-NPU 一致性

{
  "cpu_vs_npu_primary": {
    "passed": true,
    "shape": [
      1,
      12
    ],
    "elements": 12,
    "max_abs_diff": 0.00036919116973876953,
    "mean_abs_diff": 0.00032046933968861896,
    "atol": 0.001,
    "rtol": 0.001
  },
  "secondary_p53": {
    "max_abs_diff": 9.810925e-05,
    "mean_abs_diff": 7.920464e-05,
    "atol": 0.001,
    "rtol": 0.001,
    "passed": true
  },
  "secondary_brca1": {
    "max_abs_diff": 8.070469e-05,
    "mean_abs_diff": 5.831321e-05,
    "atol": 0.001,
    "rtol": 0.001,
    "passed": true
  },
  "compare_method": "np.allclose(atol=1e-3, rtol=1e-3) on logits [1,12] regulatory-sequence heads",
  "overall_passed": true,
  "note": "regulatory-sequence: compare logits and sigmoid probs; CPU and NPU use identical weights, tokenizer, sequence, dtype float32"
}

性能

{
  "warmup_iterations": 3,
  "stable_iterations": 10,
  "single_latency_ms": 2.934,
  "avg_latency_ms": 2.125,
  "throughput_seq_per_s": 470.54,
  "throughput_bases_per_s": 471007.42,
  "input_length": 1001,
  "batch_size": 1,
  "dtype": "float32",
  "device": "npu:0",
  "synchronize": "torch.npu.synchronize() before and after timing",
  "note": "first iteration includes NPU compilation; stable avg reported separately"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

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

标签

#NPU #Ascend #Ascend910