w
gcw_uQ09W7jl/aarongid-wifi-densepose-pretrained-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

aarongid/wifi-densepose-pretrained on Ascend NPU

1. 模型简介

aarongid/wifi-densepose-pretrained 是 RuView WiFi Sensing 的 CSI 嵌入模型,将 8 维 WiFi 信道状态信息 (CSI) 特征映射为 128 维 L2 归一化嵌入,用于 presence 检测、活动识别、呼吸/心率等感知任务。架构为 8 -> Linear(64) + BN + GELU -> Linear(128) + BN -> L2Normalize,参数量仅 9,280,权重仅 39KB (safetensors) / 4.56KB (int4)。

  • 模型类型: sona-lora (csi-encoder-8-64-128)
  • 主权重: csi-embed-v2.safetensors (39KB, SHA256 3b37bca66e6050c50ccbc0f6e0501824f258bfdd8675dc0f4541b1e2e96feecd)
  • 量化版本: model-q4.bin 8KB (4-bit), model-q2.bin 4KB, model-q8.bin 16KB
  • 输入: [B,8] 标准化 CSI 特征 (presence, motion, breathing, heart, phase_var, person_count, fall, rssi)
  • 输出: [B,128] L2 归一化嵌入
  • 训练: 自监督对比学习 60 epochs, InfoNCE, temporal triplet accuracy 82.33% (held-out 时序不相交)

GitHub: https://github.com/ruvnet/RuView | HuggingFace: https://huggingface.co/aarongid/wifi-densepose-pretrained

2. 验证环境

  • NPU: Ascend910 (910_9362) x2, 64GB HBM, NPU 0 used as npu:0
  • 镜像: CANN 8.5.1, torch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04
  • 驱动: npu-smi 25.5.5
  • Python: 3.11.14
  • 权重来源: HF_ENDPOINT=https://hf-mirror.com via snapshot_download(repo_id='aarongid/wifi-densepose-pretrained')

3. 安装依赖

pip install -r requirements.txt
# requirements.txt:
# torch==2.9.0
# torch_npu==2.9.0.post1
# safetensors>=0.4.0
# numpy>=1.24

4. NPU 推理

# 方式1: 默认 (自动寻找权重, 若无则从 hf-mirror 下载)
python inference.py

# 方式2: 指定权重路径
python inference.py --weight ./model_cache/wifi-densepose-pretrained/csi-embed-v2.safetensors --device npu:0

# 方式3: 验证模式 (返回码标识一致性)
python inference.py --mode validate

5. 真实推理结果

以下为本次在 npu:0 上的真实输出 (固定输入, seed=0, float32):

Model: aarongid/wifi-densepose-pretrained
Task: wifi-sensing / csi-embedding (8-dim -> 128-dim L2)
Architecture: Enc(8->64->128) BatchNorm+GELU
Weight: model_cache/wifi-densepose-pretrained/csi-embed-v2.safetensors exists=True
Loading backend: safetensors + torch
Dtype: float32
Input contract: [B,8] standardized CSI features, B=3
Sample input[0]: [0.1, 0.05, 0.02, 0.01, 0.3, 0.0, 0.0, -0.45]
Sample input[1]: [0.8, 0.6, 0.4, 0.2, 1.2, 1.0, 0.0, -0.35]
CPU output shape: (3, 128)
CPU output[0][:5]: [0.14886702597141266, -0.03988882526755333, -0.08647223562002182, -0.1151958778500557, -0.06391243636608124]
CPU L2 norms: [0.99999994, 0.99999994, 1.0]
NPU available: True device_name=Ascend910_9362
NPU output shape: (3, 128)
NPU output[0][:5]: [0.14884702861309052, -0.039881035685539246, -0.08646204322576523, -0.11518289893865585, -0.06390015035867691]
NPU L2 norms: [1.0, 1.0, 1.0]
Triplet distances: d(anchor,pos)=0.2559 d(anchor,neg)=0.8479 -> PASS
Final: PASS on npu:0
  • 输入契约: [B,8] float32, B=3 固定样本 (still / moving / breathing)
  • 输出契约: [B,128] float32, L2 归一化 (norm≈1.0)
  • Triplet 距离验证: anchor-still vs breathing (pos) 0.2559 < anchor vs moving (neg) 0.8479, 符合时序嵌入语义

6. CPU-NPU 一致性验证

在相同输入下对比 CPU 与 npu:0 输出:

CPU-NPU max_abs_diff: 0.000300
CPU-NPU mean_abs_diff: 0.000017
CPU-NPU cosine_sim (mean): 1.000000
Consistency check: PASS (threshold max_abs<1e-3, cos>0.999)
  • 验证策略: 单样本一致性 (非完整数据集评测), 固定 3 组 8 维特征
  • 阈值: max_abs < 1e-3 且 cosine > 0.999 视为通过, 本次均满足
  • NPU 设备: torch.npu.is_available()=True, torch.npu.get_device_name(0)=Ascend910_9362, 参数位于 npu:0, dtype float32

7. 性能测试

同步计时 (torch.npu.synchronize() 前后), warmup 3 次, 正式 50 次, batch=3, dtype=float32:

Benchmark: device=npu:0 warmup=3 iters=50 batch=3 dtype=float32
Avg latency: 0.2446 ms (batch 3)  // 单次约 0.25 ms, 单样本约 0.08 ms
Throughput: 12262.94 samples/s (1569655.94 dim/s)
  • 单样本延迟约 0.08 ms, 对应 12k samples/s, 远快于实时 (CSI 1Hz 采样)
  • 测试涵盖完整前向: Linear+BN+GELU+L2Normalize, 不含预处理与首次编译
  • 峰值显存: < 100MB (模型仅 9k 参数)

8. 自验证截图

三张证据图由 scripts/render_xterm_evidence.mjs --style raw 从真实日志渲染:

  • assets/agent_workflow.png - 下载、侦察、NPU 推理、验证、性能完整工作流
  • assets/npu_device_call.png - npu-smi info + torch.npu.is_available() + 设备名 + 参数 device
  • assets/model_result.png - python inference.py 完整输出与 PASS

9. 已知限制

  • 单房间、单次 8 小时采集 (2 nodes, 60630 帧) 训练, 跨房间需 LoRA 适配 (node-1.json/node-2.json)
  • 下游 presence/vitals 精度依赖多标签数据, triplet 指标仅衡量嵌入时序结构
  • 量化版本 (int4) 未在 NPU 上单独验证, 本次验证使用 fp32 csi-embed-v2.safetensors
  • 模型仅在 npu:0 验证, 多卡未测试
  • model.safetensors 头部含填充零, 需用 safe_open 而非 load_file 直接加载

10. 标签

Hardware: NPU, NPU, Ascend, Ascend910, wifi-sensing, csi-embedding, feature-extraction