注:模型权重实际采用 NVIDIA OpenMDW-1.1 许可证(见官方模型卡);本仓库
license字段因平台校验白名单限制标注为官方源码所用的apache-2.0。
模型适配 · 强化学习(RL)· 自动驾驶推理 VLA(Vision-Language-Action)· torch_npu 昇腾 NPU 推理/服务化
Beta 版本头信息
{hardware NPU}Alpamayo1_5,transformers 未内置,官方代码在 alpamayo1_5/ 目录 vendored),且官方依赖的 nvidia/Cosmos-Reason2-8B 分词器为 gated 仓库。本适配:
alpamayo1_5/(Apache-2.0);cosmos_reason2/ 目录,规避 gated 访问;attn_implementation 由 flash_attention_2 改为 sdpa(昇腾无 FA),通过 torch_npu 在 NPU 上完成加载与推理(VLM 生成 / 轨迹采样 / OpenAI 兼容服务化)。{hardware NPU} Ascend 910B(torch_npu 2.9.0.post1,NPU 0,64GB HBM)| 组件 | 版本 |
|---|---|
| python | 3.11.14 |
| torch | 2.9.0 |
| torch-npu | 2.9.0.post1 |
| transformers | 4.57.6 |
| einops / hydra-core | 0.8.x / 1.3.x |
| CANN | 8.5.1 |
| NPU | Ascend 910B (Ascend910_9362) × 2(本次部署使用 NPU 0) |
| 权重 | nvidia/Alpamayo-1.5-10B(5 × safetensors,bf16,22.16 GB) |
输入: 多路相机图像 + 文本(指令/问题) + 自车历史轨迹
│
▼
┌──────────────────────────────────────────────┐
│ 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) │
└──────────────────────────────────────────────┘| 问题 | 处理方式 |
|---|---|
自定义架构 Alpamayo1_5 | vendor 官方源码 alpamayo1_5/,AutoConfig.register("alpamayo1_5", ...) |
| Cosmos-Reason2-8B 为 gated 仓库 | 将分词器/processor 本地化到 cosmos_reason2/(151669 tokens,与 traj_token_start_idx 精确一致) |
| 昇腾无 flash-attention | attn_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 等非标准模型一致的处理方式)。
# 方式一: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')
"pip install -r requirements.txt
# 需预先安装 CANN 8.5.1 + torch_npu 2.9.0.post1python inference.py --model /path/to/alpamayo_weights --port 8000 --device-ids 0服务启动后提供:
GET /v1/models 模型列表/健康检查POST /v1/chat/completions 文本问题 → CoC 推理(强化学习推理链路)POST /v1/completions prompt 续写# 健康检查
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}'python inference.py --offline --model /path/to/alpamayo_weightspython inference.py --traj-sim --model /path/to/alpamayo_weights使用合成输入(4 路 × 4 帧灰度图 + 16 个历史 waypoint)跑通完整 VLM rollout → Action Expert → Flow-Matching 扩散的轨迹解码链路。
[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离线 --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.--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 上可跑通。
截图素材待补充(
assets/目录):
| 截图 | 说明 |
|---|---|
assets/agent_workflow.png | 适配/部署流程图 |
assets/npu_device_call.png | NPU 设备调用截图(npu-smi info / 日志中的 NPU 状态) |
assets/model_result.png | 模型推理结果截图(chat/completions 返回) |