m
mengsihan/xECG_base_model_v1-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

riccardolunelli/xECG_base_model_v1 on Ascend NPU

模型与任务

  • 模型:riccardolunelli/xECG_base_model_v1
  • Revision:b06053253a9bd21445d8189b21813484929a3ffa
  • 适配路线:ecg-representation
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "device_name": "Ascend910_9362",
  "soc_version": "ascend910_9391",
  "revision": "b06053253a9bd21445d8189b21813484929a3ffa",
  "python": "3.11",
  "cann": "8.5.1"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "signal_source": "synthetic deterministic ECG (seed 42, 1Hz+harmonics per lead, 0.05 noise)",
  "sampling_freq": 100,
  "leads": 12,
  "leads_order": [
    "i",
    "ii",
    "iii",
    "avr",
    "avl",
    "avf",
    "v1",
    "v2",
    "v3",
    "v4",
    "v5",
    "v6"
  ],
  "window": 2500,
  "window_seconds": 25.0,
  "patch_size": 25,
  "shape": [
    1,
    2500,
    12
  ],
  "dtype": "float32",
  "sha256_prefix": "2a99510f37c9b6c5",
  "mean": 0.004463,
  "std": 0.581194
}

真实推理结果

{
  "cls_shape": [
    1,
    1024
  ],
  "patches_shape": [
    1,
    100,
    1024
  ],
  "cls_mean_cpu": -0.005928894970566034,
  "cls_mean_npu": -0.005928981117904186,
  "embedding_size": 1024,
  "pooling": "avg"
}

CPU-NPU 一致性

{
  "cls_cosine_similarity": 1.0,
  "cls_max_abs_diff": 0.0006215572357177734,
  "cls_mean_abs_diff": 5.4174470278667286e-05,
  "patches_max_abs_diff": 0.001343846321105957,
  "atol": 0.01,
  "rtol": 0.01,
  "threshold_cosine": 0.999,
  "passed": true
}

性能

{
  "warmup": 3,
  "stable_runs": 10,
  "npu_avg_ms": 334.4,
  "npu_first_ms": 328.61,
  "cpu_ms": 738.21,
  "throughput_records_per_s": 2.99,
  "window": 2500,
  "dtype": "float32",
  "device": "npu:0",
  "note": "timing with torch.npu.synchronize() before/after"
}

自验证截图

Agent workflow

NPU device call

Model result

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 使用合成确定性ECG信号,非PTB-XL真实患者记录;但信号契约一致。
  • xLSTM backend强制为vanilla以兼容NPU;已验证CPU-NPU一致性。

标签

#NPU #Ascend #Ascend910