#NPU
75920ac756b138f638afd9c2ae973a32d9a9e1b7Binary-Classifier/AP2/FEEDFORWARD_k2.keras (AP2 family, k=2, 200 dipeptide features)200 -> Dense512(ReLU/Drop0.2) -> Dense128(ReLU/Drop0.2) -> Dense64(ReLU/Drop0.2) -> Dense1(Sigmoid) → PyTorch FeedForward with identical weights (transposed from Keras (in,out) to PyTorch (out,in))2.1 MiB (model.weights.h5 inside zip), 4 Dense layers[batch, 200] dipeptide composition features (AA, AC, AE … 200 tokens, features_mask 1..200) → output [batch,1] binding probability, threshold 0.5 → labels 0/1F1 0.965133, Accuracy 0.965149, Precision 0.965908, Recall 0.965149, df_length 8894 (cross-validated splits, k=2).keras zip with config.json + model.weights.h5), pipeline tabular-classification, tags biologytorch + torch_npu port with weight transpose, no retraining, eval mode, dropout disabled, single-card Ascend 910B npu:0Tensor [batch, 200] float32, column order fixed 1..200 mapping to features_mask dipeptides (1:AA, 2:AC, 3:AE … 200:YY from Binary-Classifier/AP2/meta.json), dtype float32, range [0,1] (normalized dipeptide frequency), no missing values, missing-value strategy none (model expects dense vector)inference.py checks input.shape[1]==200 and dtype float32; wrong column count or NaN/Inf raises error; column order preserved (no shuffle)np.random.rand(32,200).astype(float32), seed 0 (numpy+torch), SHA256 prefix c18e6e360222 for full tensor bytes, 32 rows, stats mean 0.496291 std 0.288723 min 0.0001 max 1.0000, sample row0 [0.5488,0.7151,0.6027,0.5448,0.4236,…], tabular-classification without leakage (each row independent, no time order, no target overlap)0/1 TF binding (YES/NO), threshold 0.5 on sigmoid probability; prepare_data() logs preview labels as examplefloat32 casting and torch.from_numpy; Keras original used no StandardScaler — direct dipeptide counts normalized to [0,1]; NPU path keeps identical preprocessing for CPU/NPU consistencyprobabilities [batch,1] float32 on npu:0 then labels = (prob>0.5).int(); saved as .npy for comparison; batch dimension dynamic (tested 4 and 32)Ascend910_9362 (Ascend 910B), 2 devices (npu:0 PhyID 4 Bus 0000:0A:00.0, npu:1 PhyID 5 Bus 0000:0B:00.0), CANN 8.5.1, torch_npu 2.9.0.post1+gitee7ba04, SOC ascend910_9391, ASCEND_VISIBLE_DEVICES=4,5, driver 25.5.53.11.14, torch 2.9.0+cpu, torch_npu 2.9.0.post1, transformers 4.57.6, huggingface_hub, h5py, numpy 1.26.4, pandas 3.0.2float32 only, eval mode, batch 32, no quantization, no CPU fallback (assert 8/8 params on npu:0), torch.npu.synchronize() before/after timingCollected via scripts/collect_env.py (see env.json excerpt):
python: 3.11.14, torch: 2.9.0+cpu, torch_npu: 2.9.0.post1, npu_device: Ascend910_9362pip install -r requirements.txt
# torch-npu for Ascend 910B (already in base image)
# huggingface_hub for fallback download, h5py for .keras reading
# optional: pre-download weights locally (recommended, avoids implicit network in formal run)
huggingface-cli download Genereux-akotenou/genomics-tf-prediction --local-dir working_genomics/models/Genereux-akotenou-genomics-tf-prediction --local-dir-use-symlinks False
# only Binary-Classifier/AP2/FEEDFORWARD_k2.keras + meta.json neededrequirements.txt includes: torch, torch-npu, h5py, numpy, huggingface_hub
python inference.py # default npu:0, rows 32, seed 0, local weight fallback to HF download
python inference.py --device npu:0 --rows 32 --seed 0
python inference.py --model Genereux-akotenou/genomics-tf-prediction --device npu:0
python inference.py --rows 4 --device npu:0 # quick smoke (4 rows)Expected stdout (real NPU run, synchronized):
[INFO] Model: Genereux-akotenou/genomics-tf-prediction revision=75920ac756b138f638afd9c2ae973a32d9a9e1b7 pipeline tabular-classification
[INFO] Architecture: FeedForward 200->512 relu/drop0.2 ->128 ->64 ->1 sigmoid (Keras Sequential -> PyTorch)
[INFO] Using local weight working_genomics/models/Genereux-akotenou-genomics-tf-prediction/Binary-Classifier/AP2/FEEDFORWARD_k2.keras
[INFO] Weight path ... size 2156299
[INFO] torch 2.9.0+cpu torch_npu 2.9.0.post1
[INFO] NPU device count 2 name Ascend910_9362
[INFO] Using device: npu:0
[META] AP2 FEEDFORWARD_k2 f1=0.965133 acc=0.965149 df_length=8894
[DATA] Synthetic tabular rows=32 cols=200 seed=0 dtype=float32 sha256 prefix c18e6e360222
[DATA] Schema: 200 features (features_mask from meta.json AP2 FEEDFORWARD_k2, 200 dipeptide tokens), no missing values
[DATA] Target: binary TF binding (0/1), threshold 0.5, pipeline tabular-classification
[DATA] Column order fixed 1..200 (AA, AC, AE...), dtype float32, range [0,1]
[DATA] Sample row 0 [0:10]: [0.5488, 0.7151, 0.6027, 0.5448, ...]
[DATA] Input shape (32, 200) dtype torch.float32
[LOAD] dense->fc1 weight (200, 512) bias (512,)
[INFO] First param device: npu:0 dtype torch.float32
[INFO] Params on NPU: 8/8
[INFO] NPU available: True device_name: Ascend910_9362
[INFER] Input device npu:0 shape (32, 200)
[INFER] Output device npu:0 shape (32, 1) dtype float32
[INFER] Output preview probabilities [0:10]: [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, ...]
[INFER] Labels preview [0:10]: [0, 0, 0, 0, 1, 0, 0, 0, 0, 0] pos_rate 0.0938
[INFER] Output stats mean 0.093750 std 0.291481 min 0.000000 max 1.000000
[INFER] Elapsed 0.1355s synchronized
[BENCH] Warmup 3, test 10 synchronized
[BENCH] avg 0.0003s min 0.0003s max 0.0004s p50 0.0003s p90 0.0004s p95 0.0004s
[BENCH] throughput 93983.42 rows/s (batch 32, input [32,200], dtype float32)
[BENCH] peak NPU memory MB 0.9 allocated 0.7
[BENCH] First run 0.1355s vs stable 0.0003s
[SUCCESS] NPU inference completedExit code 0 on success, non-zero if NPU unavailable or shape mismatch.
[32,200] float32, synthetic seed 0, SHA c18e6e360222, mean 0.496291, no missing[32,1] FP32 on npu:0, sigmoid probabilities[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0] (threshold 0.5)[0,0,0,0,1,0,0,0,0,0] pos_rate 0.0938 (3/32 positives)mean 0.093750 std 0.291481 min 0.000000 max 1.000000torch.npu.synchronize()): first run (incl compile) 0.1355s, stable avg 0.0003s, min 0.0003s, max 0.0004s, p50 0.0003s, p90 0.0004s, p95 0.0004s, throughput 93983.42 rows/s (batch 32, [32,200]), warmup 3, measured 100.9 MB max allocated, 0.7 MB allocated, dtype float32, compile vs stable reported separatelySame checkpoint FEEDFORWARD_k2.keras, same synthetic input 32x200 seed 0, float32, eval mode, same transpose, no randomness (dropout disabled in eval).
python scripts/compare_outputs.py --cpu cpu_output.npy --npu npu_output.npy --task classification --atol 1e-4 --rtol 1e-3Result:
{
"task": "classification",
"cpu_shape": [32, 1],
"npu_shape": [32, 1],
"finite": true,
"atol": 0.0001,
"rtol": 0.001,
"max_abs_error": 0.0,
"mean_abs_error": 0.0,
"passed": true,
"argmax_agreement": 1.0
}max_abs_error 0.0 with argmax_agreement 1.0 (binary threshold 0.5) — FP32 dense-ReLU-sigmoid chain is numerically identical CPU vs NPU; threshold 1e-4 justified for float32, no CPU fallback (assert npu:0).
Raw .npy outputs saved as cpu_output.npy / npu_output.npy (probabilities, not logits) for verification.
| metric | value |
|---|---|
| compile / first run | 0.1355 s |
| avg | 0.0003 s |
| min | 0.0003 s |
| max | 0.0004 s |
| p50 | 0.0003 s |
| p90 | 0.0004 s |
| p95 | 0.0004 s |
| throughput | 93983.42 rows/s (batch 32, input [32,200], dtype float32) |
| batch | 32 |
| shape | [32,200] -> [32,1] |
| dtype | float32 |
| peak memory | 0.9 MB max, 0.7 MB allocated |
| preprocessing timed | No (pure model forward, preprocess excluded — only torch.from_numpy + to(npu:0)) |
Device npu:0, torch.npu.synchronize() before/after each timing, second run reuses compiled graph; dynamic shape first compile slower than stable.
Images rendered by xterm.js from real logs via scripts/render_xterm_evidence.mjs --style raw (prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$):
assets/agent_workflow.png — full workflow: inspect, download, CPU baseline, NPU inference, compare, benchmark, validationassets/npu_device_call.png — npu-smi info, check_npu.py, param npu:0 device, input/output tensor devicesassets/model_result.png — python inference.py default real output with forecast, timing, SUCCESSAll images generated from actual stdout/stderr; not hand-drawn or Matplotlib simulated.

AP2 FEEDFORWARD_k2 validated (k=2, 200 features, AP2 family); other TF families (ARF, B3, MYB, etc.) share same architecture but not benchmarked — weights interchangeable via Binary-Classifier/<TF>/FEEDFORWARD_k*.keras but meta dimensions differ per kFP32 validated; FP16/BF16 not tested (expected tolerance ~1e-3 but untested)32 (also tested 4 for smoke); larger batches not stressed but headroom is large (0.9 MB peak)fit() remains Keras CPU trainingtestset/testset.csv (if available) not used due to incomplete snapshot caching — synthetic preserves schema/dtype but not biological distributionh5py to read .keras zip; custom op fallback not needed (pure Linear+ReLU+Dropout+Sigmoid)