atlasleong/ppo-pyramids-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

ppo-Pyramids Ascend NPU Inference

Model introduction

Nablaaa/ppo-Pyramids is a trained Unity ML-Agents PPO agent that plays the Pyramids environment. The upstream model is published on Hugging Face at https://huggingface.co/Nablaaa/ppo-Pyramids with library_name: ml-agents. The behaviour is a pure discrete-action policy: 172 vector observations, one discrete action branch of 5 actions, and two critic value streams (extrinsic and rnd). This repository reconstructs the exact policy network from the pinned ML-Agents checkpoint and executes a complete real forward on an Ascend NPU (npu:7) using torch_npu.

The reconstructed architecture is the minimal licensed subset of the official Unity ML-Agents PyTorch code pinned at 200fe54e14b649d6eac66a7f0779c1086c506919 (release_22) and vendored in ./mlagents_arch.

Environment dependencies

The container already provides the CANN-matched pair:

PackageVersionNote
torch2.9.0+cpupreinstalled, must not be replaced
torch_npu2.9.0preinstalled, must not be replaced
CANN8.5.1/usr/local/Ascend
numpy>=1.24,<2.0from Aliyun mirror only
Python3.11standard library + torch/torch_npu

Install application dependencies only from the Aliyun pip mirror, and never install or replace torch / torch_npu from ordinary PyPI:

pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt

The candidate uses the Python standard library, the preinstalled torch/torch_npu, numpy (result serialization), and the bundled mlagents_arch package. No mlagents training package is required.

Inference steps

The checkpoint is immutable:

ArtifactBytesSHA256
Pyramids/Pyramids-3778906.pt8656252cb012aae9673dfb05ddc1e4fc3a565b629a8aeb01ef5f08e7b4fa897fac41805

Local model layout (read-only source):

/work/pipeline/models/rl26/ppo-pyramids/
├── Pyramids/Pyramids-3778906.pt   # complete selected checkpoint
├── config.json                    # trainer/hyperparameter config
└── configuration.yaml             # trainer config (YAML)

Run the inference from the delivery directory on physical npu:7:

cd ppo-pyramids-npu
python3 inference.py --checkpoint /work/pipeline/models/rl26/ppo-pyramids/Pyramids/Pyramids-3778906.pt \
    --batch-size 4 --hold-seconds 12

Arguments:

ArgumentDefaultDescription
--checkpointlocal model pathimmutable .pt checkpoint
--batch-size4number of parallel observations
--hold-seconds12hold window for npu-smi PID correlation
--no-npu-smioffskip npu-smi capture
--resultlogs/npu_result.jsonoutput JSON path

The forward is fail-closed: if NPU is unavailable, placement differs from npu:7, or the strict checkpoint load fails, the process exits non-zero. There is no CPU model forward or fallback.

Complete test case and output

Deterministic test input: a redistributable all-zero synthetic tensor of shape [4, 172] (torch.float32) with a full-one action mask. Test-input source: deterministic synthetic all-zero tensor (redistributable, no external data); license: public domain / CC0-1.0.

Verified environment and contract (from the real run):

device                 : npu:7
hardware               : Ascend910B4-1
torch                  : 2.9.0+cpu
torch_npu              : 2.9.0
cann                   : 8.5.1
npu-smi                : npu-smi version: 25.5.1
contract               : obs_size=172 hidden_units=512 num_layers=2
                         discrete_branches=[5] continuous_size=0 memory_size=0
value_streams          : ['extrinsic', 'rnd']
strict_load_tensors    : 32  (actor=12 critic=8 rnd_pred=6 rnd_target=6)
input_device           : npu:7
model_device           : npu:7
output_device          : npu:7

Actual forward outputs (batch 4, all on npu:7):

logits_raw_branch0    : shape=[4, 5]  values=[-0.502707, 0.297161, 0.623955, 0.051701, -0.777674, ...]
logits_masked_branch0 : shape=[4, 5]  values=[-0.502707, 0.297161, 0.623955, 0.051701, -0.777674, ...]
action_sample         : shape=[4, 1]  values=[1, 3, 2, 0]
action_argmax         : shape=[4, 1]  values=[2, 2, 2, 2]
action_log_prob       : shape=[4]     values=[-1.049349, -1.376144, -1.049349, -1.049349]
entropy               : shape=[4]     values=[1.49365, 1.49365, 1.49365, 1.49365]
value_extrinsic       : shape=[4]     values=[0.448825, 0.448825, 0.448825, 0.448825]
value_rnd             : shape=[4]     values=[0.009599, 0.009599, 0.009599, 0.009599]
rnd_pred_encoding     : shape=[4, 64]
rnd_target_encoding   : shape=[4, 64]

Timing and acceptance (final real run):

forward_elapsed_s : 0.096063
elapsed_total_s   : 17.659
pid               : 23521
npu-smi (NPU 7)   : Process id:23521 python3 156 MB   -> PID correlated during hold
exit_code         : 0

Full sanitized raw log: logs/npu_inference.log; machine-readable evidence: logs/npu_result.json.

Test input source and license

The inference input is an in-memory all-zero synthetic vector of shape [4, 172]. It does not use any external dataset, protected content, or user data.

Limitations

  • This candidate runs the policy/value/RND forward only. It does not launch the Unity Pyramids simulator, Gym, a server, or robot hardware.
  • It reconstructs the policy from the checkpoint; it is not a training script.
  • The RND target encoder outputs are all-zero for the all-zero input, which is expected (the target is a fixed untrained network).
  • Ascend910 does not support float64; tensors are float32.

Screenshots

  • assets/agent_workflow.png — sanitized ModelAgent workflow (inspection → implementation → test → acceptance)
  • assets/modelagent_live_session.png — detailed sanitized ModelAgent interaction and final independent acceptance
  • assets/npu_device_call.png — real hardware/toolchain and NPU placement/process evidence
  • assets/model_result.png — actual final model output, elapsed time, and success status

Evidence locations

  • logs/npu_inference.log — sanitized raw inference log (includes npu-smi PID row)
  • logs/npu_result.json — structured result with engine, npu_available, npu_device_name, source_revision, input/model/output devices, output summary, timing and PID
  • SHA256SUMS — SHA-256 manifest of the delivery payload