w
gcw_uQ09W7jl/malinois-NPU-20260821
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/malinois on Ascend NPU

模型与任务

  • 模型:multimolecule/malinois
  • Revision:main
  • 适配路线:regulatory-sequence
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu_available": true,
  "device_name": "Ascend910_9362",
  "device_count": 2,
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "multimolecule": "0.2.1",
  "transformers": "5.9.0",
  "hf_endpoint": "https://hf-mirror.com",
  "python": "3.11.14"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "num_sequences": 3,
  "sequence_length_fixed": 600,
  "alphabet": "A/C/G/T/N (N->4 zero-vector, U->T via replace_U_with_T)",
  "strand": "5'->3' retained",
  "species": "Homo sapiens (K562/HepG2/SK-N-SH MPRA)",
  "genome": "MPRA plasmid flanks, input_length=600 padded by deterministic repeat per model contract",
  "padding": "exact 600bp window, each raw fragment centered and repeated to 600; no N padding needed; tokenized without extra special tokens (pad_token_id=4=N)",
  "tokenizer": "DnaTokenizer custom ACGT->0-3, N->4 zero-vector via one_hot clamp, replace_U_with_T=true, model_max_length=600",
  "sequences": [
    {
      "name": "p53_600",
      "length": 600,
      "sha256": "b3c747a8b148e11d5f6cfcb09d91190ef2b86c077697dc01dd31a667c4e6d143",
      "preview": "ACTCCCCTGCCCTCAACAAGATGTTTTGCCAA",
      "desc": "tumor protein p53 fragment repeated to 600bp (MPRA CRE context)"
    },
    {
      "name": "BRCA1_600",
      "length": 600,
      "sha256": "b76f9f4e1255e551d92f6881c920477d92ee67051cd6dc1544746b7f222fa063",
      "preview": "TCATTGGAACAGAAAGAAATGGATTTATCTGC",
      "desc": "BRCA1 DNA repair associated fragment repeated to 600bp"
    },
    {
      "name": "HBB_600",
      "length": 600,
      "sha256": "ac29a70bd7d37f13c8b629928a7938253beb4357506047e44273e2ffcbbc8950",
      "preview": "CATTTGCTTCTGACACAACTGTGTTCACTAGC",
      "desc": "hemoglobin subunit beta fragment repeated to 600bp"
    }
  ],
  "input_ids_shape": [
    3,
    600
  ],
  "attention_mask_shape": [
    3,
    600
  ],
  "add_special_tokens": false
}

真实推理结果

{
  "output_shape": [
    3,
    3
  ],
  "dtype": "float32",
  "task": "regulatory-sequence CRE activity regression K562/HepG2/SK-N-SH",
  "output_names": [
    "K562",
    "HepG2",
    "SK-N-SH"
  ],
  "logits_range": [
    -0.405,
    1.082
  ],
  "samples": [
    {
      "name": "p53_600",
      "logits": [
        0.610428,
        0.952002,
        1.08246
      ],
      "cpu_logits": [
        0.611062,
        0.951942,
        1.082101
      ]
    },
    {
      "name": "BRCA1_600",
      "logits": [
        -0.19969,
        -0.192729,
        -0.010027
      ],
      "cpu_logits": [
        -0.199748,
        -0.192784,
        -0.010187
      ]
    },
    {
      "name": "HBB_600",
      "logits": [
        -0.198549,
        0.070588,
        -0.405136
      ],
      "cpu_logits": [
        -0.198426,
        0.070793,
        -0.405111
      ]
    }
  ],
  "device_proof": "first_param:npu:0, input_ids:npu:0, logits:npu:0",
  "finite_ok": true
}

CPU-NPU 一致性

{
  "atol": 0.01,
  "rtol": 0.001,
  "max_abs_diff": 0.000634,
  "mean_abs_diff": 0.000187,
  "pearson": 1.0,
  "passed": true,
  "shape": [
    3,
    3
  ],
  "elements": 9,
  "note": "3 sequences batch compared; allclose passed with atol=0.01 (FP32 conv+batchnorm tolerance)"
}

性能

{
  "first_run_ms": 3.09,
  "avg_ms": 3.09,
  "min_ms": 3.05,
  "max_ms": 3.13,
  "single_latency_ms": 3.92,
  "throughput_seq_per_s": 970.66,
  "throughput_bases_per_s": 582395.6,
  "throughput_single_seq_per_s": 255.0,
  "batch_size": 3,
  "sequence_length": 600,
  "dtype": "float32",
  "warmup": 3,
  "iters": 10,
  "device": "npu:0"
}

自验证截图

Agent workflow

NPU device call

Model result

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

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 固定 600bp 窗口,MPRADRA-style CRE activity 回归 (K562/HepG2/SK-N-SH);跨细胞系/跨物种需额外校验。
  • N 视为 zero vector,与原实现 one_hot clamp 语义一致;U 自动映射为 T。
  • 单次 smoke consistency 验证(3 序列),非完整精度评测。

标签

#NPU #Ascend #Ascend910