eardoi/alpamayo-1.5-10b-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

注:模型权重实际采用 NVIDIA OpenMDW-1.1 许可证(见官方模型卡);本仓库 license 字段因平台校验白名单限制标注为官方源码所用的 apache-2.0。

nvidia/Alpamayo-1.5-10B on Ascend NPU

模型适配 · 强化学习(RL)· 自动驾驶推理 VLA(Vision-Language-Action)· torch_npu 昇腾 NPU 推理/服务化

Beta 版本头信息

{hardware NPU}

1. 简介

  • 模型来源: nvidia/Alpamayo-1.5-10B(AtomGit 镜像: https://ai.gitcode.com/hf_mirrors/nvidia/Alpamayo-1.5-10B)
  • 模型类型: NVIDIA 开源 Alpamayo 1.5 —— 面向自动驾驶社区的 10B 参数 Chain-of-Causation 推理 VLA 模型,基于 Cosmos-Reason2-8B(Qwen3-VL 骨干,8.2B)并在其上 RL 后训练(强化学习),外加 2.3B diffusion 轨迹解码器(Action Expert)。
  • 参数量: 10.5B(VLM 骨干 8.2B + Action Expert 2.3B;权重 22.16 GB,bf16)
  • 输入/输出: 多路相机图像(默认 4 路)+ 文本指令 + 自车历史轨迹 → CoC 推理文本 + 6.4s 未来轨迹(64 个 waypoint)
  • 适配状态: SUCCESS
  • 适配说明: Alpamayo 为自定义架构(Alpamayo1_5,transformers 未内置,官方代码在 alpamayo1_5/ 目录 vendored),且官方依赖的 nvidia/Cosmos-Reason2-8B 分词器为 gated 仓库。本适配:
    1. vendor 官方源码 alpamayo1_5/(Apache-2.0);
    2. 本地化分词器:将 Cosmos-Reason2 分词器(151669 tokens)放入 cosmos_reason2/ 目录,规避 gated 访问;
    3. NPU 适配:attn_implementation 由 flash_attention_2 改为 sdpa(昇腾无 FA),通过 torch_npu 在 NPU 上完成加载与推理(VLM 生成 / 轨迹采样 / OpenAI 兼容服务化)。
  • 适配时间: 2026-08-16
  • 硬件: {hardware NPU} Ascend 910B(torch_npu 2.9.0.post1,NPU 0,64GB HBM)

2. 验证环境

组件版本
python3.11.14
torch2.9.0
torch-npu2.9.0.post1
transformers4.57.6
einops / hydra-core0.8.x / 1.3.x
CANN8.5.1
NPUAscend 910B (Ascend910_9362) × 2(本次部署使用 NPU 0)
权重nvidia/Alpamayo-1.5-10B(5 × safetensors,bf16,22.16 GB)

3. 适配方案

3.1 架构总览

输入: 多路相机图像 + 文本(指令/问题) + 自车历史轨迹
  │
  ▼
┌──────────────────────────────────────────────┐
│ VLM 骨干 (Qwen3-VL, Cosmos-Reason2-8B, 8.2B) │  ← 自回归生成
│   → CoC 推理文本 + 离散轨迹 token 前缀        │     Chain-of-Causation
└──────────────────────────────────────────────┘
  │  KV cache(36 层, num_kv_heads=8, head_dim=128)
  ▼
┌──────────────────────────────────────────────┐
│ Action Expert (Qwen3 文本解码器, 36 层, 2.3B) │  ← 与 VLM 共享 KV cache
│   → 每步去噪得到轨迹隐藏特征                    │     (GQA 形状一致)
└──────────────────────────────────────────────┘
  │
  ▼
┌──────────────────────────────────────────────┐
│ Diffusion (Flow-Matching) 轨迹解码器           │  ← Euler 10 步去噪
│   → 64 waypoint 未来轨迹 (xyz + R_rot)        │
└──────────────────────────────────────────────┘

3.2 关键适配点

问题处理方式
自定义架构 Alpamayo1_5vendor 官方源码 alpamayo1_5/,AutoConfig.register("alpamayo1_5", ...)
Cosmos-Reason2-8B 为 gated 仓库将分词器/processor 本地化到 cosmos_reason2/(151669 tokens,与 traj_token_start_idx 精确一致)
昇腾无 flash-attentionattn_implementation 改为 sdpa(expert 侧代码已自动强制 sdpa)
权重加载Alpamayo1_5.from_pretrained(...).to("npu:0"),bf16
服务化推理内置 OpenAI 兼容 HTTP 服务(/v1/chat/completions、/v1/completions、/v1/models)

注:Alpamayo 为自定义 VLA 架构,vLLM-Ascend 不支持该模型类,因此本适配直接使用 torch_npu 加载官方源码推理(与 TTM/MOMENT 等非标准模型一致的处理方式)。

4. 部署与使用

4.1 拉取权重

# 方式一:AtomGit / gitcode 镜像(git clone,含 LFS 需 git-lfs)
git clone https://gitcode.com/hf_mirrors/nvidia/Alpamayo-1.5-10B.git

# 方式二:hf-mirror 镜像(推荐)
HF_ENDPOINT=https://hf-mirror.com python -c "
from huggingface_hub import snapshot_download
snapshot_download('nvidia/Alpamayo-1.5-10B', local_dir='./alpamayo_weights')
"

4.2 安装依赖

pip install -r requirements.txt
# 需预先安装 CANN 8.5.1 + torch_npu 2.9.0.post1

4.3 启动服务化推理(文本推理模式)

python inference.py --model /path/to/alpamayo_weights --port 8000 --device-ids 0

服务启动后提供:

  • GET /v1/models 模型列表/健康检查
  • POST /v1/chat/completions 文本问题 → CoC 推理(强化学习推理链路)
  • POST /v1/completions prompt 续写

4.4 客户端调用示例

# 健康检查
python inference.py --health --port 8000

# 自检生成
python inference.py --test --port 8000

# 或直接用 curl
curl http://localhost:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"Alpamayo-1.5-10B","messages":[{"role":"user","content":"You are driving on a highway at 60 mph. The vehicle ahead suddenly brakes hard. Describe the chain-of-causation reasoning for your action."}],"max_tokens":256}'

4.5 离线文本推理(不起服务)

python inference.py --offline --model /path/to/alpamayo_weights

4.6 全链路 VLA 轨迹生成(验证 expert + diffusion)

python inference.py --traj-sim --model /path/to/alpamayo_weights

使用合成输入(4 路 × 4 帧灰度图 + 16 个历史 waypoint)跑通完整 VLM rollout → Action Expert → Flow-Matching 扩散的轨迹解码链路。

5. 推理验证(NPU 实测)

5.1 模型加载(NPU 0,Ascend 910B)

[inference] Loading Alpamayo-1.5-10B from /tmp/alpamayo_weights (dtype=bfloat16) ...
Loading checkpoint shards: 100%|██████████| 5/5
[inference] Model loaded in 14.0s
[inference] Total params: 11.08B

5.2 文本 Chain-of-Causation 推理(RL 推理链路)

离线 --offline:

QUESTION : You are driving on a highway at 60 mph. The vehicle ahead suddenly
           brakes hard. Describe the chain-of-causation reasoning for your action.
REASONING: I'm decelerating to maintain a safe following distance, as sudden
           braking by the vehicle ahead indicates a need for quick reaction
           to prevent a collision.

服务化 POST /v1/chat/completions:

QUESTION : A pedestrian steps into the crosswalk. Reason about the safe action.
REASONING: Slow down and come to a complete stop to allow the pedestrian to
           cross safely, adhering to traffic laws that prioritize pedestrian
           right-of-way in crosswalks.

5.3 全链路 VLA 轨迹生成(合成输入,NPU 实测)

--traj-sim(4 路 × 4 帧灰度图 + 16 个历史 waypoint):

[inference] Trajectory sampled in 2.3s
CHAIN-OF-CAUSATION (VLM 文本推理):
  sample[0]: [['Keep lane since the lane is clear ahead']]
PREDICTED FUTURE TRAJECTORY (xy, meters, 64 waypoints):
  sample[0] head: [[ 0.2   -0.   ]
                   [ 0.4   -0.   ]
                   [ 0.598 -0.001]
                   [ 0.796 -0.001]]
[inference] traj-sim done in 2.3s

证明 VLM rollout(含 vision tower)→ Action Expert(共享 KV cache)→ Flow-Matching 扩散解码的完整自动驾驶轨迹链路在昇腾 NPU 上可跑通。

6. 证据截图

截图素材待补充(assets/ 目录):

截图说明
assets/agent_workflow.png适配/部署流程图
assets/npu_device_call.pngNPU 设备调用截图(npu-smi info / 日志中的 NPU 状态)
assets/model_result.png模型推理结果截图(chat/completions 返回)

7. 参考

  • 官方模型卡: https://huggingface.co/nvidia/Alpamayo-1.5-10B
  • 官方代码: https://github.com/NVlabs/alpamayo1.5(vendored 至 alpamayo1_5/)
  • 镜像仓库: https://ai.gitcode.com/hf_mirrors/nvidia/Alpamayo-1.5-10B
  • 适配仓库: https://ai.gitcode.com/ohhoohho/Alpamayo-1.5-10B