| 组件 | 版本 |
|---|---|
| NPU | Ascend 910(910B,Ascend910_9362) |
| CANN | 8.5.1 |
| torch | 2.9.0 |
| torch-npu | 2.9.0.post1 |
| transformers | 5.9.0 |
| multimolecule | 0.2.1 |
| numpy | 1.26.4 |
| fastapi / uvicorn | 0.123.10 / 0.46.0 |
| Python | 3.11.14 |
HAL 是一个线性(加性)查表评分模型,由 Rosenberg 等(Learning the Sequence Determinants of Alternative Splicing from Millions of Random Sequences, Cell 2015)从大规模平行报告实验(MPRA)中学得:
ACGU(T 自动转 U);N 的 hexamer 被忽略);(4096, 8) 的 hexamer 效应矩阵,8 列平均后得到每个 hexamer 的单个效应;nn.Linear(4096, 1, bias=False)),输出单个标量分数;delta = score_variant - score_reference,再对 delta 施加 sigmoid 得到"突变提高供体使用度"的概率。注:HAL 是判别式评分模型而非自回归生成模型,vLLM-Ascend(自回归文本生成引擎)无法加载。本仓库通过
multimolecule+torch_npu直接在 Ascend NPU 上运行,并用 FastAPI 提供 OpenAI 兼容的服务化推理。
scatter_add 频数统计 / Linear / Sigmoid),无 CUDA-only 依赖,torch_npu 直接映射到 NPU AICore,代码零改动;N(含 N 的 hexamer 被忽略,不贡献特征);长序列以步长 1 做 160 nt 滑窗扫描并返回最高分窗口,用于扫描序列中的潜在强供体位点;hal-npu/
├── inference.py # 推理脚本(CLI / 基准 / FastAPI 服务化)
├── README.md # 本说明文档
├── requirements.txt # 环境依赖清单
└── assets/ # 截图素材
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png# 建议配置华为镜像源加速
export PIP_INDEX_URL=https://repo.huaweicloud.com/repository/pypi/simple/
pip install -r requirements.txt权重目录(config.json / model.safetensors / tokenizer_config.json / vocab.txt)放置于 /opt/atomgit/models/hal,也可通过 --model-path 指定其它位置。来源:https://huggingface.co/multimolecule/hal(镜像 https://gitcode.com/hf_mirrors/multimolecule/hal)。
python3 inference.py --model-path /opt/atomgit/models/hal \
--device npu:0 --seq "UUAAUGCUAAUCGUGAUAGGGGUU"python3 inference.py --model-path /opt/atomgit/models/hal \
--device npu:0 --ref "ACGUACGU..." --variant "ACGAACGU..."输出参考分数、突变分数、delta 与 P(变体提高供体使用度)=sigmoid(delta)。
python3 inference.py --benchmark --model-path /opt/atomgit/models/hal \
--device npu:0 --n-runs 20python3 inference.py --serve --model-path /opt/atomgit/models/hal \
--port 8000 --device npu:0# 模型列表
curl http://127.0.0.1:8000/v1/models
# 剪接打分
curl http://127.0.0.1:8000/v1/predict -H 'Content-Type: application/json' \
-d '{"sequence": "UUAAUGCUAAUCGUGAUAGGGGUU"}'
# 变体效应
curl http://127.0.0.1:8000/v1/variant-effect -H 'Content-Type: application/json' \
-d '{"reference": "ACGUACGU...", "variant": "ACGAACGU..."}'
# OpenAI 兼容 chat 接口
curl http://127.0.0.1:8000/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model": "hal", "messages": [{"role": "user", "content": "UUAAUGCUAAUCGUGAUAGGGGUU"}]}'| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /v1/models | 模型列表(含 hardware=NPU) |
| POST | /v1/predict | 单/批量序列剪接打分 |
| POST | /v1/variant-effect | 参考 vs 突变变体效应评估 |
| POST | /v1/chat/completions | OpenAI 兼容包装 |
| GET | /v1/health / /health | 健康检查 |
| 指标 | 结果 |
|---|---|
| 参数量 | 4,096 |
| 输入长度 | 160 nt(定长) |
| 输出形状 | [1, 1] |
| 平均延迟(20 次,含 tokenizer) | ~30.9 ms |
| 峰值 HBM | ~0.48 GB |
| NPU vs CPU 余弦相似度 | 1.0 |
| 示例打分("ACGU"×40) | +0.1837 |