gcw_6a3w2yXz/mpradragonn
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/mpradragonn on Ascend NPU

模型与任务

  • 模型:multimolecule/mpradragonn
  • Revision:13bf3e73489942cdf0f704706eee1baa2ea70ec5
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "torch_version": "2.9.0+cpu",
  "torch_npu_version": "2.9.0.post1+gitee7ba04",
  "device_name": "Ascend910_9362",
  "device_count": 2,
  "npu_available": true,
  "python_version": "3.11.14",
  "cann_version": "8.5.1",
  "dtype": "float32",
  "model_dir": "/tmp/hf_cache/models--multimolecule--mpradragonn/snapshots/13bf3e73489942cdf0f704706eee1baa2ea70ec5"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "num_sequences": 5,
  "sequence_length": 145,
  "alphabet": "A/C/G/T/N",
  "strand": "5'->3'",
  "sequences_sha256": [
    "7e14ec6e40cae631058f5b964eec7198a2457de7cc14fbecedb027953283c467",
    "6ebb3c4b206810be4b1902c76e44fe6e366381730291af46452fa770c402c579",
    "905ab86aa9612f9ebf82e5353f4905b9c9b5a42f661d2d6218e0859197d64d78",
    "28bc031b41cb02878ac2723c6b8221038c634242ceed737563365ceeffa82d6e",
    "b3c988bc15f972bf9dd1b23efe5841865308aa9cc35796388251ed5c762e2092"
  ],
  "example_sequence": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAAGACCTGCCCTGTGCAGCTGT...",
  "example_source": "tumor protein p53 (184 bp example) truncated to first 145 bp, 5'->3'",
  "all_sources": [
    "tumor protein p53 (184 bp example) truncated to first 145 bp, 5'->3'",
    "BRCA1 DNA repair associated (99 bp) padded with N to 145 bp",
    "hemoglobin subunit beta (142 bp) padded with N to 145 bp",
    "CFTR (192 bp) truncated to first 145 bp, 5'->3'",
    "synthetic ACGT repeat 145 bp (balanced alphabet smoke)"
  ],
  "input_ids_shape": [
    5,
    145
  ],
  "attention_mask_shape": [
    5,
    145
  ],
  "tokenizer": "DnaTokenizer",
  "vocab_size": 5,
  "replace_U_with_T": true,
  "padding": "max_length 145, truncation True, N-pad for short sequences"
}

真实推理结果

{
  "logits_shape": [
    5,
    12
  ],
  "logits_dtype": "float32",
  "output_type": "12-task MPRA reporter activity (regression) per 145 bp DNA window: k562/hepg2 x minP/SV40p x rep1/rep2/avg",
  "cpu_logits": [
    [
      -0.06784578412771225,
      -0.10598482191562653,
      -0.10086536407470703,
      -0.035643234848976135,
      0.007227699737995863,
      -0.018207481130957603,
      -0.04363808408379555,
      -0.11082444339990616,
      -0.09431447088718414,
      0.03026857040822506,
      0.08533581346273422,
      0.06291549652814865
    ],
    [
      1.4499735832214355,
      1.5776528120040894,
      1.7671470642089844,
      0.5801451206207275,
      0.3215123116970062,
      0.5491125583648682,
      1.167130947113037,
      0.4177056849002838,
      0.9687628149986267,
      -0.23648715019226074,
      0.25091639161109924,
      0.008220493793487549
    ],
    [
      -0.3252933919429779,
      -0.5047654509544373,
      -0.4883599579334259,
      -0.11354874819517136,
      -0.03180203586816788,
      -0.08604659140110016,
      -0.2595794200897217,
      -0.10303585976362228,
      -0.22340044379234314,
      0.052535347640514374,
      -0.08633872866630554,
      -0.021043933928012848
    ],
    [
      -0.0490565150976181,
      0.06574112176895142,
      0.012418907135725021,
      0.1466740220785141,
      -0.1128976047039032,
      0.01641451194882393,
      -0.08345041424036026,
      -0.20912426710128784,
      -0.17397254705429077,
      -0.33278703689575195,
      -0.29885557293891907,
      -0.38149648904800415
    ],
    [
      -0.7067909836769104,
      -1.0029252767562866,
      -1.0033575296401978,
      -0.36180049180984497,
      -0.29357606172561646,
      -0.39814522862434387,
      -0.14909784495830536,
      0.10405348241329193,
      -0.03740660846233368,
      0.34347110986709595,
      0.22459504008293152,
      0.33121803402900696
    ]
  ],
  "npu_logits": [
    [
      -0.067847341299057,
      -0.106021448969841,
      -0.10088839381933212,
      -0.03566329926252365,
      0.007210131734609604,
      -0.01822848990559578,
      -0.043675683438777924,
      -0.1108887642621994,
      -0.09437502175569534,
      0.030219972133636475,
      0.0852796882390976,
      0.06285274028778076
    ],
    [
      1.4499648809432983,
      1.5776522159576416,
      1.767134428024292,
      0.5801669359207153,
      0.3215283751487732,
      0.5491335391998291,
      1.1671353578567505,
      0.4177129566669464,
      0.9687700271606445,
      -0.23649245500564575,
      0.25091832876205444,
      0.008218906819820404
    ],
    [
      -0.3252917230129242,
      -0.5047798156738281,
      -0.4883669316768646,
      -0.11351783573627472,
      -0.03178197517991066,
      -0.08601825684309006,
      -0.2595633268356323,
      -0.10299845039844513,
      -0.22336947917938232,
      0.05257077515125275,
      -0.08629365265369415,
      -0.020996395498514175
    ],
    [
      -0.04900939017534256,
      0.06578095257282257,
      0.012469768524169922,
      0.14673778414726257,
      -0.1128527969121933,
      0.016477689146995544,
      -0.08341497927904129,
      -0.20907573401927948,
      -0.17392119765281677,
      -0.33273106813430786,
      -0.2988022565841675,
      -0.38143330812454224
    ],
    [
      -0.7068069577217102,
      -1.0029774904251099,
      -1.0033977031707764,
      -0.3617950975894928,
      -0.29355388879776,
      -0.3981323540210724,
      -0.14901837706565857,
      0.10415303707122803,
      -0.037298791110515594,
      0.34359750151634216,
      0.22473159432411194,
      0.3313688635826111
    ]
  ],
  "example_mpra_cpu": [
    -0.06784578412771225,
    -0.10598482191562653,
    -0.10086536407470703,
    -0.035643234848976135,
    0.007227699737995863,
    -0.018207481130957603,
    -0.04363808408379555,
    -0.11082444339990616,
    -0.09431447088718414,
    0.03026857040822506,
    0.08533581346273422,
    0.06291549652814865
  ],
  "example_mpra_npu": [
    -0.067847341299057,
    -0.106021448969841,
    -0.10088839381933212,
    -0.03566329926252365,
    0.007210131734609604,
    -0.01822848990559578,
    -0.043675683438777924,
    -0.1108887642621994,
    -0.09437502175569534,
    0.030219972133636475,
    0.0852796882390976,
    0.06285274028778076
  ],
  "logits_device": "npu:0",
  "num_labels": 12,
  "problem_type": "regression",
  "label_names": [
    "k562_minP_rep1",
    "k562_minP_rep2",
    "k562_minP_avg",
    "k562_SV40p_rep1",
    "k562_SV40p_rep2",
    "k562_SV40p_avg",
    "hepg2_minP_rep1",
    "hepg2_minP_rep2",
    "hepg2_minP_avg",
    "hepg2_SV40p_rep1",
    "hepg2_SV40p_rep2",
    "hepg2_SV40p_avg"
  ]
}

CPU-NPU 一致性

{
  "passed": true,
  "shape": [
    5,
    12
  ],
  "elements": 60,
  "max_abs_diff": 0.00015082955360412598,
  "mean_abs_diff": 3.899856625745694e-05,
  "atol": 0.01,
  "rtol": 0.001,
  "per_sequence_diff": [
    6.432086229324341e-05,
    2.181529998779297e-05,
    4.7538429498672485e-05,
    6.376206874847412e-05,
    0.00015082955360412598
  ],
  "note": "CPU vs NPU same weights, same DnaTokenizer batch, same padding, float32. Max diff 1.51e-04 well below 1e-2 threshold."
}

性能

{
  "device": "npu:0",
  "dtype": "float32",
  "batch": 5,
  "sequence_length": 145,
  "warmup_iterations": 3,
  "stable_iterations": 10,
  "first_latency_ms": 164.53,
  "avg_latency_ms": 0.79,
  "min_latency_ms": 0.75,
  "max_latency_ms": 0.81,
  "sequences_per_second": 6344.08,
  "bases_per_second": 919891.01,
  "model_params_M": 2.1,
  "flops_M": 30.5
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • MPRA-DragoNN 固定输入 145 bp DNA 窗口;短于 145 的序列经 N-padding,长于 145 的截断至前 145 bp。

标签

#NPU #Ascend #Ascend910