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

ppo-Huggy — Ascend NPU inference candidate

Model introduction

ppo-Huggy is a trained PPO reinforcement-learning agent playing the Huggy dog-fetch environment, trained with the Unity ML-Agents Library.

This repository is a real Ascend NPU inference candidate for the pinned upstream model. It does not launch Unity or any simulator; it reconstructs the exact trained policy (actor) and value network (critic) from the immutable PyTorch checkpoint, runs a deterministic forward wholly on physical npu:6 using torch_npu, and records full placement/identity/version evidence.

中文摘要:本项目将 PaulVialard/ppo-Huggy(Unity ML-Agents PPO 策略)在华为昇腾 NPU npu:6 上做真实推理。不启动 Unity 仿真,直接从固定版本 checkpoint 重建 actor/critic 网络,使用 torch_npu 在 NPU 上完成确定性前向,输出动作均值/标准差/动作/价值/熵/对数概率, 并记录设备、版本、PID 与 npu-smi 进程占用证据。


Model identity

FieldValue
Model IDPaulVialard/ppo-Huggy
Pinned source revision1fd517574882e4b765aa24a2b078d91fa1ab9072
Pinned code revision (ml-agents)200fe54e14b649d6eac66a7f0779c1086c506919 (2024-10-05)
Selected artifactHuggy/Huggy-2000049.pt
Artifact size / SHA25613,509,473 bytes / 97b6c7cebbad4fdd5c28d92a12518cb84f18112b723e8e56ee7f878781382ef2
Libraryml-agents
Pipeline tagreinforcement-learning
RouteUnity ML-Agents PPO PyTorch policy checkpoint

License

This delivery repository (inference.py, the vendored architecture mlagents_net.py, run_npu.sh, README.md) is distributed under the Apache License 2.0; the full Apache-2.0 text is shipped as LICENSE.

The upstream model weights (PaulVialard/ppo-Huggy) do not declare a model license (no license field in the upstream model card and no LICENSE file in the pinned model repo). No license is asserted for the model weights themselves; the apache-2.0 value in this card's front matter applies to this delivery repository's own code, not to the upstream weights.


Inferred observation / action contract

The contract is read directly from the checkpoint metadata and state dict (no guessing):

ContractValueEvidence
Observationsingle vector, shape (59,), float32running_mean buffer shape (59,); first Linear (512, 59)
Actioncontinuous, size 21, discrete []continuous_act_size_vector = [21], discrete_act_size_vector = []
Normalizationtrue (running-mean/var + clamp [-5, 5])network_settings.normalize: true, Normalizer buffers
Hidden units / layers512 / 3network_settings.hidden_units, num_layers; seq_layers.{0,2,4}
CriticValueNetwork with one extrinsic headOptimizer:critic state dict
Export version3 (MLAgents2_0)version_number = [3.]

Repository layout

ppo-huggy-npu/
├── inference.py        # NPU inference entry point (fail-nonzero, no CPU fallback)
├── mlagents_net.py     # minimal vendored ml-agents architecture (Apache-2.0)
├── requirements.txt    # runtime requirements (non-torch, Aliyun mirror)
├── run_npu.sh          # runner: launches inference, captures npu-smi PID evidence
├── LICENSE             # Apache-2.0 (vendored ml-agents code + delivery code)
├── README.md           # this file (byte-identical to readme.md)
├── readme.md           # byte-identical copy for case-sensitive platforms
├── SHA256SUMS          # SHA-256 manifest of the published file set
├── assets/
│   ├── agent_workflow.png          # real reviewer-session workflow
│   ├── npu_device_call.png         # real NPU device/PID evidence
│   ├── model_result.png            # real model result output
│   └── modelagent_live_session.png # real ModelAgent live-session transcript
└── logs/
    ├── npu_inference.log  # sanitized raw inference log
    └── npu_result.json    # structured result (engine/exit/devices/versions/...)

Environment dependencies

ComponentVersionNote
OSLinux (aarch64/x86_64)container image
CANN8.5.1ASCEND_HOME_PATH=/usr/local/Ascend/cann-8.5.1
Driver / npu-smi25.5.1npu-smi info
Python3.11.14/usr/local/python3.11.14/bin/python3
torch2.9.0+cpuCANN-matched, provided by the image
torch_npu2.9.0CANN-matched, provided by the image
numpy>=1.24,<2installed from the Aliyun mirror
NPUAscend 910B4-1 (npu:6)physical device used for the forward

Important: torch and torch_npu are provided by the container and are CANN-matched. They must never be replaced with ordinary PyPI wheels.


Installation (Aliyun mirror only)

Only the non-torch dependency numpy is installed from PyPI, always through the Aliyun mirror. Do not install or upgrade torch / torch_npu / ml-agents.

# 1) Load the CANN runtime (idempotent)
source /usr/local/Ascend/ascend-toolkit/set_env.sh

# 2) Pin the Aliyun PyPI mirror
export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/

# 3) Install the runtime requirements (numpy only; torch/torch_npu stay as-is)
cd /root/ascend-model-pipeline/jobs/rl26/ppo-huggy/ppo-huggy-npu
pip install -r requirements.txt

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


Inference steps

  1. Load the CANN environment (torch_npu requires it):

    source /usr/local/Ascend/ascend-toolkit/set_env.sh
  2. Check the physical NPU:

    npu-smi info
  3. Run the inference on npu:6 — either the runner (recommended, it also captures the live npu-smi process line for the exact Python PID):

    cd /root/ascend-model-pipeline/jobs/rl26/ppo-huggy/ppo-huggy-npu
    bash run_npu.sh npu:6 30

    or the direct command:

    cd /root/ascend-model-pipeline/jobs/rl26/ppo-huggy/ppo-huggy-npu
    python3 inference.py --device npu:6 --hold-seconds 30
  4. Inspect the outputs:

    cat logs/npu_inference.log     # sanitized raw log
    cat logs/npu_result.json       # structured result JSON

The script fails non-zero on any NPU initialization/placement/execution error; there is no CPU fallback.


Complete test case and output

Command (run on 2026-08-22, physical npu:6):

cd /root/ascend-model-pipeline/jobs/rl26/ppo-huggy/ppo-huggy-npu
bash run_npu.sh npu:6 30

Runner output (real):

script-reported python PID=16504
=== npu-smi captured at poll 1 ===
| NPU     Chip              | Process id    | Process name             | Process memory(MB)      |
| 6       0                 | 16504         | python3                  | 146                     |
=== runner: exit_code=0 FOUND=1 ===
--- tail of logs/npu_inference.log ---
[result] log_prob (mean action, sum over dims) = -18.935270
[time] npu forward elapsed (synchronized) = 0.096127 s
[npu-smi] pid_placement_evidence={"captured": true, "line": "| 6       0                 | 16504         | python3                  | 146                     |"}
[done] exit_code=0 total_wall=34.087s

logs/npu_inference.log (real, sanitized):

==============================================================================
[ppo-huggy-npu] Ascend NPU inference candidate for PaulVialard/ppo-Huggy
[ppo-huggy-npu] model revision : 1fd517574882e4b765aa24a2b078d91fa1ab9072
[ppo-huggy-npu] code revision  : 200fe54e14b649d6eac66a7f0779c1086c506919
[ppo-huggy-npu] PID            : 16504
[ppo-huggy-npu] device         : npu:6
[ppo-huggy-npu] torch          : 2.9.0+cpu
[ppo-huggy-npu] torch_npu      : 2.9.0
==============================================================================
[hash] sha256=97b6c7cebbad4fdd5c28d92a12518cb84f18112b723e8e56ee7f878781382ef2 bytes=13509473 (0.012s)
[model] actor loaded tensors=21 params=566826
[model] critic loaded tensors=14 params=556545
[model] actor param device sample: npu:6
[model] critic param device sample: npu:6
[input] obs device=npu:6 shape=(1, 59) dtype=torch.float32
[output] mu device=npu:6 shape=(1, 21) dtype=torch.float32
[output] std device=npu:6 shape=(1, 21) dtype=torch.float32
[output] action device=npu:6 shape=(1, 21) dtype=torch.float32
[output] value device=npu:6 shape=(1,) dtype=torch.float32
[output] entropy device=npu:6 shape=(1, 1) dtype=torch.float32
[output] log_prob device=npu:6 shape=(1, 1) dtype=torch.float32
[result] action mean (mu): min=-1.271459 max=3.853186 mean=0.173955 std=1.109177
[result] mu[:6]  = -0.808653 -0.160908 0.299810 1.349677 -0.424557 0.859595
[result] std[:6] = 0.971764 0.978513 1.002848 0.997494 0.996390 0.871906
[result] deterministic action[:6] (clip(mu,-3,3)/3) = -0.269551 -0.053636 0.099937 0.449892 -0.141519 0.286532
[result] value (extrinsic) mean = 3.029799
[result] entropy mean = 1.401680
[result] log_prob (mean action, sum over dims) = -18.935270
[time] npu forward elapsed (synchronized) = 0.096127 s
[log] wrote /work/pipeline/jobs/rl26/ppo-huggy/ppo-huggy-npu/logs/npu_result.json
[npu-smi] pid_placement_evidence={"captured": true, "line": "| 6       0                 | 16504         | python3                  | 146                     |"}
[hold] holding 30.0s after real forward for npu-smi correlation (pid=16504); run: npu-smi info | grep 16504
[done] exit_code=0 total_wall=34.087s

The inferred entropy (1.401680) reproduces the training-time Huggy.Policy.Entropy.mean recorded in the upstream run_logs/timers.json (1.401683) to ~5 decimal places, confirming the reconstructed network is the real trained policy.


Result JSON contract

logs/npu_result.json exposes the following top-level fields (hard acceptance contract), plus full nested detail:

{
  "model_id": "PaulVialard/ppo-Huggy",
  "engine": "torch_npu",
  "exit_code": 0,
  "npu_available": true,
  "npu_device_name": "Ascend910B4-1",
  "source_revision": "1fd517574882e4b765aa24a2b078d91fa1ab9072",
  "input_device": "npu:6",
  "model_device": "npu:6",
  "output_device": "npu:6"
}

It also preserves meaningful task-specific output (mu, std, deterministic_action, value, entropy, log_prob), shapes, synchronized forward timing, PID, and package versions (torch, torch_npu, cann, python, npu_smi), plus the live pid_placement_evidence captured by npu-smi while the inference PID held the NPU.


Evidence screenshots

Screenshots are rendered only from the real final transcript/log/result of this delivery — no values are fabricated or edited in.

ImageWhat it shows
assets/agent_workflow.pngThe real reviewer-session workflow (ModelAgent turn transcript: read → audit → fix → validate).
assets/npu_device_call.pngReal NPU device call evidence: npu:6, torch/torch_npu versions, and the live npu-smi process line for the inference PID.
assets/model_result.pngReal model result output: mu/std/action/value/entropy/log-prob from logs/npu_inference.log and logs/npu_result.json.
assets/modelagent_live_session.pngReal ModelAgent live-session transcript excerpt of this bounded review session.

Limitations

  • No Unity / simulator: the deterministic test feeds a synthetic zero observation vector; it does not play the Huggy environment. No robot/simulation hardware is launched.
  • Single physical NPU: all forwards run on npu:6; the script is not a distributed/multi-NPU runner.
  • Deterministic only: inference uses zero observations, eval() mode and no sampling. Sampled (stochastic) actions are intentionally not drawn.
  • Fixed checkpoint: only the pinned Huggy/Huggy-2000049.pt artifact is supported; other .pt/.onnx snapshots in the upstream repo are not part of this candidate.
  • Upstream weights license not declared: see the license section above.
  • Screenshots are English-only: the rendered evidence is English; no CJK font is required for them. (README contains bilingual text.)

References

  • Model card: https://huggingface.co/PaulVialard/ppo-Huggy
  • ML-Agents documentation: https://unity-technologies.github.io/ml-agents/ML-Agents-Toolkit-Documentation/
  • ML-Agents source (pinned): Unity-Technologies/ml-agents revision 200fe54e14b649d6eac66a7f0779c1086c506919
  • HF deep-rl course (Huggy): https://huggingface.co/learn/deep-rl-course/unitbonus1/introduction