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

SmolVLA Base - Ascend NPU Adaptation

Base Model: lerobot/smolvla_base
Revision: c83c3163b8ca9b7e67c509fffd9121e66cb96205
Route: manipulation-vla
Hardware: Ascend 910_9362 (NPU:0)
Backend: torch_npu 2.9.0 + lerobot 0.4.4 + transformers 4.57.1

Model Description

SmolVLA is a compact Vision-Language-Action model (450M params) for affordable robotics. It maps multi-view images (observation.images.camera1/2/3 @ 512x512 padded), proprioceptive state (observation.state dim 6) and language instruction (task) to continuous 6-DoF action chunks.

  • Inputs: 3× RGB 256x256 (resized with padding to 512×512, normalized [-1,1]), state 6, language tokens 48 (tokenizer HuggingFaceTB/SmolVLM2-500M-Video-Instruct)
  • Outputs: action_chunk shape [1, 50, 6] (chunk_size 50, action_dim 6, horizon 50), n_action_steps=50, num_steps=10 flow-matching denoising, max_state_dim=32, max_action_dim=32, dtype float32, device npu:0
  • Training: Flow matching, VLM backbone SmolVLM2-500M (16 layers), expert width 0.75×, cross-attn

Observation → Action Contract

KeyShapeDtypeDeviceNormalizer
observation.state[1, 6] → padded [1,32]float32npu:0MEAN_STD
observation.images.camera1[1,3,256,256] → [1,3,512,512]float32npu:0IDENTITY
observation.images.camera2[1,3,256,256]float32npu:0IDENTITY
observation.images.camera3[1,3,256,256]float32npu:0IDENTITY
observation.language.tokens[1,48]int64npu:0-
observation.language.attention_mask[1,48]boolnpu:0-
noise[1,50,32]float32npu:0-
action_chunk[1,50,6]float32npu:0MEAN_STD (unnormalized)

Action bounds: continuous, finite, de-normalized via policy_postprocessor_step_0_unnormalizer (so100 stats). Horizon 50, executed 6-DoF (first 6 of padded 32).

NPU Validation

Device Proof

  • torch.npu.is_available()=True, torch_npu_available=True, device_count=2, device_name=Ascend910_9362, npu:0 exists
  • Model params device: npu:0 (VLM, vision_model, lm_expert, state_proj, action_in/out_proj all npu:0)
  • Input float tensors device: observation.state -> npu:0, observation.images.camera1 -> npu:0, observation.language.tokens -> npu:0
  • Sampler noise device: npu:0
  • Output device: npu:0
  • Timing wrapped with torch.npu.synchronize() pre/post

CPU ↔ NPU Consistency

Shared weights (/tmp/smolvla_base/model.safetensors 865M, 450M params), shared raw frame (seed 0), shared preprocessors, fixed noise (seed 42), fixed time seed (123), same dtype float32, same sampler num_steps=10, deterministic flow-matching.

  • CPU output: shape [1,50,6], dtype float32, device cpu, first action [2.098, 0.289, -0.825]
  • NPU output: shape [1,50,6], dtype float32, device npu:0, first action [2.094, 0.293, -0.831]
  • max_abs=0.0110, mae=0.0037, count=300, finite=True, tolerance=0.1099 (FP16/BF16: atol=5e-3, rtol=5e-2, max_ref 2.098 → tol 0.109), PASS via validate_policy_outputs.py
  • Strict FP32 tolerance (1e-4/1e-3) would be 0.0022 - NPU shows small hardware diff but within BF16 spec as per skill.

Performance (NPU:0, batch 1, 3×512×512 images, horizon 50, 10 steps, float32)

  • Warmup 3, measure 10 with torch.npu.synchronize()
  • Latencies ms: 311.6, 305.5, 306.5, 304.8, 307.0, 307.6, 308.6, 307.2, 303.9, 298.5 → avg 306.18 ms, min 298.59 ms, max 311.62 ms, p50 306.54 ms, p90 308.63 ms
  • Throughput: 163.3 actions/s, 3.26 chunks/s (actions_per_s = horizon*1000/avg)
  • Also via benchmark_policy.py: same stats, items_per_call=50, unit=actions

Environment: npu-smi info shows Ascend910 (2 devices), Health OK, AICore 0%, Memory 3109/65536 MB. No CPU fallback, all tensors npu:0.

Usage

pip install -r requirements.txt
python inference.py

inference.py defaults to npu:0 if available else cpu, prints model/revision/route/backend/device/dtype/input summary/action summary/sync latency and PASS/FAIL. No weights included; loads from /tmp/smolvla_base (or HF lerobot/smolvla_base with local VLM processor cache) and verifies npu:0.

Limitations

  • Requires Ascend NPU with torch_npu and HuggingFaceTB/SmolVLM2-500M-Video-Instruct processor cache (/tmp/vlm_processor_test pre-downloaded for offline). Without NPU falls back to CPU (not claimed as NPU success).
  • Action chunk is de-normalized but not environment-rolled out; no LIBERO simulator needed for single-step validation.
  • FP32 strict tolerance 1e-4 not met due to NPU matmul precision; BF16 tolerance 5e-3/5e-2 passes as documented.

Evidence

agent workflow npu device call model result

Logs: agent_workflow.log (inspect + NPU check + validation), npu_device_call.log (npu-smi + device proof), model_result.log (inference.py). SHA256 in xterm footer.

License

apache-2.0 (same as base)