#NPU
Framepool is a frame-aware pooling convolutional network for predicting mean ribosome load (MRL) from variable-length 5'UTR sequences, implemented for Huawei Ascend NPU (910B, npu:0). This repository is an NPU-adapted deployment of multimolecule/framepool (0.28M params, 1D residual CNN, 768-dim pooled representation) with standalone PyTorch inference that validates CPU-NPU consistency.
combined_residual, Karollus et al. 2021, PLOS Comp Biol)model.safetensors (1.1 MiB) + config.json (SHA via HF snapshot; local dir model_cache/multimolecule-framepool)log2(MRL_alt / MRL_ref) via paired reference/alternativehttps://huggingface.co/multimolecule/framepoolnpu:0, torch_npu, torch.npu.is_available()A, C, G, U ( T auto-converted to U), N / unknown → all-zero column, excluded from poolingA=0, C=1, G=2, U=3, N=4), null_channel_id=4 zeroed[batch, length] with attention_mask (1 = real, 0 = pad)N (id 4) + attention_mask=0; derived pad_mask = sum(one_hot, -1) excludes pads from conv and pooling (masked)egfp_unmod_1=0, random=1), default random (index 1) matching Kipoi variant-effect interfacelogits shape [batch, 1] float32 (MRL); with alternative → logits, alternative_logits, delta = log2(alt/ref) shape [batch,1]dtype: float32); pre-processing on CPU, core forward on NPUmicroRNA 21 UAGCUUAUCAGACUGAUGUUGA, 22 nt) plus 50 nt synthetic ACGU repeat and 332 nt 7SK-like long sequence — all real, traceable; SHA not applicable (synthetic/RNA strings), no CSV submission (sequence regression)npu-smi info shows 2 devices, 64 GB HBM), CANN 8.5.1torch 2.9.0+cpu, torch_npu built for CANN 8.5.1, transformers 4.57.6, safetensors 0.7.0, numpy 1.26.4, huggingface_hubpython scripts/collect_env.py --output working/env.json (see workflow log)HF_ENDPOINT=https://hf-mirror.com for all HF downloadsInstall:
pip install -r requirements.txtDefault python inference.py loads weights from model_cache/multimolecule-framepool (or downloads from hf-mirror if missing), moves model + tensors to npu:0, and runs synchronized timing.
python inference.py
# optional: python inference.py --device npu:0 --batch-size 3Key logs (truncated):
Model: multimolecule/framepool, Selected device: npu:0, Model first param device: npu:0Input_ids shape: torch.Size([3, 332]) device=npu:0First run (compile) latency: ~220 ms, Stable avg ~2.3 msMRL predictions (see below) and Status: PASSInputs (RG):
example_50nt (50 nt): ACGUACGUACGU...microRNA_21 (22 nt): UAGCUUAUCAGACUGAUGUUGAlong_7SK_like (332 nt): GGAUGUGAGGGCGAUCUGG...Outputs (logits, CPU vs NPU, batch 50/22/277):
[5.625991, 4.632115, 6.905369][5.626033, 4.631859, 6.905476]max_abs_error = 0.000256, mean_abs_error = 0.000135 at atol=1e-3 rtol=1e-3 → PASS (regression, same shape [3,1], finite)ref ACGU... (50 nt) vs alt ACGU...A → delta = 0.095257 (log2 alt/ref)Default python inference.py (batch 50/22/332, NPU npu:0):
example_50nt (50 nt) → MRL 5.568919microRNA_21 (22 nt) → 5.603491long_7SK_like (332 nt) → 3.631469Peak HBM ~3110 MB (idle) → < 4 GB with model (0.28M params ~2.2 MB + activations).
python scripts/compare_outputs.py --cpu /tmp/cpu_logits.npy --npu /tmp/npu_logits.npy --task regression --atol 1e-3 --rtol 1e-3
passed: true, max_abs_error 0.000256, mean_abs_error 0.000135npu:0; no CPU fallbacktorch.npu.synchronize() before/after):
10 runs → avg 2.35 ms, min 2.09 ms, max 3.21 ms, p50 ~2.3 msGenerated from real logs via node scripts/render_xterm_evidence.mjs --style raw; prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$ (display label only).
assets/agent_workflow.png — discovery, download, CPU baseline, NPU inference, consistency, benchmark, validationassets/npu_device_call.png — npu-smi info, torch.npu.is_available()==True, device count 2, Ascend910, param device npu:0, input/output tensor device npu:0assets/model_result.png — python inference.py full stdout (schema, predictions, sync timing, finite check, Status PASS)All three PNGs verified PNG header, width>0 height>0.

npu:0 validated; training/fine-tuning (fit()) remains CPU (not claimed as NPU training)pyarrow/datasets not required for inference (standalone model, no CSV Parquet path); tabular contract adapted to sequence regression (RNA as single feature column, scalar target). For CSV tasks, wrap sequences into a sequence column and map target=MRL.kernel_meta/ and fusion_result.json excluded per whitelist[batch, 128, length] — tested up to 332 nt; >2k nt may need batch 1 and explicit HBM check