HumanCompatibleAI/ppo-CartPole-v1 is a PPO (Proximal Policy Optimization) agent trained with the RL Zoo and stable-baselines3 on the CartPole-v1 environment. It learns to balance a pole on a cart by choosing between two discrete actions (push left / push right).
MlpPolicy)ActorCriticPolicy (MLP 64-64, Tanh) with separate actor (action_net) and critic (value_net) heads[cart_pos, cart_vel, pole_angle, pole_ang_vel]This repository adapts the real trained PPO policy to run on a single Ascend NPU (npu:0). All policy parameters and every input/output tensor are explicitly placed on npu:0; inference.py loads the real weights from the local checkpoint directory and produces the real policy action (action logits, probabilities and value estimate).
| Field | Value |
|---|---|
| Route | offline-RL policy (SB3 PPO) |
| Observation dim | 4 (cart_pos, cart_vel, pole_angle, pole_ang_vel) |
| Action dim | 2 discrete (CartPole push left/right) |
| Actor | Linear(4→64) → Tanh → Linear(64→64) → Tanh → Linear(64→2) |
| Critic | Linear(4→64) → Tanh → Linear(64→64) → Tanh → Linear(64→1) |
| Output | action logits, action probabilities, state value, deterministic action |
| Sampler | deterministic (argmax) for verification |
| Seed (training) | 2623485154 |
The model is evaluated on fixed, deterministic CartPole observation batches (real observations from the environment space, no random initialization at verification time). inference.py uses a fixed 5-observation batch of float32 CartPole state vectors.
The weights are loaded from the local checkpoint directory (PPO_CARTPOLE_LOCAL_DIR) if provided, otherwise downloaded from HuggingFace Hub (HF_ENDPOINT mirror) on first run.
npu:0), CANN 8.5.1 / Ascend Toolkitpip install -r requirements.txtpython inference.pyTo load weights from a local directory instead of downloading:
PPO_CARTPOLE_LOCAL_DIR=/path/to/model python inference.pyAll computation runs on npu:0 (Ascend910_9362). The 5-observation batch produces:
(5, 2), dtype float32, device npu:0(5, 2), device npu:0(5, 1), device npu:0[1, 1, 1, 0, 1][-6.35313, 6.35593, -17.81828, 17.82692, -18.07850, 18.08478, 10.21172, -10.21372, -9.73818, 9.74270]0.000006 (tol 0.018), max_diff_value: 0.000008 (tol 0.050), actions_match True, finite True0.30 ms, min 0.28 ms, max 0.34 ms, p50 0.29 ms, p90 0.31 ms, p95 0.34 msCPU and NPU share identical weights (ppo-CartPole-v1.zip), observation batch, preprocessing, deterministic sampler, seed, dtype (FP32) and policy parameters. Verification uses FP32 tolerance atol=1e-4, rtol=1e-3. Logits and value are compared element-wise; actions are compared via torch.equal on argmax. Tolerance is satisfied (0.000006 < 0.018).
npu:0torch.npu.synchronize() before/after each timing


npu:0) only; multi-card not tested.MIT (original model). NPU adaptation code MIT.