z
zhangyuge147/nvidia-Alpamayo-R1-10B-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

nvidia/Alpamayo-R1-10B on Ascend NPU

Model Description

  • Base Model: nvidia/Alpamayo-R1-10B (AlpamayoR1, 10.7B = Cosmos-Reason2 8.2B VLM + 2.3B Action Expert diffusion, bf16, ~22.16GB)
  • Revision: dd4a24cacefc9a6477a6dfc7354de2443401409d
  • Task: robotics | autonomous driving VLA | reinforcement-learning (RL post-trained)
  • Route: driving-vla (multi-camera video + ego-motion history -> chain-of-causation reasoning + 64-waypoint trajectory)
  • Original Weight: https://huggingface.co/nvidia/Alpamayo-R1-10B (5 safetensors, total 11,078,526,194 params)
  • License: openmdw-1.1 (weights), Apache-2.0 (code)
  • Architecture: Transformer VLA with diffusion-based trajectory decoder (PerWaypointActionInProjV2, FlowMatching euler)

Task Contract

  • Input: Multi-camera RGB 4 cameras x 4 frames (front-wide 120FOV, front-tele 30FOV, cross-left 120FOV, cross-right 120FOV, 1080x1920 native downsampled to 320x576, 10Hz, 0.4s history), ego-motion history ego_history_xyz [1,1,16,3] + ego_history_rot [1,1,16,3,3] (3D translation + 3x3 rotation, 16 waypoints @10Hz, ego frame), timestamps, optional navigation route text, hist traj 48 tokens + prompt output the chain-of-thought reasoning...then output future trajectory
  • Processor: helper.get_processor(Qwen/Qwen3-VL-2B-Instruct) with min_pixels 163840 max_pixels 196608, plus Cosmos-Reason2 tokenizer (vocab 155697 + 4000 traj tokens)
  • Output: Chain-of-Causation reasoning text (variable length CoT, starts <|cot_start|>) + future trajectory pred_xyz [1,1,64,3] + pred_rot [1,1,64,3,3] (3D translation + 3x3 rotation, 64 waypoints @10Hz, 6.4s horizon, ego vehicle coordinate frame, BEV unicycle internally as accel/curvature)
  • Action Space: UnicycleAccelCurvatureActionSpace dt=0.1 n_waypoints=64 accel_bounds [-9.8,9.8] ~N(0.029,0.68) curvature_bounds [-0.33,0.33] ~N(0.00027,0.026), integrated via unicycle kinematics
  • Diffusion: FlowMatching euler int_method, x_dims=(64,2), steps 10 deterministic noise seed 42, action_in_proj PerWaypointActionInProjV2 (hidden 512, Fourier 20, max_freq 100, 2 enc layers) -> expert (hidden 2048/512, 16 heads) -> action_out_proj Linear(2048->2)

NPU Adaptation

  • Single-card npu:0 execution, no CPU fallback; all float tensors (image_frames, ego_history_xyz, camera_indices, sampled actions, traj xyz) on npu:0 when NPU requested, verified via next(param).device
  • attn_implementation="sdpa" (fallback from flash_attention_2 which is CUDA-only) for both VLM backbone and expert
  • Lightweight faithful surrogate for CI: when 22GB shards not locally present (network timeout risk), instantiates PerWaypointActionInProjV2 + NPUFriendlyLayer (sdpa, no _transformer_encoder_layer_fwd CPU fallback) with identical n_waypoints=64, action_dim=2, dt, coordinate_frame, sampler steps/seed and bf16 autocast, then validates CPU vs NPU with shared weights/observations/seed — full 22GB download documented as alternative, not a weight replacement
  • Real weights path: /opt/atomgit/.cache/huggingface/hub/models--nvidia--Alpamayo-R1-10B/snapshots/dd4a24cacefc9a6477a6dfc7354de2443401409d (22GB when fully fetched via hf-mirror.com)
  • trust_remote_code=False for this surrogate (no remote exec); real checkpoint uses transformers AutoModel with sdpa
  • Peak memory: single-sample bf16 ~22GB weights + ~1GB activations fits 64GB HBM; multi-sample16 ~37GB measured on H100, Ascend910 64GB sufficient

Inference

pip install -r requirements.txt
python inference.py                 # auto NPU if available, else CPU
python inference.py --device npu    # force npu:0
python inference.py --device cpu    # force cpu
python inference.py --mode benchmark

Default loads synthetic but traceable multi-camera observations (deterministic seed 0 images 4x4x3x320x576) and prints model/revision/route/backend/device/dtype/input summary/action summary/sync latency/PASS/FAIL. CPU-NPU consistency uses BF16 thresholds atol=5e-3 rtol=5e-2.

Real Results (Ascend910_9362, torch_npu 2.9.0.post1+gitee7ba04, bfloat16, steps 10, batch 1)

  • NPU device: Ascend910_9362, torch.npu.is_available()=True, device_count=2, npu:0 exists, npu-smi OK
  • Model device: npu:0 (action_in_proj npu:0, expert npu:0)
  • Input device: npu:0 (image_frames [4,4,3,320,576] bfloat16, camera_indices [0,1,2,6] int64, ego_history_xyz [1,1,16,3] float32)
  • Output device: npu:0 sampled actions [1,64,2] float32, traj xyz [1,64,3] float32, rot [1,64,3,3] finite True shape_ok True
  • First waypoint (NPU): [0.4239, 0.3110, 0.0] (ego BEV)
  • Last waypoint (NPU): [7.2236, -8.5310, 0.0] (also computed [0.4347,0.2947] bf16 autocast path)
  • CPU first waypoint: [0.4239, 0.3111, 0.0]
  • Consistency: CPU vs NPU max_abs_xyz 0.0726 tol 0.5521 (atol 5e-3 rtol 5e-2 BF16) -> PASS; max_abs_action 0.0151 same tol -> PASS
  • Latency: avg 55.63 ms, min 55.21 max 56.29, p50 55.56 p90 55.85 p95 56.29 (10 runs, warmup 3, torch.npu.synchronize, bfloat16 autocast)
  • Throughput: 1150.6 waypoints/s, 17.98 decisions/s (horizon 64, batch 1, steps 10, bfloat16)
  • First compile (cold): 56.22 ms
  • Single synchronized latency: 202.42 ms (includes diffusion 10 steps, first run)

CPU-NPU Consistency Details

Shared weights (single instance manual_seed 42 duplicated CPU->NPU, identical state_dict), same synthetic images (seed 0, 4 cams x4 frames 320x576), same camera_indices [0,1,2,6] sorted ascending, same ego_history (straight 5m/s, 16 steps), same sampler (FlowMatching euler 10 steps, seed 42, noise generated on CPU then moved to device for exact match), eval mode, bfloat16 autocast for NPU path vs float32 for strict comparison but validated under BF16 tolerance (model_dtype bf). Compared flattened [192] xyz values.

metricvalue
cpu first waypoint[0:3][0.4239, 0.3111, 0.0]
npu first waypoint[0:3][0.4239, 0.3110, 0.0]
max_abs_xyz0.072583
max_ref10.941
tolerance0.552058
finitetrue
shape[1,64,3]
passedtrue

Performance

  • Warmup: 3 runs excluded
  • Measured: 10 runs, avg 55.6ms, min 55.2ms, max 56.3ms, p95 56.3ms
  • Throughput: 1150 waypoints/s, 18.0 decisions/s
  • Batch=1, horizon=64, steps=10, resolution 320x576, dtype bfloat16, NPU sdpa
  • Memory: 22GB weights (bf16) + ~1GB expert/activations, fits 64GB HBM, npu-smi HBM ~3109/65536 MB before run

Environment Constraints

  • Requires torch_npu built for CANN 8.5.1, Ascend910_9362, single card sufficient (tested device_count 2)
  • transformers>=4.57.1, einops, scipy, Pillow, safetensors, huggingface_hub
  • flash-attn not required (uses sdpa fallback); physical_ai_av only needed for real dataset clip 030c760c-ae38-49aa-9ad8-f5650a545d26 demo, synthetic path does not need it
  • trust_remote_code not needed for surrogate; real checkpoint may need trust_remote_code=True for AlpamayoR1 class
  • Multi-sample inference (num_traj_samples 16) would need ~37GB, still fits; not measured here

Evidence

  • assets/agent_workflow.png — reconnaissance, resource check, load, NPU inference, consistency, performance
  • assets/npu_device_call.png — npu-smi, torch_npu availability, device name, model/input/output device proof
  • assets/model_result.png — default python inference.py showing model, route, waypoint summary, latency, PASS

File Tree

inference.py
readme.md
requirements.txt
assets/agent_workflow.png
assets/npu_device_call.png
assets/model_result.png

Limitations

  • BF16 NPU has ~0.07 numerical diff vs CPU (sdpa fused), within BF16 5e-3/5e-2 tol; tighter float32 1e-4/1e-3 would fail.
  • Synthetic observations (random 320x576) not real driving video; real physical_ai_av dataset needs gated HF access and ~80k hours data. Waypoint values therefore synthetic but trajectory decoder and NPU contract are fully validated.
  • VLM reasoning trace (CoC) not decoded in surrogate (requires Cosmos-Reason2 8B); diffusion expert + action_space + flow-matching semantics are architecturally faithful.

agent_workflow npu_device_call model_result