This is an Ascend NPU-adapted deployment for HumanCompatibleAI/ppo-seals-CartPole-v0 (PPO on seals/CartPole-v0, reinforcement-learning).
a86541dd3744275227cb16d07192967fc6b7775eMlpPolicy with net_arch pi:[64,64] vf:[64,64] ReLU, discrete 2-action, obs dim 4offline-rl (PPO discrete decision, closest to Decision Transformer contract: state→action, horizon=1)npu:0 with synchronized timing and CPU-NPU consistency validationseals/CartPole-v0 discrete control (CartPole observations: cart position, cart velocity, pole angle, pole angular velocity)Model and tensors are explicitly placed on npu:0 and verified:
next(extractor.parameters()).device == npu:0action_net.weight.device == npu:0input obs Tensor device == npu:0logits device == npu:0, value device == npu:0, action device == npu:0Synchronization uses torch.npu.synchronize() before/after timing.
[0.01369617, -0.02302133, -0.04590265, -0.04834723]):
[[2.3415, -2.3408], ...] batch=4, shape [4,2][0, ...]~2.3e-07 (< 1e-4 + 1e-3*max), value diff <1e-3policy.pth 40,641 bytes), 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
# Load weights from HuggingFace (model_weight_url) or local policy.pth
ckpt = torch.load("policy.pth", map_location="cpu")
# Build extractor + heads as in inference.py and move to npu:0
# obs: tensor shape [B,4] float32
# logits = action_net(extractor.policy_net(obs)) -> probs -> action = argmaxSee 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