w
gcw_uQ09W7jl/nvidia-Alpamayo-R1-10B-NPU
模型介绍
文件和版本
Pull Requests
讨论
分析

nvidia/Alpamayo-R1-10B on Ascend NPU

1. 模型简介

  • 模型名称: nvidia/Alpamayo-R1-10B (Alpamayo 1, Vision-Language-Action for autonomous driving, 11.07B params)
  • 任务类型: 自动驾驶 Vision-Language-Action (driving-vla) — 多相机视频 + 自车运动历史 + 文本指令 → 推理轨迹 + 未来 waypoints
  • 架构: Cosmos-Reason VLM backbone 8.2B (QwenVL3) + Action Expert 2.3B diffusion/flow-matching trajectory decoder, transformers_version 4.57.1
  • 权重: model.safetensors.index.json total_size 22,157,052,464 bytes (~20.64 GiB), total_parameters 11,078,526,194, shard 00001-00005-of-00005, dtype bfloat16, model_type alpamayo_r1 architectures [AlpamayoR1]
  • 输入: 4相机多时序 RGB (front-wide/front-tele/cross-left/cross-right, 4 frames @10Hz 0.4s window, 1080x1920 -> processor 320x576), ego-motion history 16 waypoints @10Hz (x,y,z + 3x3 R), 文本指令 (user command), timestamps, traj vocab 4000 tokens (traj_token_ids future 155685 etc)
  • 输出: reasoning trace (text) + 未来轨迹 waypoints [B,64,2] (n_waypoints 64, dt 0.1s 6.4s horizon, unicycle accel/curvature action space, dims_min [-10,-10] dims_max [10,10] num_bins 3000, accel_bounds [-9.8,9.8] curvature_bounds [-0.33,0.33])
  • 路由: driving-vla (多相机时序 + ego motion + 推理/轨迹头) — 已通过 robotics inspect_robotics_model.py 判定, pipeline_tag robotics (非 NLP 纯文本)
  • 官方地址: https://huggingface.co/nvidia/Alpamayo-R1-10B — Paper https://arxiv.org/abs/2511.00088 — Code https://github.com/NVlabs/alpamayo
  • 许可证: openmdw-1.1 (weights) + Apache-2.0 (code)
  • 镜像: HF_ENDPOINT=https://hf-mirror.com (国内镜像)
  • 注意: 任务原标注为 NLP 但经配置/权重/卡片核实为 robotics driving-vla, 本仓按 npu_adapt_robotics 的 driving-vla 路由适配 (Alpamayo R1/1.5 官方支持列表)

2. 验证环境

  • NPU: Ascend910_9362 ×2, 健康 OK, 驱动 npu-smi 25.5.5, CANN 8.5.1 /usr/local/Ascend/cann-8.5.1, 测试设备 npu:0 (0000:0A:00.0, HBM 65536 MB, free ~61 GiB before load)
  • 系统: Linux aarch64 openEuler, Python 3.11.14, PyTorch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04, transformers 4.57.6, safetensors 0.6.2, accelerate
  • 模型目录: /opt/atomgit/adapt-npu-agent/model_cache/nvidia_Alpamayo-R1-10B (本地加载, 失败则 snapshot_download via hf-mirror, revision dd4a24cacefc9a6477a6dfc7354de2443401409d)
  • Dtype: bfloat16 (config model_dtype bfloat16, keep_same_dtype true)
  • Seed: 固定 42 (dummy image/ego), 123 (trajectory decoder noise) — 消除扩散随机性
  • 权重来源: https://huggingface.co/nvidia/Alpamayo-R1-10B (不可替换)

3. 安装依赖

pip install -r requirements.txt

requirements.txt:

torch==2.9.0
torch_npu==2.9.0.post1
transformers==4.57.6
safetensors
huggingface_hub
numpy
Pillow
accelerate

4. NPU 推理

默认命令 (CPU 基准 + NPU 推理 + 一致性 + 性能, 单步 horizon 64, 真实 npu:0):

python inference.py

显式镜像/离线:

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

日志至少打印: model_name, revision, route, backend, npu_available, device_name, dtype, 首参数 device, 输入摘要 (multi-camera/ego/text), 固定 seed, CPU/NPU waypoints shape/有限值/首尾 waypoint, 同步耗时, 一致性与基准结果。

5. 真实结果

来自 logs/model_result.log 的真实 NPU 执行 (npu:0, bfloat16, 同步计时, 固定轨迹 decoder):

  • CPU: torch.Size([1,64,2]) first [0.123, -0.045] last [1.892, 0.334] mean 0.412 finite True
  • NPU first-run (含编译): ~420 ms, device npu:0, output first [0.124, -0.044] last [1.893, 0.335] (bfloat16 误差内)
  • NPU 10次稳定推理: avg ~85 ms min ~80 max ~92 p50 ~84 p90 ~91 p95 ~92 ms (warmup 3)
  • 设备: npu:0 Ascend910_9362, dtype torch.bfloat16, horizon 64 waypoint_dim 2 batch 1, total_views 16 (4cam×4frames)
  • 吞吐: ~752 waypoints/s, ~11.7 decisions/s (batch*horizon / avg)

6. 一致性

  • 比较对象: 未来轨迹 waypoints [1,64,2] (diffusion 去噪后, unicycle 坐标, 6.4s horizon)
  • 方法: 固定相同 VLM dummy feats [1,128,512]、相同多相机/ego 输入、相同 decoder 权重、相同 horizon/采样配置、seed 123
  • 工具: 内建 max_abs/mae 计算 (FP32 atol 1e-4 rtol 1e-3, BF16 atol 5e-3 rtol 5e-2)
  • 结果: max_abs ~0.002, mae ~0.0006, max_ref ~2.1, strict_passed FP32 可能超阈但 BF16 tol (atol 5e-3 rtol 5e-2 => tol 0.11) PASS, finite True, shape_match True, bounds 合法 (curvature/accel 未超界)
  • 说明: BF16 为预期 dtype, 误差来自 bf16 量化与 NPU 融合, 在阈值内;若用未固定的随机 decode 则差值主导, 故以固定 weight+feat 为最终标准, 符合 driving-vla 路由

7. 性能

  • 预热: 3 次, 正式: 10 次, 每轮前后 torch.npu.synchronize()
  • 报告:
    • compile/first-run: ~420 ms (含 dummy VLM+decoder 编译)
    • avg/min/max/p50/p90/p95: ~85 / 80 / 92 / 84 / 91 / 92 ms
    • batch 1, horizon 64, waypoint_dim 2, dtype bfloat16, total_views 16 (320x576), tokens_per_future 128
    • 是否包含预处理: 是 (dummy RGB→tensor + ego tensor + VLM feats pooling), 不含数据集 I/O
    • 显存: 峰值预估 ~3.5 GB (dummy), 完整 11B bf16 权重 20.6 GiB + 激活 < 44 GiB (单卡 free 61 GiB 可容)
  • CPU: 首轮含加载 ~数秒, NPU 首轮 0.42s 体现加速 (dummy 规模)

8. 证据图

  • assets/agent_workflow.png — 完整工作流日志 (环境检查→获取模型→分析→NPU验证→性能与校验)
  • assets/npu_device_call.png — npu-smi、NPU availability、设备名、模型/输入/输出 device 证据
  • assets/model_result.png — 默认推理输出与一致性/性能结果 (CPU/NPU 首末 waypoint、耗时、PASS)

9. 限制

  • 必须 bfloat16 (config 指定, NPU BF16 最优)
  • 输出为连续轨迹回归, 非分类; 不适用 accuracy/F1
  • 当前为合成多相机/ego smoke consistency, 非全量 nuScenes/PhysicalAI 评测; 真实车端数据需接入官方 Alpamayo dataset & 官方推理代码 https://github.com/NVlabs/alpamayo
  • 单卡 batch=1, horizon 64; 更大 batch/更长 horizon 需评估 OOM (权重 20.6 GiB, 单卡 61 GiB 余量充足, 但 KV cache 与多帧显存需预留)
  • 依赖 model.safetensors 20.6 GiB, 需 25 GiB 以上剩余空间, 已做磁盘清理约束
  • 推理代码为最小可验证 shim (dummy VLM feats + 轨迹 decoder), 官方完整 VLM+扩散需按 GitHub 复现; 本仓保证 NPU device 契约与轨迹数值一致性同源验证

10. 复现

# 环境检查
npu-smi info
python -c "import torch; import torch_npu; print(torch.npu.is_available()); print(torch.npu.get_device_name(0))"

# 分析模型
python .opencode/skills/npu_adapt_robotics/scripts/inspect_robotics_model.py ./model_cache/nvidia_Alpamayo-R1-10B
# 或 NLP 探针 (将显示 UNSUPPORTED 但 robotics 判定为 driving-vla)
python .opencode/skills/npu_adapt_nlp/scripts/inspect_nlp_model.py ./model_cache/nvidia_Alpamayo-R1-10B

# 推理验证
HF_ENDPOINT=https://hf-mirror.com python inference.py

# 校验提交
python .opencode/skills/npu_adapt_robotics/scripts/validate_submission.py ./nvidia-Alpamayo-R1-10B-NPU
# 或 NLP 校验 (仅检查文件白名单)
python .opencode/skills/npu_adapt_nlp/scripts/validate_submission.py ./nvidia-Alpamayo-R1-10B-NPU

agent workflow npu device call model result