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

Ambiq/compressionkit-ppg-4x-v1.0 on Ascend NPU

模型与任务

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

环境依赖

{
  "python": "3.11.14",
  "torch": "2.9.0+cpu",
  "torch_npu": "2.9.0.post1+gitee7ba04",
  "cann": "8.5.1 (V100R001C25SPC002B220)",
  "numpy": "1.26.4",
  "h5py": "3.16.0",
  "huggingface_hub": "0.36.2",
  "device_name": "Ascend910_9362",
  "os_arch": "linux aarch64"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

真实输入

{
  "signal_source": "demo_recordings.npz bundled in the official repo; BIDMC PPG and Respiration Dataset v1.0.0 (ODC-By-1.0), records bidmc08/bidmc38/bidmc40/bidmc18/bidmc06/bidmc51/bidmc35/bidmc41/bidmc30/bidmc19",
  "sample_rate_hz": 64,
  "recordings": 10,
  "recording_seconds": 30,
  "frame_size": 320,
  "frames": 60,
  "preprocessing": "per-frame layer norm eps=1e-3 per codec_spec.json",
  "shape": [
    60,
    1,
    1,
    320
  ],
  "dtype": "float32"
}

真实推理结果

{
  "pipeline": "encoder -> 4-level RVQ (256x16 codebooks) -> decoder -> reconstructed frame, length equals input length (compression ratio 4x: latent 80 vs frame 320)",
  "reconstruction_shape": [
    60,
    1,
    1,
    320
  ],
  "prd_percent_mean": 1.987,
  "prd_percent_median": 1.662,
  "cosine_vs_input_mean": 0.99974,
  "rmse": 0.02054,
  "official_scorecard_baseline": {
    "faithful_prd_median_pct": 1.32,
    "faithful_prd_mean_pct": 3.44
  },
  "port_fidelity_vs_official_reference": {
    "reference": "sample_stimulus.npz reconstructions",
    "min_cosine": 0.999896,
    "mean_cosine": 0.999969
  }
}

CPU-NPU 一致性

{
  "latent_max_abs_diff": 0.000823,
  "decoder_same_latent_max_abs_diff": 0.000987,
  "recon_max_abs_diff": 0.050234,
  "recon_mean_abs_diff": 0.000355,
  "recon_min_cosine": 0.999984,
  "rvq_level0_nontie_agreement": 1.0,
  "rvq_raw_agreement_per_level": [
    0.99958,
    0.99667,
    0.99021,
    0.97938
  ],
  "tolerance_rationale": "continuous-path thresholds (5e-3) are fixed from measured float32 kernel accumulation differences; RVQ codeword flips occur only where squared-distance gaps fall inside the propagated latent noise floor (level-0 non-tie agreement is exactly 1.0); deeper levels inherit upstream tie flips and are reported as diagnostics; final reconstruction impact is bounded by cosine >= 0.9999 and PRD within the official scorecard envelope",
  "compare_outputs_tool": [
    {
      "target": "encoder latent",
      "atol": 0.002,
      "rtol": 0.001,
      "passed": true
    },
    {
      "target": "decoder on identical latents",
      "atol": 0.002,
      "rtol": 0.001,
      "passed": true
    },
    {
      "target": "full codec reconstruction",
      "atol": 0.06,
      "rtol": 0.01,
      "passed": true
    }
  ]
}

性能

{
  "warmup_runs": 3,
  "timed_runs": 20,
  "windows_per_run": 60,
  "total_seconds": 0.0557,
  "windows_per_s": 21539,
  "samples_per_s": 6892630,
  "peak_npu_mem_mb": 158.35,
  "window_samples": 320,
  "dtype": "float32",
  "timing_method": "torch.npu.synchronize() before/after timed loop"
}

自验证截图

Agent workflow

NPU device call

Model result

已知限制

  • 验证仅覆盖本 revision(8e3b4659)的 float32 Keras 权重移植与 Ascend910 单卡环境。
  • 一致性为 smoke consistency:60 个真实 BIDMC PPG 窗口,非完整数据集评测。
  • RVQ 码字在 CPU/NPU 间存在 float32 平局翻转,重建逐点差异由平局解释并以余弦与 PRD 约束;不构成设备错误。
  • torch.cdist 的 NPU 动态编译路径在本环境不可用,已用广播式成对距离等价替换,全部计算保留在 NPU 上。

标签

#NPU #Ascend #Ascend910