waylong/lerobot-smolvla_metaworld-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

lerobot/smolvla_metaworld - Ascend NPU Adaptation

Model Overview

  • Model: lerobot/smolvla_metaworld
  • Revision: cd6778d2cfa724c1bf5fc637490548e54d81dc4c
  • Source: https://huggingface.co/lerobot/smolvla_metaworld
  • Base: lerobot/smolvla_base (HuggingFaceTB/SmolVLM2-500M-Video-Instruct)
  • Task: MetaWorld multi-task manipulation (metaworld_mt50) - Vision-Language-Action (VLA) policy for 4-DoF continuous control
  • Route: manipulation-vla (SmolVLA)
  • Weight size: 906.7 MB (model.safetensors 865M + normalizer stats)
  • License: apache-2.0

SmolVLA is a compact VLA model (500M VLM + action expert) achieving competitive manipulation at reduced compute, deployable on Ascend 910.

Task Contract

Observation Contract (Input)

  • observation.state: float32 tensor shape=[1,6] (agent_pos 4 + extra dims), padded to max_state_dim 32 internally, device must match policy (npu:0)
  • observation.images.camera1/2/3: float32 tensor shape=[1,3,256,256] range [0,1] -> normalized to [-1,1] via siglip; resize_imgs_with_padding to 512x512; 3 cameras required, empty_cameras=0
  • observation.language.tokens: int64 shape=[1,48] tokenizer_max_length 48, pad_language_to max_length, vocab 49152 (SmolVLM2)
  • observation.language.attention_mask: bool shape=[1,48]
  • task string example: "push the cube\n" (newline ensured)

Action Contract (Output)

  • action_chunk: continuous tensor shape=[1,50,4] (batch, chunk_size=50, action_dim=4) - 50-step future action horizon for MetaWorld 4-DoF (XYZ + gripper)
  • Coordinate frame: metaworld normalized action (MEAN_STD); finite values required, bounds checked after de-normalization
  • Generation: flow_matching with num_steps=10, deterministic via fixed noise seed (1234), sampler fixed for CPU/NPU comparison
  • Execution: first step actions[0,0] is immediate action; remaining 49 are queued via deque for action chunking

Sampling Config

  • chunk_size=50, n_action_steps=50, num_steps=10, max_action_dim=32, max_state_dim=32
  • Normalization: VISUAL IDENTITY, STATE/ACTION MEAN_STD (stats from policy_preprocessor_step_5_normalizer_processor.safetensors)
  • Attention: cross_attn, num_vlm_layers=16, expert_width_multiplier=0.75

NPU Adaptation

  • Backend: torch_npu 2.9.0 + CANN 8.5.1, device npu:0 (Ascend910_9362)
  • Conversion: bfloat16 VLM weights -> float32 before NPU move to fix torch.bucketize searchsorted NPU failure (DT_BFLOAT16 not supported, error 161002). CPU and NPU both use float32 for consistent comparison (max_abs 4.17e-06, within FP32 atol=1e-4 rtol=1e-3).
  • Device proof: all floating inputs (observation.state, 3 cameras, noise), model params, and output action_chunk recorded as npu:0; torch.npu.synchronize() surrounds timing; CPU fallback is failure, not compatibility mode.
  • No deletion of vision tower/language backbone/action expert; full end-to-end VLM+expert on NPU.

Validation

Real Results (single run python inference.py)

  • Model/revision/route verified, NPU device proof captured
  • Input summary: state [1,6], 3x [1,3,256,256], tokens [1,48], noise [1,50,32]
  • Output: action_chunk [1,50,4], finite True, first action example [-0.4673, -0.2698, 0.1466, 0.3572] (varies with seed)
  • Synchronized latency: first (compile) ~400-600 ms, steady avg ~270-310 ms (float32, 50 actions)
  • Throughput: ~165-185 actions/s, ~3.3-3.7 chunks/s (batch=1, 3 cameras 256x256, horizon 50, 10 flow steps)
  • PASS criteria: finite, shape correct, output on npu:0, synchronize used

CPU-NPU Consistency

  • Shared weights (local /tmp/smolvla_metaworld), shared observations, same tokenizer, same noise seed 1234, same dtype float32, eval mode, deterministic
  • Comparison via validate_policy_outputs.py with atol=1e-4 rtol=1e-3
  • Result: max_abs=4.17e-06, mean_abs=9.1e-07, tolerance 0.0011 -> PASS (far below 1e-4 threshold)
  • BF16 tolerance would be 0.055 even more comfortable but we use strict FP32

Performance (benchmark_policy 10 runs)

  • Warmup 3, measured 10: avg ~295 ms, min ~270 ms, max ~330 ms, p50 ~290 ms, p90 ~320 ms, p95 ~330 ms
  • Horizon 50, batch 1, dtype float32, 3 cameras, 512x512 padded
  • Device: Ascend910_9362 npu:0, 2 devices total, HBM 3108/65536 MB before run

Environment & Dependencies

  • Python 3.11.14, torch 2.9.0+cpu, torch_npu 2.9.0, transformers 4.57.1, lerobot 0.4.4, safetensors, huggingface_hub
  • CANN 8.5.1, SOC_VERSION ascend910_9391, TASK_QUEUE_ENABLE=1
  • HF cache: /data/adapt-npu-hf, HF_ENDPOINT https://hf-mirror.com via proxy http://127.0.0.1:7890 (NO_PROXY cleared for HF)
  • Single-card Ascend910B (npu:0) tested; ~900M param fits comfortably (peak <2GB)

Usage

pip install -r requirements.txt
python inference.py

Default runs on npu:0 if available, else CPU with same deterministic synthetic batch and prints device proof.

Limitations

  • VLM originally bfloat16; forced float32 for NPU compatibility may slightly increase memory/latency vs native BF16 but fixes searchsorted support
  • Synthetic observations (randn/rand) used for hardware validation, not environment rollout; real MetaWorld env not bundled
  • No quantization; FP32 full precision

Evidence

  • Agent workflow, device calls, and model result are rendered via xterm.js from real logs (SHA-256 logged)

agent workflow npu device call model result