HumanCompatibleAI/ppo-CartPole-v1 (PPO MlpPolicy)08b61dd5dca1ee9f1a0f2d7a0fcf7740b0af5dacoffline-rl (adapted PPO discrete policy, observation -> action)ppo-CartPole-v1/policy.pth (40641 bytes, ~32k params, Tanh MLP 64x64 + logits 2)npu:0 and cpu[cart_pos, cart_vel, pole_angle, pole_ang_vel] where cart_pos in [-4.8,4.8], pole_angle in [-0.418,0.418] rad, dtype float32mlp_extractor.policy_net=[Linear(4,64)+Tanh, Linear(64,64)+Tanh] -> action_net Linear(64,2) -> logits -> argmax and value network same shape. Deterministic inference uses argmax, stochastic would sample from softmax.torch.nn (Tanh activations matching SB3) to allow direct to(npu:0) placement and avoid gymnasium/stable-baselines3 NPU incompatibilities.policy.pth OrderedDict: mlp_extractor.policy_net.*, mlp_extractor.value_net.*, action_net.*, value_net.*.npu:0 when NPU requested; verified via next(model.parameters()).device, input.device, output.device.torch.npu.synchronize() before/after forward.pip install -r requirements.txt
python inference.py # auto NPU if available
python inference.py --device npu # force npu:0
python inference.py --device cpu # force cpu
python inference.py --mode validate # CPU vs NPU consistency
python inference.py --mode benchmark # warmup 3 + 10 measuredDefault python inference.py loads local policy.pth (or hf_hub_download fallback), prints model/revision/route/backend/device/dtype/input summary/action summary/synced latency/PASS/FAIL.
Ascend910_9362, torch.npu.is_available()=True, npu:0 exists, count=2npu:0 (single obs [0,0,0,0] centered upright, batch 8 covering centered/tilted/cart-offset states)npu:0 shape [1,2] logits and [8,2] batch, action shape [1] and [8][-6.353, 6.356] -> probs [3.0e-06, 0.999997] -> action 1 (push right) value 49.98[1,1,1,1,0,1,0,1] with high confidence (>0.93 even near decision boundary, saturates to 1.0 for far states)37.5-50.0 with max at uprightShared weights, same 8 fixed observations, same Tanh MLP, deterministic argmax, dtype float32. Compared logits, probs, argmax action and value. Threshold FP32 atol=1e-4 rtol=1e-3. Discrete action bounds checked.
| metric | value |
|---|---|
| max_abs_logits | 0.000004 |
| max_abs_probs | 0.000000 |
| max_abs_value | 0.000004 |
| tolerance | 0.018267 |
| actions_match (argmax) | true |
torch_npu built for CANN 8.5.1, Ascend910B/910 recommended, single card sufficient.python -m gymnasium not required at runtime; pure torch inference avoids env dependencies.inference.py.assets/agent_workflow.png — full workflow: inspection, NPU check, load, NPU inference, consistency, benchmarkassets/npu_device_call.png — npu-smi, torch_npu availability, device name, model/input/output device proofassets/model_result.png — default python inference.py showing logits, action, latency, PASSinference.py
readme.md
requirements.txt
assets/agent_workflow.png
assets/npu_device_call.png
assets/model_result.png