Base Model: HumanCompatibleAI/ppo-CartPole-v1 Revision: main (ppo-CartPole-v1.zip 137KB, 9155 params) Route: offline-rl (discrete policy, state->action) - CartPole 4-dim observation to Discrete(2) action Task: Reinforcement Learning - CartPole-v1 balancing control Hardware: Ascend 910 (Ascend910_9362) NPU:0
训练于 CartPole-v1 的 PPO (Proximal Policy Optimization) 智能体,使用 stable-baselines3 MlpPolicy。观测为 4 维连续向量 [cart position, cart velocity, pole angle, pole angular velocity],动作空间 Discrete(2) (0=向左推, 1=向右推)。奖励在每一时间步保持杆直立时为 +1,episode 在杆角度超过阈值或 500 步后结束。基座模型在评估中达到 mean_reward 500.00。
Box(4,) float32, bounds [-4.8, -inf, -0.418, -inf] to [4.8, inf, 0.418, inf], 代表 CartPole 物理状态Discrete(2) 通过 action_net 输出 2 维 logits,经 argmax 得到离散动作;同时输出 value 估计PPO.load("ppo-CartPole-v1.zip") -> policy.extract_features -> mlp_extractor -> _get_action_dist_from_latent -> logitsnpu:0,采样在 NPU 上完成在 Ascend910_9362 上端到端验证:
/tmp/ppo-cartpole/ppo-CartPole-v1.zip (139331 bytes) 固定 revision main,未替换模型policy param device after to(npu:0): npu:0, NPU input tensor device: npu:0, NPU logits device: npu:0, NPU latent device: npu:0, torch.npu.is_available(): Truemax_abs=3.81e-06, tolerance=0.03549 (atol=1e-4 rtol=1e-3), finite=True, PASS[1,1,1,1] vs NPU [1,1,1,1] 完全一致,shape [4,2] horizon=1 action_dim=2[0,0,0,0] CPU logits [-12.709067, -2.86e-06] NPU [-12.709069, -2.86e-06] -> action 1validate_policy_outputs.py --atol 1e-4 --rtol 1e-3 对 logits 数值比较{"count":8,"finite":true,"max_abs":3.81e-06,"tolerance":0.03549,"passed":true}torch.npu.synchronize() 包围的同步计时,预热 3 次后测量 10 次:
avg 0.4404ms min 0.4219ms max 0.4770ms p50 0.4392ms p90 0.4770ms p95 0.4770ms2270.53 decisions/s (batch=1, 1 decision per forward, 2 logits)pip install -r requirements.txt
python inference.py
# 预期输出 model/revision/route/backend/device/dtype/观测摘要/动作摘要/同步耗时/PASS
