w
gcw_uQ09W7jl/multimolecule-framepool-NPU-model
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

multimolecule/framepool-NPU

#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.

  • Base model: multimolecule/framepool (combined_residual, Karollus et al. 2021, PLOS Comp Biol)
  • Revision: pinned to model.safetensors (1.1 MiB) + config.json (SHA via HF snapshot; local dir model_cache/multimolecule-framepool)
  • Task: regression — single scalar MRL per 5'UTR; optional variant-effect log2(MRL_alt / MRL_ref) via paired reference/alternative
  • Weights URL (submission): https://huggingface.co/multimolecule/framepool
  • Hardware: Ascend 910B, single card npu:0, torch_npu, torch.npu.is_available()

Data contract

  • Alphabet: RNA A, C, G, U ( T auto-converted to U), N / unknown → all-zero column, excluded from pooling
  • Vocab: 5 channels (A=0, C=1, G=2, U=3, N=4), null_channel_id=4 zeroed
  • Input: variable length (upstream MPRA 25–100 nt, supports any length), shape [batch, length] with attention_mask (1 = real, 0 = pad)
  • Padding: pad token N (id 4) + attention_mask=0; derived pad_mask = sum(one_hot, -1) excludes pads from conv and pooling (masked)
  • Library indicator: one-hot size 2 (egfp_unmod_1=0, random=1), default random (index 1) matching Kipoi variant-effect interface
  • Output: logits shape [batch, 1] float32 (MRL); with alternative → logits, alternative_logits, delta = log2(alt/ref) shape [batch,1]
  • Dtype: float32 (model config dtype: float32); pre-processing on CPU, core forward on NPU
  • Dataset example: model card examples (microRNA 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)

Environment

  • NPU: Ascend 910B (npu-smi info shows 2 devices, 64 GB HBM), CANN 8.5.1
  • Python: 3.11.14, torch 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_hub
  • Collection: python scripts/collect_env.py --output working/env.json (see workflow log)
  • Mirror: HF_ENDPOINT=https://hf-mirror.com for all HF downloads

Install:

pip install -r requirements.txt

NPU inference

Default 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 3

Key logs (truncated):

  • Model: multimolecule/framepool, Selected device: npu:0, Model first param device: npu:0
  • Input_ids shape: torch.Size([3, 332]) device=npu:0
  • First run (compile) latency: ~220 ms, Stable avg ~2.3 ms
  • MRL predictions (see below) and Status: PASS

Real results (NPU, npu:0, float32, batch 3)

Inputs (RG):

  • example_50nt (50 nt): ACGUACGUACGU...
  • microRNA_21 (22 nt): UAGCUUAUCAGACUGAUGUUGA
  • long_7SK_like (332 nt): GGAUGUGAGGGCGAUCUGG...

Outputs (logits, CPU vs NPU, batch 50/22/277):

  • CPU: [5.625991, 4.632115, 6.905369]
  • NPU: [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)
  • Variant effect demo: 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.568919
  • microRNA_21 (22 nt) → 5.603491
  • long_7SK_like (332 nt) → 3.631469
  • Compile ~219 ms, stable avg ~2.27 ms, throughput ~1320 rows/s

Peak HBM ~3110 MB (idle) → < 4 GB with model (0.28M params ~2.2 MB + activations).

Consistency & performance

  • CPU vs NPU comparison: python scripts/compare_outputs.py --cpu /tmp/cpu_logits.npy --npu /tmp/npu_logits.npy --task regression --atol 1e-3 --rtol 1e-3
    • Result: passed: true, max_abs_error 0.000256, mean_abs_error 0.000135
    • Seed, preprocessing, dtype, weights identical; model & tensors explicitly to npu:0; no CPU fallback
  • Performance (NPU, torch.npu.synchronize() before/after):
    • Warmup compile: ~223 ms (first run includes graph compile)
    • Stable: 10 runs → avg 2.35 ms, min 2.09 ms, max 3.21 ms, p50 ~2.3 ms
    • Batch size 3, lengths 22/50/332 (padded 332), dtype float32, throughput ~1280 rows/s
    • Preprocessing (tokenize + pad) on CPU, not included in NPU compute timing (reported separately)

Evidence (xterm.js, raw style)

Generated 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, validation
  • assets/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:0
  • assets/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.

agent workflow npu device call model result

Limitations

  • Only inference on 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.
  • FP32 only; FP16/BF16 not yet validated for this checkpoint
  • Weight files not included (download at runtime); kernel_meta/ and fusion_result.json excluded per whitelist
  • Long sequences (>1k nt) increase HBM linearly via conv feature map [batch, 128, length] — tested up to 332 nt; >2k nt may need batch 1 and explicit HBM check