Ascend NPU adapted version of Addaoud/DeepPlant-EAP — plant genomic Expression-Associated Polymorphism predictor (EAP). Original model: https://huggingface.co/Addaoud/DeepPlant-EAP
| Attribute | Value |
|---|---|
| Model | Addaoud/DeepPlant-EAP |
| Task | EAP (plant regulatory genomics, 2-feature regression) |
| Architecture | CNN backbone (Conv1d 4→512 + 2 residual blocks 512→2048) + Transformer encoder (6 layers, 8 heads, 2048 dim) + Attention pooling + FC (2048→4096→4096→2) |
| Config | embed_dim=2048, n_filters=512, encoder_num_layers=6, num_heads=8, max_seq_length=100, expand_factor=2, dropout=0.2, n_features=2 |
| Weights | model.safetensors 947 MB, 143 tensors, strict load PASS (0 missing, 0 unexpected) |
| Original Code | PyTorchModelHubMixin (no extra code in HF repo) — reproduced in model.py |
| Property | Value |
|---|---|
| NPU | Ascend910_9362 (Ascend910_9391 SOC, CANN 8.5.1, npu-smi 25.5.5) |
| NPU Devices | 14,15 (logical 0,1) • tested on npu:0 |
| CPU | x86_64 / aarch64 |
| Python | 3.11.14 |
| PyTorch | 2.9.0+cpu |
| torch_npu | 2.9.0.post1+gitee7ba04 |
| safetensors | 0.6.x |
| HW | HBM 3107/65536 MB idle |
backbone.conv_features.0.conv (512,4,11) + backbone.conv_features.1 BNbackbone.conv_network.0 (512→512→512→2048, proj 512→2048 k9) and backbone.conv_network.2 (2048→1024→1024→2048, proj 2048→2048 k5) with layers layer.0/1/3/4/6/7 + project.0/1transformer.encoder.encoder_layers.{0..5}.self_attn.in_proj_weight/bias, out_proj.weight/bias, linear1/2, norm1/2 + transformer.pos_encoder.pe (1,100,2048)attention_pool.to_attn_logits as Parameter (2048,2048) — matches safetensors key without .weight suffix (fixed vs nn.Linear)fc.linear.0 (4096,2048), fc.linear.3 (4096,4096), fc.prediction_head.0 (2,4096)strict=True → 0 missing, 0 unexpectedtorch.npu.is_available(), torch.npu.get_device_name(0), model.to("npu:0"), input.to("npu:0"), torch.npu.synchronize() around timingmax_seq_length=100 before Transformer (supports any input length 100–2000, e.g. 512, 600, 1000)to_attn_logits matrix (x @ W → softmax → weighted sum)pip install -r requirements.txt
# NPU
python inference.py --device npu:0
# CPU
python inference.py --device cpuProgrammatic:
import torch
from model import DeepPlantEAP
import json
config = json.load(open("/path/to/config.json"))
model = DeepPlantEAP(config)
model.load_pretrained("/path/to/model.safetensors", device="cpu")
device = torch.device("npu:0" if torch.npu.is_available() else "cpu")
model = model.to(device).eval()
# One-hot DNA: (B,4,L), L e.g. 600
# A=0,C=1,G=2,T=3
import numpy as np
def random_one_hot(batch=2, L=600):
bases = np.random.randint(0,4,size=(batch,L))
arr = np.zeros((batch,4,L), dtype=np.float32)
for b in range(batch):
for l in range(L):
arr[b, bases[b,l], l] = 1.0
return torch.from_numpy(arr).to(device)
with torch.no_grad():
out = model(random_one_hot(2,600)) # (2,2)
print(out)| Field | Shape | Dtype | Device |
|---|---|---|---|
Input x | (B,4,L) one-hot DNA, B>=1, L arbitrary (tested 512,600,1000) | float32 | npu:0 / cpu |
| Output | (B,2) EAP predictions (2-dim regression) | float32 | same device |
Example (batch 2, L 600):
CPU: [[-0.1315, 0.1368], [-0.1314, 0.1368]]
NPU: [[-0.1315, 0.1368], [-0.1314, 0.1368]]
mae 2.3e-07 cosine 0.9999998[DEVICE_PROOF] model param device: npu:0
[DEVICE_PROOF] target device: npu:0
[INFO] npu name 0: Ascend910_9362
[INFO] npu.is_available True device_count 2
torch.npu.is_available() True| Metric | Value |
|---|---|
| MAE | 2.31e-07 |
| Max diff | 4.47e-07 |
| Cosine | 0.99999982 |
| Threshold | mae < 1e-5, cosine > 0.999 → PASS |
| Strict load | 143/143 tensors, 0 missing, 0 unexpected |
| Device | Batch | Length | Avg latency | Min | Max |
|---|---|---|---|---|---|
| CPU | 2 | 600 | 4045 ms | 3927 | 4234 |
| NPU (npu:0) | 2 | 600 | 7.71 ms | 7.66 | 7.74 |
| Speedup | — | — | 525× | — | — |
NPU synchronized timing via torch.npu.synchronize() before/after.

.
├── model.py # NPU-adapted architecture (exact key mapping)
├── inference.py # load + NPU/CPU verify + benchmark + asset generation
├── requirements.txt
├── config.json # HF config (copied for reference)
├── npu_output.json # NPU verification result
├── cpu_output.json # CPU baseline
└── assets/
├── npu_device_call.png
├── perf_comparison.png
└── output_distribution.pngn_features=2 (EAP). GEP variant (different n_features) needs config change.A/C/G/T) shown in one_hot_encode() utility.max_seq_length=100 via adaptive pooling — longer inputs truncated via pooling, not sliding window.Original model: Addaoud/DeepPlant-EAP — https://huggingface.co/Addaoud/DeepPlant-EAP