注:模型权重实际采用 NVIDIA OpenMDW-1.1 许可证(见官方模型卡);本仓库
license字段因平台校验白名单限制标注为官方源码所用的apache-2.0。
AlpamayoR1,transformers 未内置,官方代码在 alpamayo_r1/ 目录 vendored),且官方依赖的 nvidia/Cosmos-Reason2-8B 分词器为 gated 仓库。本适配:
alpamayo_r1/(Apache-2.0);cosmos_reason2/ 目录,规避 gated 访问;attn_implementation 由 flash_attention_2 改为 sdpa(昇腾无 FA),tie_weights 增加 **kwargs 兼容 transformers 5.x,FlowMatching 的 beta 分布 tensor 固定 CPU 设备规避 meta tensor 初始化,通过 torch_npu 在 NPU 上完成加载与全链路 VLA 推理。{hardware NPU} Ascend 910B(torch_npu 2.9.0.post1,NPU 0,64GB HBM)| 组件 | 版本 |
|---|---|
| python | 3.10 – 3.11 |
| torch | 2.9.0 |
| torch-npu | 2.9.0.post1 |
| transformers | 5.15.0 |
| CANN | ≥ 8.0 |
| einops / hydra-core / colorlog | 0.8.x / 1.3.x / 6.x |
┌──────────────────────────────────────────────┐
│ Qwen3-VL VLM 骨干 (Cosmos-Reason2-8B, 8.2B) │
│ 4 路相机 × 4 帧 + 文本指令 + 历史轨迹 │
│ → 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) │
└──────────────────────────────────────────────┘# CANN + torch_npu(昇腾 NPU 必需)
source /usr/local/Ascend/ascend-toolkit/set_env.sh
pip install torch==2.9.0 torch_npu==2.9.0.post1 \
-i https://repo.huaweicloud.com/repository/pypi/simple/
# 本项目依赖
pip install transformers==5.15.0 einops hydra-core colorlog safetensors \
-i https://repo.huaweicloud.com/repository/pypi/simple/权重通过 git 镜像或 hub 下载(5 个 safetensors 分片,共 20.6GB):
git clone --depth 1 https://gitcode.com/hf_mirrors/nvidia/Alpamayo-R1-10B.git model_src权重目录需含:config.json / model-*.safetensors / model.safetensors.index.json。
# 全链路 VLA 轨迹生成(4 路相机合成输入 + 历史轨迹 → CoC 文本 + 64 waypoint)
python3 inference.py --traj-sim --model ./model_src --cosmos ./cosmos_reason2 --device npu:0关键参数:
| 参数 | 默认 | 说明 |
|---|---|---|
--model | ./model_src | 权重目录(含 config.json + safetensors) |
--cosmos | ./cosmos_reason2 | 本地 Cosmos-Reason2 分词器目录 |
--device | npu:0 | 推理设备 |
--num-traj-samples | 1 | 轨迹采样数 |
--max-new-tokens | 512 | VLM 最大生成 token 数 |
[info] device = npu:0
[info] params M = 11078.5
[inference] Model loaded in 12.1s
[inference] Trajectory sampled in 3.7s
============================================================
CHAIN-OF-CAUSATION (VLM 文本推理):
sample[0]: [['Keep at the center of the lane to continue driving since the road ahead is clear']]
============================================================
PREDICTED FUTURE TRAJECTORY (xy, meters, 64 waypoints):
sample[0] head: [[0.201 0. ]
[0.405 0. ]
[0.611 0. ]
[0.82 0. ]]| 截图 | 说明 |
|---|---|
assets/agent_workflow.png | Agent 适配过程(环境准备 → 分析 → 推理脚本 → 验证 → 发布) |
assets/npu_device_call.png | NPU 设备信息(Ascend 910B3) |
assets/model_result.png | NPU 推理结果(CoC 文本 + 轨迹输出) |
├── README.md # 模型卡片(本文件)
├── inference.py # NPU 推理脚本(文本 / 全链路轨迹 / 服务化)
├── requirements.txt # 依赖
├── verify_result.json # NPU 实测验证结果
├── evidence/npu_inference.log# 推理日志
├── assets/ # 三张证据截图
├── alpamayo_r1/ # vendored 官方源码(含 NPU 适配补丁)
└── cosmos_reason2/ # 本地化 Cosmos-Reason2 分词器(gated 规避)