This is an Ascend NPU-adapted deployment for HumanCompatibleAI/ppo-Pendulum-v1 (PPO on Pendulum-v1, reinforcement-learning).
6a0fe838119427278252dde3bf723ed7a3266df5MlpPolicy with net_arch pi:[64,64] vf:[64,64] ReLU, continuous 1-D action Box [-2,2], obs dim 3 [cos(theta), sin(theta), theta_dot]offline-rl (PPO continuous decision, closest to Decision Transformer contract: state→action, horizon=1)npu:0 with synchronized timing and CPU-NPU consistency validationPendulum-v1 continuous torque control (observations: cos/sin of angle + angular velocity)Model and tensors are explicitly placed on npu:0 and verified:
next(extractor.parameters()).device == npu:0action_net.weight.device == npu:0log_std param device == npu:0input obs Tensor device == npu:0mean/action device == npu:0, value device == npu:0Synchronization uses torch.npu.synchronize() before/after timing.
[1.0,0.0,0.0] upright):
[[0.40988], [-5.1887], [3.0893], [-4.0313]] batch=4, shape [4,1][-2,2] => [[0.40988], [-2.0], [2.0], [-2.0]][ -13.49, -129.67, -129.33, -66.31] batch=4, shape [4,1]~9.5e-07 (< 1e-4 + 1e-3*max), value diff <1.6e-05 (<1e-3)[-2,2], shape correct => PASSpolicy.pth 40,641 bytes, log_std [64,1]), fp32torch.npu.synchronize() around each timed forwardValidated on Ascend 910 (2x NPU, 61 GiB free per card, torch_npu 2.9.0.post1, CANN 8.5.1).
import torch, torch_npu, torch.nn as nn
from pathlib import Path
ckpt = torch.load("policy.pth", map_location="cpu") # from https://huggingface.co/HumanCompatibleAI/ppo-Pendulum-v1
# Build extractor + heads as in inference.py and move to npu:0
# obs: tensor shape [B,3] float32 [[cos, sin, theta_dot]]
# latent_pi, _ = extractor(obs_npu)
# mean = action_net(latent_pi) # device npu:0
# action = torch.clamp(mean, -2.0, 2.0)
# value = value_net(latent_vf)See inference.py for full synchronized example with device proof and batch 4.

inference.py - NPU inference with device proof, consistency and perfrequirements.txt - dependenciesassets/*.png - xterm.js evidence screenshots[64,1] is loaded for completeness but deterministic path uses mean only (SB3 predict with deterministic=True)