This repository ports lerobot/diffusion_pusht (Diffusion Policy for PushT) to Huawei Ascend NPU (Ascend910) via torch_npu. The original model is a visuomotor diffusion policy trained on the PushT environment (gym-pusht) with LeRobot. All weights and configs are kept identical; only the runtime is moved from CUDA to npu:0.
lerobot/diffusion_pusht @ 84a7c23178445c6bbf7e1a884ff497017910f653demonstration-policy (LeRobot DiffusionPolicy, ACT/Diffusion family)image (96×96 RGB) + state (2D agent_pos) → continuous action chunk (horizon 16, executed 8 steps, dim 2)resnet18 (GroupNorm, 32 keypoints SpatialSoftmax) + DiffusionConditionalUnet1d (down_dims 512,1024,2048, kernel 5, diffusion_step_embed_dim 128, FiLM) + DDPM 100 steps (squaredcos_cap_v2, clip_sample True range 1.0)npu:0 with torch.npu.synchronize() timing, CPU vs NPU numerically compared (same local snapshot, same synthetic observation, same noise seed 999, same scheduler). See evidence.Input (per step):
observation.state: [B,2] or [B,n_obs_steps,2] float32 agent xy in MIN_MAX normalized rangeobservation.image: [B,3,96,96] float32 RGB in [0,1] (preprocessor will center-crop to 84×84)observation.state [B,n_obs_steps,2] and observation.images [B,n_obs_steps,1,3,96,96]Output:
action_chunk: [B, n_action_steps, 2] float32 (horizon 16 sliced to 8). Values in normalized action space (clip to [-1,1]), corresponds to delta xy for the pusher. Shape/dtype/device/sampler are logged.python inference.py
# loads DiffusionPolicy.from_pretrained(local_snapshot) -> npu:0, runs generate_actions with fixed noise
# prints model/revision, route, backend, device, dtype, input summary, action summaries, synchronized latency, PASS/FAILNo manual http_proxy handling required – HF_ENDPOINT=https://hf-mirror.com is respected via env.
/opt/atomgit/adapt-npu-agent/.cache_hf/models--lerobot--diffusion_pusht (model.safetensors 1.0GB)B=1, n_obs_steps=2 – state ~ N(0,1) seed 0, images ~ U(0,1), noise ~ N(0,1) seed 999, shape [1,16,2][-1.0, 0.7120] last_action [-1.0, 0.6949] mean -0.1533 std 0.8747 shape [1,8,2] finite true[-1.0, 0.7265] last_action [-1.0, 0.6761] mean -0.1556 std 0.8724 shape [1,8,2] device npu:0 finite truenpu_first_param device=npu:0, noise device=npu:0, output device=npu:0, global_cond on NPUmax_abs=0.018759 mae=0.00457 tolerance=0.055 (atol 5e-3 rtol 5e-2, max_ref 1.0) → PASS via validate_policy_outputs.pyNPU device call and model results are rendered from real logs (no mock):
npu-smi info shows 2×Ascend910 devices, test used Ascend910_9362 on npu:0 (Phy-ID 2, Bus 0000:0A:00.0)torch.npu.is_available()==True, device_count=2, get_device_name(0)=Ascend910_9362, first param / inputs / sampler noise / output all on npu:0torch.npu.synchronize() around each generate_actions call

num_inference_steps (e.g., to 10 via DDIM) drastically speeds up but changes the action distribution; this port keeps the original 100-step schedule for fidelity.use_amp=False, pretrained_backbone_weights=None.normalize_inputs/unnormalize_outputs buffers from the checkpoint are warnings on load (unknown keys) – the diffusion core itself runs in normalized space; the wrapper normalizer is handled at dataset level and does not affect this single-step synthetic validation.