#NPU
Genereux-akotenou/genomics-tf-prediction is a genomics transcription-factor (TF) binding prediction model. It classifies a query amino-acid sequence into one of 58 plant transcription-factor families based on k-mer composition.
Binary-Classifier/<FAMILY>/FEEDFORWARD_k3.keras): input = 1000 amino-acid trigram (k-mer) count features, output = sigmoid binding probabilityMetaClassifier/META_k3.keras): input = the 58 family probabilities, output = softmax over 58 TF familiesconfig.json, weights from model.weights.h5), re-implemented as PyTorch MLPsThis repository adapts the checkpoint to run on single-card Ascend NPU (npu:0). All parameters and input tensors are explicitly placed on npu:0; inference.py runs the real weights on real test data.
Input: one row = normalized amino-acid k-mer (trigram) counts, with columns named by the k-mer (e.g. AAR, AAT). The model vocabulary for family <FAMILY> is defined by meta.json → <FAMILY> → FEEDFORWARD_k3 → features_mask (k-mer → feature index, 1000 features).
Real labeled test data: testset/testset.csv (from the model repository), 64,091 rows × 7,754 columns, 58 TF-family labels in the class column. This adaptation uses a stratified sample of 20 rows (one per family) for the default run.
Preprocessing contract:
features_mask order; column order is preserved.__ (e.g. E2F/DP → E2F__DP) to match the model directory naming.npu:0)models/genomics-tf-prediction/ (downloaded via huggingface_hub.snapshot_download('Genereux-akotenou/genomics-tf-prediction'))pip install -r requirements.txtpython inference.py --device npu:0 --rows 20The script:
.keras checkpoints into PyTorch on npu:0.npu:0.[RESULT] synchronized inference time: ~40 ms
[RESULT] accuracy: 0.9500 (19/20)Sample rows: Dof→Dof, Whirly→Whirly, NF-YB→NF-YB, ZF-HD→ZF-HD, NF-YA→NF-YA, TCP→TCP, HD-ZIP→HD-ZIP, SBP→SBP, Nin-like→Nin-like, YABBY→YABBY, CPP→CPP, Trihelix→Trihelix, C2H2→C2H2, RAV→RAV, SRS→SRS, EIL→EIL, MYB→MYB (0.921), DBB→DBB (0.520), G2-like→G2-like, and one misclassification HB-other→LBD (0.426).
CPU and NPU runs use identical weights, inputs, preprocessing, dtype (float32) and seed. The softmax probability matrices are compared:
| Metric | Value |
|---|---|
| max abs error | 1.19e-06 |
| mean abs error | 3.89e-09 |
| argmax agreement | 1.000 |
| threshold (atol/rtol) | 1e-4 / 1e-3 |
FP32 thresholds are justified by the small MLP structure and matching outputs.
| Metric | Value |
|---|---|
| first-run (compile) | 155 ms |
| stable avg / min / max | 12.7 / 12.4 / 13.0 ms |
| p50 / p90 / p95 | 12.7 / 12.9 / 12.9 ms |
| throughput | ~1572 rows/s |
| peak NPU memory | 143.6 MB |
Timing covers the two-stage inference (58 family forwards + META forward); torch.npu.synchronize() is called around each timed run. Preprocessing (feature extraction) is not included in the per-run timing.
The three PNGs below are generated by xterm.js from this task's real command logs (not hand-drawn screenshots):
assets/agent_workflow.png — environment check, model download, analysis, NPU inference, CPU-NPU consistency, performance benchmarkassets/npu_device_call.png — npu-smi, torch/torch_npu versions, NPU availability, model parameter/input/output tensor device proofassets/model_result.png — default python inference.py real full output (schema, predictions, synchronized timing, status)config.json + model.weights.h5); TensorFlow is not required.--rows 64091 (larger runtime).E2F/DP, NZZ/SPL) use / and are normalized to __ to match directory names.