waylong/ai_final_12_act_2-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

MidoriChou/ai_final_12_act_2 - Ascend NPU Adaptation (ACT)

Model Overview

  • Base model: MidoriChou/ai_final_12_act_2 (https://huggingface.co/MidoriChou/ai_final_12_act_2)
  • Revision: 92654eb0e3f9ee4329d54a599165aeb12512e92f
  • Type: act (Action Chunking with Transformers) via lerobot ACTPolicy
  • Route: demonstration-policy (LeRobot policy predicting continuous action chunks)
  • Task: Robot manipulation via imitation learning - predicts 100-step action chunks from vision+state
  • License: apache-2.0

Observation & Action Contract

  • Input features (from config.json):
    • observation.state: STATE, shape (9,) - 9-DoF robot proprioception
    • observation.images.wrist: VISUAL, shape (3, 480, 640) - wrist camera RGB
    • observation.images.front: VISUAL, shape (3, 480, 640) - front camera RGB
    • n_obs_steps: 1 (single timestep observation)
  • Output features:
    • action: ACTION, shape (8,) per step, chunk_size=100, n_action_steps=100
    • Output tensor shape: (batch=1, horizon=100, action_dim=8)
    • Normalization: MEAN_STD for VISUAL/STATE/ACTION (via policy_preprocessor_step_3_normalizer)
  • Backbone: ResNet18 (IMAGENET1K_V1) + Transformer (dim_model=512, n_heads=8, dim_feedforward=3200, n_encoder_layers=4, n_decoder_layers=1, use_vae=True, latent_dim=32)
  • Weight size: 198 MB (model.safetensors) + 7.6K normalizer stats, 51.6M parameters

NPU Adaptation

  • Device: npu:0 Ascend910_9362 (2 devices available, using 0)
  • Framework: torch 2.9.0 + torch_npu + lerobot 0.4.4
  • Loading: ACTPolicy.from_pretrained("/tmp/MidoriChou_ai_final_12_act_2") then .to(torch.device("npu:0")) - no code rewrite, no CPU fallback, all params/images/actions on NPU
  • Dtype: float32 (policy config use_amp=False)
  • Synchronization: torch.npu.synchronize() before/after each timed forward for accurate latency
  • Inference entry: predict_action_chunk(batch) with deterministic zero latent (eval mode, use_vae=True but training=False => latent zeros, no sampling randomness)

Real Results (NPU)

  • First action (step 0): e.g. [2.706, -1.127, 1.122, -0.928, -0.434, -0.628, 0.777, -0.630] (validation batch seed 42, mean 0.106)
  • Full chunk: shape (1,100,8), finite True, min ~ -1.13, max ~2.81, horizon 100 validated
  • Device proof: policy param device: npu:0, input state device: npu:0, output device: npu:0 - see assets/npu_device_call.png
  • NPU compilation: first call includes graph compilation (~23ms), stabilized after 3 warmup iterations

CPU-NPU Consistency

  • Method: Identical batch (seed 42, same preprocess, same dtype) run on CPU (cpu) and NPU (npu:0), compare flattened 800 values (100*8)
  • Threshold: FP32 atol=1e-4, rtol=1e-3 => tolerance 2.918e-03
  • Result: max_abs=1.35e-03, max_ref=2.818, finite=True, count=800 => PASS (within tolerance)
  • Validation command: python scripts/validate_policy_outputs.py --cpu cpu.json --npu npu.json => {"passed": true}
  • Details: Action dimensions, horizon, finite checks all PASS, no CPU fallback

Performance (NPU, synchronized)

  • Timing: 10 samples after 3 warmup, torch.npu.synchronize() bounded
    • avg_ms: 23.42, min: 22.78, max: 23.85, p50: 23.49, p90: 23.79, p95: 23.85
    • actions_per_s: 4269, chunks_per_s: 42.7 (100 actions per chunk, batch 1)
  • Benchmark: python scripts/benchmark_policy.py --latencies-ms latencies.json --items-per-call 100 --unit actions => avg 23.42ms
  • Second run (inference.py): avg 23.23ms, actions/s 4305, consistent
  • Config: batch 1, 2 cameras 480x640, float32, npu:0, includes preprocess not included separately

Environment & Limitations

  • Hardware: Ascend910_9362, 2 NPUs, 64GB HBM, tested on npu:0
  • Software: CANN 8.5.1, torch 2.9.0+cpu, torch_npu 2.9.0.post1, Python 3.11, lerobot 0.4.4, diffusers, huggingface_hub 0.34.4
  • Constraints: Single-card only, 198MB weights fit easily (< 1GB peak), no multi-NPU needed
  • Not covered: Closed-loop rollout/env reward not measured - single-step chunk validation only per skill

Usage

pip install -r requirements.txt
python inference.py  # auto-selects npu:0 if available, else cpu

Expected output: model/revision/route/backend/device/dtype, input summary, synchronized latencies, action chunk summary, PASS/FAIL.

Evidence

  • Workflow (recon, load, NPU inference, consistency, performance): assets/agent_workflow.png
  • NPU device calls (npu-smi, torch.npu.is_available, param/input/output device): assets/npu_device_call.png
  • Model result (python inference.py on NPU): assets/model_result.png

All three PNGs rendered from real UTF-8 logs via xterm.js with SHA256 verification.

References

  • Policy paper: https://huggingface.co/papers/2304.13705
  • LeRobot docs: https://huggingface.co/docs/lerobot/index
  • Original weights: https://huggingface.co/MidoriChou/ai_final_12_act_2