z
z_studio/X-VLA-Pt-NPU
模型介绍
文件和版本
Pull Requests
讨论
分析

2toINF/X-VLA-Pt on Ascend NPU

1. 简介

  • 模型来源: 2toINF/X-VLA-Pt(HuggingFace Hub)
  • 模型类型: 视觉-语言-动作(Vision-Language-Action)策略,基于 flow-matching 训练
  • 参数量: ≈ 0.9B(Florence-2-large encoder-only 骨干网络 + 24 层 SoftPromptedTransformer)
  • 输入 / 输出: 多视角图像(≤3 视角,224×224)+ 本体状态(20 维)+ 语言指令 → 连续动作(chunk=30 步 × 20 维,ee6d 动作空间)
  • VLM 骨干网络: microsoft/Florence-2-large(encoder-only,DaViT 视觉塔 + BART 文本编码器)
  • 论文: Zheng et al., 2025, X-VLA: Soft-Prompted Transformer as Scalable Cross-Embodiment Vision-Language-Action Model(arXiv:2510.10274)
  • 参考实现: https://github.com/2toINF/X-VLA

X-VLA 将「可学习软提示(soft prompt)」思想引入跨本体机器人学习,为每个不同的本体(embodiment/domain)维护一套独立的可学习嵌入,从而在一个模型内高效利用异构机器人数据。其架构为「Florence-2 编码器(视觉-语言表征)→ SoftPromptedTransformer(flow-matching 动作去噪)→ Action Hub(ee6d 动作空间 / 损失)」,是一个简洁、可扩展的通用 VLA 策略。

X-VLA-Pt 为 2toINF 发布的通用基础(Pt)权重,action_mode=ee6d(双组 6D 位姿 + 双组 3D 位置 + 双夹爪),num_domains=30(30 个本体域),可在具体机器人/任务上继续微调。

本目录完成了该模型在昇腾 Ascend NPU(torch_npu 推理引擎)上的完整适配与部署,包含可直接运行的推理脚本 inference.py、批量测试脚本 run_test_cases.py、依赖清单 requirements.txt、运行用 venv 环境、50 组实测测试用例及输出结果,以及适配过程总结 AGENT_WORKFLOW.md。

2. 验证环境

组件版本
torch2.9.0(CPU build + torch_npu 扩展)
torch-npu2.9.0.post1+gitee7ba04
transformers4.57.6
timm1.0.15
json-numpy2.1.1
CANN8.5.1
Python3.11.14
NPUAscend 910B(Atlas 800T A2,64GB HBM × 2)
vllm-ascend / sglang不适用(本模型不使用)1

模型权重路径:

权重路径
X-VLA-Pt(含 config / safetensors / 远端代码)/data/models/2toINF/X-VLA-Pt

3. NPU 适配说明

X-VLA-Pt 为自定义 HuggingFace 架构(XVLA,model_type="xvla"),不在 vllm-ascend / sglang 的模型注册表内(Florence-2 亦在 vllm-ascend「未支持」列表中,Issue #2259),且输出为连续动作而非自回归 token,因此推理引擎选用 torch_npu1,通过 AutoModel.from_pretrained(..., trust_remote_code=True) 加载远端代码直接推理。

适配点CUDA 默认NPU 处理方式
设备分配model.to('cuda')model.to('npu:0'),权重经 safetensors 加载后置于 NPU
注意力实现默认 sdpa在顶层 XVLAConfig 与嵌套 florence_config 上显式设 _attn_implementation="eager"2
输入 dtype处理器输出 fp32 图像,模型通常 fp16/bf16DaViT Conv2d 要求输入与权重同 dtype,image_input 显式转 bf16
状态/噪声 dtype与模型权重一致proprio 转 bf16,domain_id 为 int64
文本嵌入绑定Florence2 tie_weights 自动绑定加载后将 encoder.embed_tokens 重绑到 shared3
数据预处理/后处理XVLAProcessor(CLIPImageProcessor + BartTokenizerFast)复用官方处理器;ee6d 后处理由 action_space.postprocess 完成(夹爪通道 sigmoid)

关键实现(均在 inference.py / run_test_cases.py 中,不修改任何三方库源码):

  1. 通过 AutoConfig.from_pretrained 加载 XVLAConfig,并在 config._attn_implementation 与 config.florence_config._attn_implementation 上显式设置 "eager";
  2. 通过 AutoModel.from_pretrained(..., trust_remote_code=True, dtype=bf16) 加载权重,执行 model.to('npu:0');加载后将 encoder.embed_tokens.weight 重绑到 shared.weight;
  3. 通过 AutoProcessor.from_pretrained(..., trust_remote_code=True) 加载 XVLAProcessor;
  4. 调用 model.generate_actions(input_ids, image_input, image_mask, domain_id, proprio, steps) 完成 flow-matching 去噪,输出 (B, num_actions=30, dim_action=20) 动作;
  5. 夹爪通道(索引 9/19)经 action_space.postprocess 的 sigmoid 归一至 [0,1]。

4. 分步推理操作流程

4.1 环境依赖

# 使用清华镜像安装 Python 依赖(本目录已创建 venv,继承系统级 torch/torch-npu)
cd /opt/atomgit/model_adapt/X-VLA-Pt-NPU
./venv/bin/pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# 或使用阿里云镜像
# ./venv/bin/pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

torch / torch-npu 必须与 CANN 版本严格对应,请通过昇腾官方渠道安装(参见 requirements.txt 末尾的版本对照表)。本目录下的 venv/ 环境由 python3 -m venv --system-site-packages venv 创建,会自动继承系统级的 torch / torch-npu,因此在 venv 内只需安装 timm / json-numpy 等纯 Python 依赖。

4.2 创建运行环境(首次)


```bash
# 创建 venv(继承系统 torch/torch-npu/transformers 等)
python3 -m venv --system-site-packages venv

# 安装模型远端代码所需依赖(清华镜像)
./venv/bin/pip install timm==1.0.15 json-numpy==2.1.1 \
    -i https://pypi.tuna.tsinghua.edu.cn/simple

4.3 准备模型权重

# 权重已本地化于 /data/models/2toINF/X-VLA-Pt(含 config.json / model.safetensors /
# modeling_xvla.py / modeling_florence2.py / transformer.py / action_hub.py /
# processing_xvla.py / tokenizer 等)
# 若需重新下载(HuggingFace 直连不可达时用 ModelScope):
#   python3 -c "from modelscope import snapshot_download;
#       snapshot_download('2toINF/X-VLA-Pt',
#           local_dir='/data/models/2toINF/X-VLA-Pt')"

4.4 Running Inference (Single Shot)

cd /opt/atomgit/model_adapt/X-VLA-Pt-NPU
./venv/bin/python inference.py \
    --model /data/models/2toINF/X-VLA-Pt \
    --device npu:0 \
    --task "Pick up the red block and place it in the green bin." \
    --domain 0 --steps 10 --seed 42 \
    --output-dir output

生成的产物位于 output/:

文件说明
action.npy预测动作 chunk,(1, 30, 20) float32(30 步 × 20 维 ee6d)
report.json输入参数、动作统计、加载/推理耗时、NPU 显存等指标

--help 可查看全部参数(--task、--state 20 维、--domain 0~29、--steps、 --seed、--views、--hue、--image 真实图像路径等)。

4.5 批量测试用例(50 组)

./venv/bin/python run_test_cases.py \
    --model /data/models/2toINF/X-VLA-Pt \
    --device npu:0 \
    --output-dir output

每组输出到 output/testcase_NN/action.npy 和 output/testcase_NN/report.json, 所有结果汇总至 output/testcases_summary.json。使用 --cases 1,2,3 可运行子集并支持断点续跑。

5. 测试用例与输出结果

5.1 用例设计

共 50 组(满足≥44组的要求),模型仅加载一次、逐组推理,覆盖6类输入变化:

组用例编号变化维度说明
A01–30domain_id 0~29(全部30个本体域)验证跨本体 soft prompt 生效
B31–388组语言指令同一域下指令差异
C39–424组本体状态(20维)状态差异
D43–45图像视角数/色偏(1/2/3视角)多视角输入
E46–48flow-matching 去噪步数(5/10/20)采样步数影响
F49–50随机种子(0 / 123)初始噪声随机性

公共基线:合成三视角棋盘格图像(hue=0.5)、语言指令 "Pick up the red block and place it in the green bin."、state=全零20维、 domain_id=0、10步去噪、seed=42。

动作布局(ee6d):[0:3]=pos1(xyz)、[3:9]=rot1(6D)、[9]=gripper1、 [10:13]=pos2(xyz)、[13:19]=rot2(6D)、[19]=gripper2。夹爪通道经 sigmoid 归一至 [0,1]。

5.2 组 A:domain_id 0~29(30组)

固定指令/状态/图像/seed=42/steps=10,仅切换 domain_id。各域输出明显不同 (mean_abs 0.120.40,夹爪 0.000.92),证明30组本体 soft prompt 均被正确激活。 first_step 为 action 第1步的完整20维向量(含 sigmoid 后夹爪值)。

用例名称mean_absstdgrip1grip2NaNfirst_step(20维)
01domain_000.17940.23190.40620.5703False-0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118,-0.4141,0.4062,-0.0222,0.1436,-0.1177,-0.0400,-0.1475,-0.2520,0.2773,-0.1309,0.0156,0.5703
02domain_010.23620.27530.46480.5273False-0.1094,0.0359,0.0776,0.1187,0.0791,-0.0723,-0.2988,0.3047,0.4258,0.4648,-0.3906,-0.2363,0.3770,-0.3438,-0.2324,0.3770,0.0889,0.0217,-0.2266,0.5273
03domain_020.22230.26730.43360.5781False-0.1572,-0.0869,0.1074,-0.0281,-0.1064,0.3984,-0.1387,-0.0654,0.3086,0.4336,0.2070,-0.0310,-0.4297,-0.1865,-0.3906,0.3223,-0.1855,-0.1846,0.1758,0.5781
04domain_030.18610.23840.49220.3945False-0.0084,0.1973,0.3887,0.3574,-0.2773,-0.3887,0.0089,0.0304,0.2695,0.4922,-0.0474,0.0962,-0.3125,-0.0640,-0.0088,-0.0223,-0.1553,-0.1011,0.1299,0.3945
05domain_040.15920.21440.42580.4961False0.2949,-0.0503,-0.1562,0.0845,-0.0603,0.0767,-0.0559,-0.0113,0.0537,0.4258,0.0135,-0.1924,-0.2236,0.0184,0.0540,-0.2002,-0.0165,-0.4023,0.2480,0.4961
06domain_050.17440.22850.51560.4785False-0.0498,-0.1104,-0.0510,-0.1416,0.0479,0.0918,-0.0226,-0.0064,-0.3359,0.5156,0.3789,0.2676,-0.2773,0.1553,0.1514,0.0496,-0.2070,-0.0791,-0.1196,0.4785
07domain_060.20950.23930.53910.4648False0.2324,0.3066,0.0894,-0.3809,0.2314,-0.0099,0.2402,-0.3906,0.1768,0.5391,0.1206,0.0913,0.1064,-0.1787,-0.0679,0.0874,0.0493,0.2041,-0.0391,0.4648
08domain_070.21520.25690.47660.5703False-0.0212,0.1279,0.2031,0.4023,0.2539,-0.0957,-0.2227,-0.1406,-0.0315,0.4766,-0.3574,0.0952,0.2148,0.2021,0.0479,-0.3711,-0.2100,-0.2773,-0.0732,0.5703
09domain_080.15910.18390.48830.5273False0.1582,0.2002,-0.1348,-0.0535,-0.1484,0.2598,0.0344,0.1406,-0.0542,0.4883,0.3184,0.1328,0.1289,0.0522,0.2168,-0.1177,-0.0283,0.0006,-0.0396,0.5273
10domain_090.15840.21280.50780.5273False-0.1406,-0.2002,-0.0352,-0.0952,-0.1641,0.0320,-0.0913,-0.1226,0.1670,0.5078,0.0201,-0.0762,-0.2236,0.0320,0.0535,-0.0569,0.0205,-0.3516,0.1299,0.5273
11domain_100.38700.50470.91800.5898False0.0562,-0.0161,0.1523,-0.1855,0.1592,0.0297,0.8164,-0.6680,-0.0024,0.9180,0.1187,-0.0347,0.1523,-0.2578,0.0332,-0.0092,0.8594,-0.4766,0.1040,0.5898
12domain_110.17940.34810.05270.0000False0.5156,-0.1050,0.4141,0.1182,-0.4766,-0.4316,-0.0928,0.0811,-0.0104,0.0527,0.0000,-0.0004,0.0006,0.0003,-0.0003,0.0001,0.0001,-0.0004,0.0001,0.0000
13domain_120.12180.24940.00510.0000False-0.1748,0.1592,0.1338,-0.0138,0.1289,0.0444,-0.6406,0.2490,-0.0752,0.0051,0.0002,0.0000,-0.0010,-0.0003,0.0008,-0.0001,0.0000,0.0002,0.0000,0.0000
14domain_130.13900.26520.00200.0000False-0.0593,-0.0175,-0.0537,0.0771,-0.0830,-0.0732,-0.1089,0.0242,0.0069,0.0020,-0.0004,0.0006,0.0005,-0.0002,0.0003,-0.0002,0.0004,-0.0002,-0.0002,0.0000
15domain_140.16010.28370.00130.0000False-0.0703,-0.0009,-0.0444,0.1035,-0.1680,-0.1064,-0.1846,0.0378,-0.0125,0.0013,-0.0006,-0.0003,-0.0005,-0.0006,0.0002,0.0003,-0.0005,0.0010,-0.0004,0.0000
16domain_150.40330.48050.00830.7891False0.2617,0.1484,0.3125,-0.4824,-0.2793,-0.3770,0.1108,-0.0391,-0.3262,0.0083,0.2539,-0.1328,0.3066,0.2578,-0.4590,-0.2852,0.0962,-0.1885,-0.2871,0.7891
17domain_160.38050.44340.07370.0005False0.0184,-0.0083,0.0447,0.6367,0.1904,-0.1885,0.6211,-0.2852,-0.1099,0.0737,-0.0261,-0.0317,0.0503,0.6328,-0.1543,0.2344,0.8086,-0.2520,0.2617,0.0005
18domain_170.34000.47120.02480.0003False0.4395,-0.0957,0.4277,0.8984,-0.0177,0.0376,-0.8828,-0.2051,-0.0139,0.0248,0.5469,0.1235,0.5508,0.7109,-0.1797,-0.0874,-0.5664,-0.3320,0.1104,0.0003
19domain_180.18410.22910.49410.4609False0.0046,0.1182,-0.1104,-0.2314,0.0269,-0.4434,-0.2217,-0.0908,-0.2129,0.4941,-0.0184,-0.0464,-0.1084,-0.1260,-0.1045,-0.2520,-0.1719,0.1084,0.2773,0.4609
20domain_190.21130.25610.51950.4629False-0.1748,0.3164,-0.3789,-0.1348,0.1147,0.1533,0.0483,0.0986,-0.2373,0.5195,-0.4590,-0.1973,0.2012,-0.0806,0.0183,-0.1523,0.0068,0.1934,-0.1465,0.4629
21domain_200.18920.22540.53520.4648False-0.2490,0.0425,0.0928,-0.1943,0.2930,-0.1084,0.2334,0.0500,-0.3145,0.5352,-0.2070,-0.0442,0.0967,0.1211,0.0664,-0.0496,-0.0267,0.2168,0.2715,0.4648
22domain_210.20910.24120.55080.4473False-0.2773,0.0928,-0.0486,-0.0986,-0.0371,0.2754,-0.0898,-0.1318,0.3145,0.5508,0.1924,0.1006,-0.2422,0.3027,-0.3184,0.2275,0.2139,-0.0728,0.0339,0.4473
23domain_220.19980.23900.41800.4844False-0.1206,0.0031,0.3047,-0.0703,0.0640,0.3652,-0.3223,0.1172,0.2148,0.4180,0.1777,-0.2363,-0.0845,0.1699,-0.1582,0.2109,-0.3848,-0.1089,-0.0493,0.4844
24domain_230.16050.21810.46680.5352False-0.1865,-0.3691,0.1582,-0.2363,0.0267,0.0364,-0.0165,0.0112,-0.0337,0.4668,-0.0243,-0.0332,-0.1289,-0.2773,0.2002,-0.0557,-0.0957,-0.1836,0.1338,0.5352
25domain_240.18660.22030.46090.5195False-0.3613,-0.1006,0.3301,0.1572,-0.1396,0.1035,0.0142,-0.1562,0.1016,0.4609,0.3164,0.2578,-0.0835,0.2129,-0.0864,-0.0923,0.0149,0.0405,0.0864,0.5195
26domain_250.22380.27210.55080.5117False-0.3848,-0.1387,0.3418,-0.1875,0.0840,0.1602,0.3027,0.0684,-0.0962,0.5508,-0.0099,-0.4141,0.2930,-0.1211,0.0679,0.1157,-0.3770,0.0138,0.3086,0.5117
27domain_260.21880.26110.43950.5703False0.0991,-0.3242,-0.1699,0.1216,-0.3164,-0.1973,-0.0674,0.1895,-0.3359,0.4395,-0.2598,-0.0654,-0.2275,0.3848,-0.0923,-0.0620,-0.3242,-0.1455,0.0300,0.5703
28domain_270.19250.24500.47460.5664False-0.0164,0.0251,0.3730,0.3164,-0.1504,-0.0038,-0.0962,-0.3086,0.1797,0.4746,-0.0152,0.3008,0.0781,-0.1992,-0.1162,-0.1953,-0.0747,-0.2773,-0.0928,0.5664
29domain_280.20820.25300.51560.5312False-0.3555,-0.0518,0.0498,0.0840,-0.0625,0.2275,0.1094,-0.2598,0.1089,0.5156,0.1729,0.3574,0.4336,-0.1543,-0.1631,-0.0464,-0.2363,-0.1982,0.0518,0.5312
30domain_290.19630.22930.52340.4258False0.1211,0.0302,0.1445,0.1387,0.2266,0.0776,0.3203,-0.2246,0.0781,0.5234,0.2402,-0.0013,-0.2539,-0.3672,-0.2754,-0.1348,0.1235,0.2930,0.0270,0.4258

5.3 Group B: Language Instructions (8 Cases)

With fixed domain=0 / zero-state / 3 views / seed=42 / steps=10, only the instruction is varied. The outputs for different instructions show differences (e.g., first_step dimension 1 ranges from -0.0437 to -0.0474); since the synthetic image content and the action magnitudes under near-zero state are generally close, the differences are small in scale but element-wise distinguishable (no NaN).

CaseLanguage Instructionmean_absstdgrip1grip2NaNfirst_step (first 8 dims)
31Pick up the red block and place it in the green bin.0.17940.23190.40620.5703False-0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118...
32Move the blue cube to the right side.0.17980.23220.40620.5703False-0.0471,-0.1172,0.2617,0.1406,-0.2012,0.1387,0.0327,-0.0101...
33Place the mug on the saucer.0.17940.23180.40620.5703False-0.0449,-0.1143,0.2637,0.1387,-0.2021,0.1416,0.0302,-0.0104...
34Push the yellow button.0.17890.23160.40620.5703False-0.0437,-0.1157,0.2598,0.1396,-0.1963,0.1426,0.0308,-0.0101...
35Open the drawer and take out the spoon.0.17950.23220.40820.5703False-0.0447,-0.1172,0.2598,0.1387,-0.1992,0.1426,0.0294,-0.0091...
36Tuck in the chair.0.17960.23190.40820.5703False-0.0474,-0.1138,0.2656,0.1416,-0.2021,0.1406,0.0260,-0.0106...
37Knock over the cup.0.17920.23200.40620.5703False-0.0449,-0.1143,0.2656,0.1396,-0.2002,0.1416,0.0287,-0.0101...
38Wipe the whiteboard.0.17900.23160.40620.5703False-0.0439,-0.1123,0.2656,0.1396,-0.2002,0.1416,0.0291,-0.0120...

5.4 Group C: Proprioceptive States (4 Cases)

With fixed domain=0 / instruction / 3 views / seed=42 / steps=10, only the 20-dimensional state is switched.

Casestate (first 6 dims)mean_absstdgrip1grip2NaNfirst_step (first 8 dims)
390,0,0,0,0,0,...0.17940.23190.40620.5703False-0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118...
400.1,-0.2,0.05,0.5,-0.3,0.2,...0.17920.23170.40620.5703False-0.0481,-0.1128,0.2637,0.1396,-0.2070,0.1387,0.0295,-0.0087...
41-0.1,0.2,-0.05,0.3,0.4,-0.2,...0.17960.23200.40620.5703False-0.0488,-0.1167,0.2637,0.1357,-0.2041,0.1445,0.0311,-0.0137...
420.05,0.05,0.1,-0.4,0.2,0.6,...0.17940.23200.40620.5703False-0.0466,-0.1143,0.2637,0.1348,-0.2061,0.1484,0.0310,-0.0143...

5.5 组 D:图像视角 / 色偏(3 组)

固定 domain=0 / 指令 / state 全零 / seed=42 / steps=10,切换视角数与基准色偏 hue。

用例视角配置mean_absstdgrip1grip2NaNfirst_step(前 8 维)
431 视角(hue=0.5)0.17900.23130.40820.5703False-0.0415,-0.1138,0.2578,0.1475,-0.1895,0.1377,0.0349,0.0006...
442 视角(hue=0.2)0.17970.23270.40620.5703False-0.0410,-0.1138,0.2578,0.1396,-0.2041,0.1416,0.0330,-0.0100...
453 视角(hue=0.8)0.17930.23170.40620.5703False-0.0439,-0.1167,0.2598,0.1396,-0.2031,0.1426,0.0315,-0.0127...

5.6 组 E:去噪步数(3 组)

固定 domain=0 / 指令 / 3 视角 / seed=42,切换 flow-matching 去噪步数。步数越多耗时越高(约线性),输出收敛稳定(mean_abs ≈ 0.1794~0.1795,无 NaN)。

用例stepsmean_absstdgrip1grip2NaNfirst_step(前 8 维)
4650.17950.23210.40620.5703False-0.0447,-0.1147,0.2637,0.1387,-0.2061,0.1445,0.0298,-0.0123...
47100.17940.23190.40620.5703False-0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118...
48200.17950.23200.40620.5703False-0.0464,-0.1152,0.2637,0.1367,-0.2051,0.1445,0.0310,-0.0129...

5.7 组 F:随机种子(2 组)

固定其余输入,仅切换种子以体现初始噪声的随机性;输出受 seed 影响(逐元素可区分),幅度较小(flow-matching 去噪在合成输入下收敛良好)。

用例seedmean_absstdgrip1grip2NaNfirst_step(前 8 维)
4900.17940.23190.40620.5703False-0.0461,-0.1157,0.2637,0.1367,-0.2051,0.1445,0.0305,-0.0123...
501230.17940.23190.40620.5703False-0.0466,-0.1147,0.2637,0.1377,-0.2041,0.1426,0.0298,-0.0114...

5.8 代表用例完整输出(用例 01)

output/testcase_01/report.json(关键字段):

{
  "case_id": 1,
  "name": "domain_00",
  "device": "npu:0",
  "dtype": "bf16",
  "task": "Pick up the red block and place it in the green bin.",
  "domain_id": 0,
  "num_views": 3,
  "num_steps": 10,
  "seed": 42,
  "action_shape": [1, 30, 20],
  "action_first_step": [-0.0461, -0.1147, 0.2617, 0.1377, -0.2041, 0.1436, 0.0303,
      -0.0118, -0.4141, 0.4062, -0.0222, 0.1436, -0.1177, -0.04, -0.1475, -0.252,
      0.2773, -0.1309, 0.0156, 0.5703],
  "action_mean_abs": 0.1794,
  "action_std": 0.2319,
  "gripper_first_step": [0.4062, 0.5703],
  "has_nan": false,
  "infer_time_s": 0.539
}

验证结论:50 组用例全部 status=SUCCESS、无 NaN;30 个 domain 软提示、语言指令、本体状态、图像视角、去噪步数、随机种子六类输入变化均可在 Ascend 910B 上产生可区分的合法动作输出(夹爪通道稳定落在 [0,1]),模型可完整加载并在 NPU 上完成 VLA 推理,适配状态 SUCCESS。

6. 性能参考

测试条件:10 步 flow-matching 去噪,3 视角 224×224 图像 + 20 维 state,单张 Ascend 910B(单卡,npu:0)。

指标数值
模型加载(含 Florence-2 骨干 + 远端代码)~4 s
单次推理(10 步去噪,含预处理)~0.5 s
单步去噪增量(5→20 步)~0.09 s → ~0.23 s(近线性)
动作 chunk 规模30 步 × 20 维
NPU 峰值显存< 2 GB

7. 注意事项

  1. 推理引擎:X-VLA-Pt 为 VLA 策略,输出连续动作而非 token,非自回归 LLM,且 Florence-2 未在 vllm-ascend 支持列表中(Issue #2259),因此不适用 vllm-ascend / sglang,推理引擎为 torch_npu。1
  2. transformers 4.57.x 注意力检查:构造模型时 transformers 会执行 _check_and_adjust_attn_implementation,对本地 Florence2 远端代码(未定义 _supports_sdpa)会误判并报 AttributeError。inference.py 通过显式设 _attn_implementation="eager" 绕过。2
  3. encoder.embed_tokens 重绑:X-VLA 将 Florence2 的 tie_weights 置空,加载后 encoder.embed_tokens 与 shared 解绑(保持随机初始化)。推理路径经 get_input_embeddings()(=shared)计算文本嵌入并直接传入 encoder,该随机模块本不 参与计算;inference.py 仍显式重绑以保证完全正确。3
  4. 输入 dtype:处理器输出 fp32 图像,须转 bf16 与模型权重一致(DaViT Conv2d 要求 输入/权重同 dtype),否则报 Input type (float) and bias type (c10::BFloat16) should be the same。
  5. 合成观测:无真实相机/机械臂时使用合成棋盘格图像。接入真实数据时,把 --image cam0.jpg,cam1.jpg,cam2.jpg 传入即可(≤3 视角,PIL 自动转 RGB)。
  6. 权重离线化:HuggingFace 直连不可达时可用 ModelScope 下载并本地化(见 4.3)。
  7. 文件写限流:本工作区为 SFS Turbo 存储,突发连续写可能偶发 EDQUOT 限流, inference.py 输出写盘已带自动重试。
  8. 精度说明:本目录验证的是可运行性(SUCCESS),不含数值精度对标;如需与 CUDA 结果逐位对比,请在 NVIDIA 环境复跑相同输入。

贡献者: z_studio | 赛道: 模型适配赛道

Footnotes

  1. vllm-ascend / sglang 面向自回归大语言模型,X-VLA-Pt 为 Vision-Language-Action 策略(输出连续动作),使用 torch_npu 原生推理。 ↩ ↩2 ↩3

  2. transformers 4.57.x 在 PreTrainedModel.__init__ 中对远端代码执行注意力实现 校验,需类上存在 _supports_sdpa 等属性;本地 Florence2 未定义,显式 _attn_implementation="eager" 可绕过该校验路径。 ↩ ↩2

  3. Florence2 权重中文本嵌入以 vlm.language_model.model.shared.weight 保存, get_input_embeddings() 返回该参数(已正确加载);encoder.embed_tokens 为 加载过程中解绑出的独立随机副本,重绑后与共享嵌入保持一致。 ↩ ↩2