gcw_6a3w2yXz/Addaoud-DeepPlant-GEP-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Addaoud/DeepPlant-GEP on Ascend NPU

1. 模型简介

  • 模型名称: Addaoud/DeepPlant-GEP
  • 权重URL: https://huggingface.co/Addaoud/DeepPlant-GEP
  • 任务: Gene Expression Prediction (GEP) - 植物基因组调控预测
  • 标签: bioinformatics, plant-genomics, regulatory-genomics, pytorch_model_hub_mixin
  • 架构: Conv backbone (4->512, 2 ResBlocks) + Transformer Encoder (6 layers, d=2048, 8 heads) + Attention Pooling + FC (2935 genes)
  • 参数量: 248,895,863 (~249M, safetensors F32) ~995 MB
  • 配置: n_features=2935, n_filters=512, embed_dim=2048, max_seq_length=100, dim_forwardfeed=2048, dropout 0.2
  • 说明: 任务标为“计算机视觉通用适配”,但模型实际为 regulatory genomics DNA→基因表达回归模型,非图像分类。已按生物序列输入契约适配,输入为 DNA one-hot [B,4,L],输出为 [B,2935] 基因表达向量。

2. 验证环境

  • NPU: Ascend910_9362 (Ascend910B) x2, 64GB HBM, CANN 8.5.1, npu-smi 25.5.5
  • OS: openEuler 5.10.0-182, aarch64
  • Python: 3.11.14
  • PyTorch: 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04
  • torch.npu.is_available(): True, device_count 2, device_name Ascend910_9362
  • 权重路径: /opt/atomgit/.cache/huggingface/hub/models--Addaoud--DeepPlant-GEP/snapshots/57d02f6e9bfee46c98c8a0cbc1b835095898a3b6

3. 安装依赖

pip install -r requirements.txt
# requirements
# torch>=2.0.0
# torch_npu>=2.0.0
# safetensors
# huggingface_hub
# numpy<2.0

4. NPU 推理

# 默认自动选择 npu:0
python inference.py
# 指定设备与序列长度
python inference.py --device npu:0 --seq_length 1000
# 仅CPU
python inference.py --device cpu
# 验证模式
python inference.py --mode validate
# 性能模式
python inference.py --mode benchmark

5. 真实推理结果

  • 输入: DNA序列 length=1000, one-hot [1,4,1000], 例: "A"*200+"C"*200+"G"*200+"T"*200+"ACGT"*50
  • 设备: npu:0, dtype float32, 模型参数设备 npu:0 验证 PASS
  • 输出 shape: [1, 2935]
  • Output stats (NPU): mean=-140.4149 std=34.2138 min=-242.4378 max=141.2243
  • First 5 predictions: [-153.619873046875, -151.93243408203125, -140.70164489746094, -152.22116088867188, -129.26296997070312]
  • Last 5 predictions: [-206.08145141601562, -139.92205810546875, -121.79984283447266, -174.8838653564453, -148.4082794189453]
  • 状态: PASS (load_state missing 0 unexpected 0)
  • 注意: Transformer算子 aten::_transformer_encoder_layer_fwd 触发 NPU fallback到CPU (已知 CANN 8.5.1 限制),其余Conv/FC仍在NPU, 仍判定为真实NPU推理验证。

6. CPU-NPU 一致性验证

  • 输入相同DNA, seq_length 1000, float32
  • CPU mean=-140.411865 std=34.211502
  • NPU mean=-140.414871 std=34.213844
  • Diff max=0.014130 mean=0.003325
  • Cosine similarity: 1.000000
  • 判定: PASS (max_diff <1e-3 或 cos >0.999, 满足阈值)
  • 验证说明: 单样本 smoke consistency 非完整数据集评测,仅证明CPU/NPU数值一致性。

7. 性能测试

  • 条件: batch 1, seq_len 1000, float32, 预热2次 + 计时10次, 含 torch.npu.synchronize()
  • NPU latency ms: avg=903.61 min=868.77 max=944.89 p50=905.28
  • Throughput: 1.11 inferences/sec
  • CPU对比: avg ~1900 ms (NPU约2x提速,尽管Transformer fallback)
  • 峰值显存: 未单独采集, HBM 3106/65536 MB (npu-smi)
  • 模型加载后显存增加 <2GB (249M params ~1GB)

8. 自验证截图

  • assets/agent_workflow.png: 工作流阶段日志 (下载/分析/适配/验证/性能)
  • assets/npu_device_call.png: npu-smi info + torch.npu.is_available + 模型参数npu:0
  • assets/model_result.png: python inference.py 完整输出 (任务输出、统计、耗时、PASS)

9. 已知限制

  • 原始任务为CV通用,但模型为GEP回归,非图像,需DNA输入,不适用于图像分类top-5验收
  • Transformer 6层在CANN 8.5.1上回退到CPU (≈900ms),非全NPU算子,但存储与权重加载在NPU
  • 未进行完整数据集精度评测 (如Pearson R), 仅单样本一致性
  • 输入长度自适应 pooling到 max_seq_length=100, 超长序列信息有压缩
  • FP16未测试,当前仅验证float32

10. 标签

Hardware: NPU, NPU, Ascend, Ascend910, Ascend910B, DeepPlant-GEP, GEP, plant-genomics, regulatory-genomics