z
zhangyuge147/Nablaaa-ppo-Pyramids-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Nablaaa/ppo-Pyramids - Ascend NPU Adaptation

  • Base model: Nablaaa/ppo-Pyramids @ 51afdc57fa90b739589ca4b9082ac738191eb606
  • Task: PPO discrete control for Unity ML-Agents Pyramids environment (vector observation → discrete action)
  • Route: offline-rl (PPO discrete policy, extension of Decision Transformer route for robotics RL)
  • Hardware: Huawei Ascend 910B (910_9362), npu:0, torch_npu 2.9.0.post1
  • Dtype: float32, batch 4, obs 172, action_dim 5 (single discrete branch)

Model & Contract

  • Input schema: vector observation float32 [batch, 172] normalized by ML-Agents; seed 42 fixed for validation
  • Architecture: 172 → Linear 512 → ReLU → Linear 512 → ReLU → Linear 5 logits; 353,803 params; ~1.4 MB ONNX / 8.6 MB PT
  • Output schema: discrete logits [batch, 5], argmax action ∈ {0..4}; checked finite, shape, and device
  • Sampling: deterministic argmax (no stochastic sampling; would fix seed/sampler for categorical)
  • Weights: loaded from fixed local cache Pyramids/Pyramids-10240.pt at 51afdc57fa90b739589ca4b9082ac738191eb606; no dummy weights

NPU Evidence (real npu:0)

  • npu-smi Ascend910_9362, torch.npu.is_available()==True, device_count==2
  • All params on npu:0, all floating inputs on npu:0, logits on npu:0, timed with torch.npu.synchronize()
  • No .cpu() compute fallback, no model replacement

CPU-NPU Consistency

  • Shared weights, shared obs (seed 42), same dtype/sampler
  • max_abs = 4.84e-08, mae = 1.97e-08, tolerance atol=1e-4 rtol=1e-3 (FP32) → PASS
  • Validator: validate_policy_outputs.py --atol 1e-4 --rtol 1e-3 → {"passed": true, "count": 20, "max_abs": 4.8e-08}
  • Actions identical: cpu [4, 1, 4, 3] vs npu [4, 1, 4, 3]

Performance (synchronized)

  • Warmup 3, measured 10, torch.npu.synchronize() bracketed
  • First (compile) 0.23 ms, avg 0.16 ms, min 0.14 ms, p50 0.15 ms, p90/p95 0.24 ms
  • decisions_per_s ≈ 24,783 (batch 4 → 24k decisions/s, 24k actions/s, horizon 1, incl. no preprocess overhead)
  • Benchmark: benchmark_policy.py --items-per-call 4 --unit decisions → {"decisions_per_s": 22251.58} (batch 4) and 24783 in inference.py

Usage

pip install -r requirements.txt
python inference.py

Default python inference.py loads local checkpoint via huggingface_hub cache, prints model/revision/route/backend/device/dtype/input summary/logits/action/consistency/latency and PASS/FAIL.

Limitations

  • Single checkpoint Pyramids-10240.pt used for validation; other Pyramids-*.pt share same architecture but may need separate fetch
  • ONNX path available but PyTorch path used for NPU (torch_npu)
  • Environment rollout (Unity) not executed; single-step logits are the validated object per skill hard rule #6

Evidence Images

  • assets/agent_workflow.png — workflow, discovery, NPU, consistency, perf
  • assets/npu_device_call.png — npu-smi and device proof
  • assets/model_result.png — python inference.py output

workflow npu device result