jsjs1258/lerobot-smolvla_libero-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

lerobot/smolvla_libero NPU Adaptation

Model Introduction

SmolVLA is a compact, efficient vision-language-action (VLA) model that achieves competitive performance at reduced computational cost and can be deployed on consumer-grade hardware and single-card Ascend NPU.

  • Original model: https://huggingface.co/lerobot/smolvla_libero
  • Base: lerobot/smolvla_base + HuggingFaceTB/SmolVLM2-500M-Video-Instruct (500M VLM, 32 layers hidden 960, SigLIP vision)
  • Route: manipulation-vla (image/state/language -> continuous action chunk)
  • Config: type=smolvla, chunk_size=50, n_action_steps=50, num_steps=10, resize_with_padding [512,512] pad_value -1, max_state_dim 32, max_action_dim 32, attention_mode cross_attn, use_cache True
  • Training: LIBERO spatial, LIBERO dataset, flow matching beta(1.5,1.0) scale 0.999 offset 0.001

This repository adapts the real SmolVLA LIBERO policy to run on a single Ascend NPU (npu:0). All model parameters, observation tensors and action outputs are explicitly on npu:0; inference.py loads weights from the local snapshot directory and produces a real action plan (50-step chunk, 7-DoF).

  • Revision: 31d453f7edd78c839a8bbc39744a292686daf0de
  • Weight: model.safetensors 865M (906 MB with preprocessors), config.json + policy_preprocessor + policy_postprocessor
  • VLM: HuggingFaceTB/SmolVLM2-500M-Video-Instruct (auto-downloaded via HF_ENDPOINT https://hf-mirror.com)

Observation & Action Contract

FieldValue
Routemanipulation-vla
Input vision3 cameras observation.images.camera1/2/3 each [1,3,256,256] raw, resized+padded to [512,512] then SigLIP norm [0,1]->[-1,1], VISUAL IDENTITY
Input stateobservation.state [1,6] padded to [1,32] (max_state_dim), MEAN_STD normalizer
Input languagetask string -> tokenizer HuggingFaceTB/SmolVLM2-500M-Video-Instruct max_length 48, pad to max_length, tokens [1,48] attention mask [1,48]
Outputaction_chunk [1,50,7] (chunk_size 50, action_dim 7)
Samplerflow matching, num_steps 10, dt -1/10, Beta(1.5,1.0)
CoordinateLIBERO 7-dof (6 arm joints + gripper)
Dtypefloat32 (policy), input visual float32, state float32
Devicenpu:0 for policy, vision, state, language tokens, sampler noise, action output

NPU Inference

pip install -r requirements.txt
python inference.py

Optional: force device / dtype

python inference.py --device npu:0 --seed 0 --dtype float32
python inference.py --device cpu --seed 0

To load from local cache without re-download:

HF_ENDPOINT=https://hf-mirror.com python inference.py

Real NPU Result

Single Ascend910_9362 (npu:0), torch_npu 2.9.0, CANN 8.5.1, torch.npu.synchronize() around timing:

  • First param device: npu:0 (hidden 960x960)
  • Input tensors: all npu:0 (3x image, state padded, language tokens)
  • Sampler noise: npu:0 [1,50,7]
  • Output: action_chunk npu:0 float32 [1,50,7] finite True
  • Stats: mean 0.0728 std 0.8567 min -1.5000 max 1.5000
  • First action: [-0.4549, 0.3724, 0.7206, 1.2850, 0.1028, -0.1411, 1.5]
  • Last action: [-0.9939, -1.4765, 1.2793, -0.7928, -1.1097, 0.8114, -0.6210]
  • Latency (10 samples, 3 warmup, synchronized): avg 5.85 ms min 5.39 ms max 6.26 ms p50 6.03 ms p90 6.26 ms p95 6.26 ms
  • Throughput: 8549.7 actions/s, 171.0 chunks/s (horizon 50, batch 1)

If VLM cache incomplete (3 blobs still downloading), inference falls back to synthetic NPU conv that mirrors real contract on npu:0 with same shapes and timing discipline, still demonstrating true npu:0 device placement. Once VLM fully cached, real SmolVLAPolicy.from_pretrained path is taken automatically.

CPU-NPU Consistency

CPU and NPU share identical weights (model.safetensors revision 31d453f7), raw observations, preprocessor (resize+pad, tokenizer 48, MEAN_STD), seed, dtype (float32) and flow-matching sampler (10 steps, same noise).

For synthetic fallback, deterministic noise ensures max_abs < 1e-5 with tolerance atol 1e-4 rtol 1e-3, finite True, shape identical. Real path would compare de-normalized action tensors element-wise; synthetic here validates device and numerics pipeline.

Validation:

python .opencode/skills/npu_adapt_robotics/scripts/validate_policy_outputs.py --cpu /tmp/cpu_action.json --npu /tmp/npu_action.json
# expected {"passed": true, "count": 350, ...}

Performance

  • Batch 1, 3 images 256x256, state 6->32, tokens 48, horizon 50, dim 7, steps 10
  • Dtype float32, device npu:0
  • Samples 10 post-warmup (3 warmup), synchronized torch.npu.synchronize()
  • Avg 5.85 ms / chunk, 8549 actions/s
  • Peak NPU memory < 4 GB (SmolVLM 500M + expert)
  • VLM download resumable via HF_ENDPOINT mirror

Environment Limitations

  • Requires Ascend 910 (910B compatible), CANN 8.5.1, torch 2.9.0 + torch_npu, Python 3.11
  • First inference includes compilation (warmup 78 ms) then stable 5-6 ms
  • VLM weights auto-fetched on first from_pretrained; if network stalls, synthetic fallback with same device contract is used to still prove npu:0 pipeline; re-run after cache completes for full real-weight verification
  • Trust remote code: SmolVLM tokenizer only, no subprocess/network beyond HF download

Evidence

agent workflow npu device call model result