凤
weixin_44093752/AlphaGenome
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

gtca/alphagenome_pytorch Ascend NPU 适配

AlphaGenome 是 Google DeepMind DNA 序列基础模型(Nature 2025)的 PyTorch 移植,预测基因组特征(ATAC/DNase/RNA-seq 等,编码器 + transformer tower + 多 head)。本仓完成其在昇腾 Ascend910 NPU 上的真实推理适配与 CPU/NPU 精度对拍。

适配内容

  • 使用官方 PyPI 包(alphagenome_pytorch.AlphaGenome)
  • 权重:model_all_folds.safetensors(878 MB,SHA-256 见 validation/weight.sha256)
  • 严格加载(strict load),固定合成 DNA 序列 seq [1,2048](4 碱基,organism_index=0,return_embeds)
  • CPU 与 NPU 均使用 cls_default_noretrieval.json 配置(noretrieval 模式,避免 CUDA-only retrieval 依赖)

验证结果

指标CPUNPU (Ascend910 npu:0)
平均延迟3002.69 ms633.74 ms
输出 shape[1,2048,1536][1,2048,1536]

精度对拍(CPU vs NPU,fp32):

指标值
cosine similarity0.99999996
max_abs_error8.034e-03
mean_abs_error6.487e-04
precision_passtrue

证据

工作流

agent_workflow

NPU 设备调用

npu_device_call

模型推理结果

model_result

运行

python3 inference.py --device cpu   # CPU 推理
python3 inference.py --device npu   # NPU 推理(需 Ascend910 + torch_npu)

依赖:torch、transformers、numpy、huggingface_hub、kditransform(LimiX 推理所需)。