waylong/ppo-Pyramids-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Nablaaa/ppo-Pyramids — Ascend NPU Adapted

NPU adaptation of Nablaaa/ppo-Pyramids (ML-Agents PPO) for Huawei Ascend 910B (npu:0).

  • Source: https://huggingface.co/Nablaaa/ppo-Pyramids
  • Checkpoint: Pyramids/Pyramids-1099880.pt (fixed revision main snapshot 51afdc57fa90b739589ca4b9082ac738191eb606)
  • Task: ML-Agents Pyramids — discrete RL policy (obs → discrete action)
  • Route: offline-rl / discrete-policy (mapped from npu_adapt_robotics contract)
  • Observation契约:
    • obs_0 [B,56] float32
    • obs_1 [B,56] float32
    • obs_2 [B,56] float32
    • obs_3 [B,4] float32
    • concat → [B,172] → Linear 172→512 (Swish) → Linear 512→512 (Swish) → Logits [B,5] → masked softmax
    • action_masks [B,5] float32 (1=valid)
  • 动作契约: discrete action_dim=5, horizon=1, output deterministic_discrete_actions [B,1] int64 (ArgMax) + discrete_actions stochastic via Multinomial; version_number=[3], memory_size=[0]
  • Backend: torch_npu 2.9.0.post1 on Ascend910_9362, torch 2.9.0, dtype=float32

真实结果(NPU:0)

  • device: npu:0 (Ascend910_9362, device_count=2)
  • model param device: npu:0, input device: npu:0, output device: npu:0 — 全链路无 CPU fallback
  • 示例 batch=1 观测(seed 0):
    • CPU logits [-1.90618, 1.25010, -1.07639, -3.20638, 3.98736] deterministic [[4]]
    • NPU logits [-1.90618, 1.25010, -1.07639, -3.20638, 3.98736] deterministic [[4]]
  • CPU-NPU 一致性: max_abs_logits=2.38e-06, max_abs_probs=1.19e-07, det_match=True, finite=True — 阈值 atol=1e-4 rtol=1e-3 PASS

性能(同步计时,torch.npu.synchronize() 包围)

  • 预热 3 次,测量 12 次(含 warmup 后 10 次有效)
  • avg 0.373ms / min 0.353ms / max 0.827ms / p50 0.373ms
  • decisions_per_s ≈ 2680, actions_per_s ≈ 2680 (batch=1, horizon=1)

环境限制

  • 单卡 Ascend910B 可运行,显存 ~116 MB;模型权重 8.3 MB (2 层 512 hidden + 1 层 logit)
  • 需要 torch_npu,huggingface_hub 自动下载权重(首次联网),离线缓存 /data/adapt-npu-hf
  • trust_remote_code 不适用(本地权重加载,无远程代码执行)

证据

Agent workflow NPU device call Model result

推理

python inference.py

默认从 HuggingFace 拉取 Nablaaa/ppo-Pyramids 的 Pyramids/Pyramids-1099880.pt,在 npu:0 上执行同步推理,打印一致性与耗时并以 PASS/FAIL 退出。

许可证

原权重遵循其模型卡许可证(ML-Agents),本仓仅提供 NPU 适配代码与验证。