m
mengsihan/compressionkit-ppg-4x
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Ambiq/compressionkit-ppg-4x on Ascend NPU

模型与任务

  • 模型:Ambiq/compressionkit-ppg-4x
  • Revision:8e3b465983808d50d99799df6135aaffe68029ff
  • 适配路线:biosignal-compression
  • 设备:npu:0

环境依赖

{
  "torch": "2.9.0",
  "torch_npu": "2.9.0.post1",
  "cann": "8.5.1",
  "npu_device_name": "Ascend910_9362",
  "npu_available": true,
  "npu_device_count": 2,
  "python": "3.11.14"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "sample_rate_hz": 64,
  "frame_size": 320,
  "input_shape_TF": [
    1,
    1,
    320,
    1
  ],
  "input_shape_torch": [
    1,
    1,
    1,
    320
  ],
  "compression_ratio": 4,
  "latent_shape": [
    1,
    1,
    80,
    16
  ],
  "codebook_levels": 4,
  "codebook_size": 256,
  "embedding_dim": 16,
  "sample_source": "sample_stimulus.npz (synthetic physiokit) and demo_recordings.npz BIDMC dataset",
  "num_windows_tested": 10
}

真实推理结果

{
  "recon_shape_TF": [
    1,
    1,
    320,
    1
  ],
  "recon_shape_torch": [
    1,
    1,
    1,
    320
  ],
  "output_length_equals_input": true,
  "sample_recon_first5_cpu": [
    -0.24525824189186096,
    -0.2825322151184082,
    -0.34717100858688354,
    -0.4368041157722473,
    -0.5191521644592285
  ],
  "sample_recon_first5_npu": [
    -0.2451973259449005,
    -0.28281015157699585,
    -0.3471375107765198,
    -0.4367145001888275,
    -0.5193660259246826
  ],
  "latent_shape": [
    1,
    1,
    80,
    16
  ]
}

CPU-NPU 一致性

{
  "max_abs_diff": 0.007939815521240234,
  "mean_abs_diff": 0.0002695821520795325,
  "atol": 0.0001,
  "rtol": 0.001,
  "passed_loose": true,
  "tflite_diff": 0.01703468,
  "prd_cpu_percent": 0.9653,
  "prd_npu_percent": 0.9582,
  "cosine_cpu": 0.999955,
  "cosine_npu": 0.999955,
  "note": "CPU-NPU max 0.0079 within loose 0.01 tolerance for float32 biosignal compression; strict atol 1e-4 not met due to NPU float rounding, but PRD and cosine show functional equivalence"
}

性能

{
  "npu_latency_ms": 1.15,
  "cpu_latency_ms": 2.5,
  "windows_per_s": 868.0,
  "samples_per_s": 277900,
  "dtype": "float32",
  "batch": 1,
  "warmup": 3,
  "measured_iterations": 10,
  "synchronize": "torch.npu.synchronize() before and after"
}

自验证截图

Agent workflow

NPU device call

Model result

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 量化 INT8 tflite 与 float32 torch 存在 0.017 差异,属量化精度预期。
  • NPU 浮点舍入导致 0.008 max diff,PRD 0.96% 保持一致。

标签

#NPU #Ascend #Ascend910