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。
| 组件 | 版本 |
|---|---|
| torch | 2.9.0(CPU build + torch_npu 扩展) |
| torch-npu | 2.9.0.post1+gitee7ba04 |
| transformers | 4.57.6 |
| timm | 1.0.15 |
| json-numpy | 2.1.1 |
| CANN | 8.5.1 |
| Python | 3.11.14 |
| NPU | Ascend 910B(Atlas 800T A2,64GB HBM × 2) |
| vllm-ascend / sglang | 不适用(本模型不使用)1 |
模型权重路径:
| 权重 | 路径 |
|---|---|
| X-VLA-Pt(含 config / safetensors / 远端代码) | /data/models/2toINF/X-VLA-Pt |
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/bf16 | DaViT 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 中,不修改任何三方库源码):
AutoConfig.from_pretrained 加载 XVLAConfig,并在 config._attn_implementation 与 config.florence_config._attn_implementation 上显式设置 "eager";AutoModel.from_pretrained(..., trust_remote_code=True, dtype=bf16) 加载权重,执行 model.to('npu:0');加载后将 encoder.embed_tokens.weight 重绑到 shared.weight;AutoProcessor.from_pretrained(..., trust_remote_code=True) 加载 XVLAProcessor;model.generate_actions(input_ids, image_input, image_mask, domain_id, proprio, steps) 完成 flow-matching 去噪,输出 (B, num_actions=30, dim_action=20) 动作;action_space.postprocess 的 sigmoid 归一至 [0,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 依赖。
```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# 权重已本地化于 /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')"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 真实图像路径等)。
./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 可运行子集并支持断点续跑。
共 50 组(满足≥44组的要求),模型仅加载一次、逐组推理,覆盖6类输入变化:
| 组 | 用例编号 | 变化维度 | 说明 |
|---|---|---|---|
| A | 01–30 | domain_id 0~29(全部30个本体域) | 验证跨本体 soft prompt 生效 |
| B | 31–38 | 8组语言指令 | 同一域下指令差异 |
| C | 39–42 | 4组本体状态(20维) | 状态差异 |
| D | 43–45 | 图像视角数/色偏(1/2/3视角) | 多视角输入 |
| E | 46–48 | flow-matching 去噪步数(5/10/20) | 采样步数影响 |
| F | 49–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]。
固定指令/状态/图像/seed=42/steps=10,仅切换 domain_id。各域输出明显不同
(mean_abs 0.120.40,夹爪 0.000.92),证明30组本体 soft prompt 均被正确激活。
first_step 为 action 第1步的完整20维向量(含 sigmoid 后夹爪值)。
| 用例 | 名称 | mean_abs | std | grip1 | grip2 | NaN | first_step(20维) |
|---|---|---|---|---|---|---|---|
| 01 | domain_00 | 0.1794 | 0.2319 | 0.4062 | 0.5703 | False | -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 |
| 02 | domain_01 | 0.2362 | 0.2753 | 0.4648 | 0.5273 | False | -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 |
| 03 | domain_02 | 0.2223 | 0.2673 | 0.4336 | 0.5781 | False | -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 |
| 04 | domain_03 | 0.1861 | 0.2384 | 0.4922 | 0.3945 | False | -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 |
| 05 | domain_04 | 0.1592 | 0.2144 | 0.4258 | 0.4961 | False | 0.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 |
| 06 | domain_05 | 0.1744 | 0.2285 | 0.5156 | 0.4785 | False | -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 |
| 07 | domain_06 | 0.2095 | 0.2393 | 0.5391 | 0.4648 | False | 0.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 |
| 08 | domain_07 | 0.2152 | 0.2569 | 0.4766 | 0.5703 | False | -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 |
| 09 | domain_08 | 0.1591 | 0.1839 | 0.4883 | 0.5273 | False | 0.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 |
| 10 | domain_09 | 0.1584 | 0.2128 | 0.5078 | 0.5273 | False | -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 |
| 11 | domain_10 | 0.3870 | 0.5047 | 0.9180 | 0.5898 | False | 0.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 |
| 12 | domain_11 | 0.1794 | 0.3481 | 0.0527 | 0.0000 | False | 0.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 |
| 13 | domain_12 | 0.1218 | 0.2494 | 0.0051 | 0.0000 | False | -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 |
| 14 | domain_13 | 0.1390 | 0.2652 | 0.0020 | 0.0000 | False | -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 |
| 15 | domain_14 | 0.1601 | 0.2837 | 0.0013 | 0.0000 | False | -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 |
| 16 | domain_15 | 0.4033 | 0.4805 | 0.0083 | 0.7891 | False | 0.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 |
| 17 | domain_16 | 0.3805 | 0.4434 | 0.0737 | 0.0005 | False | 0.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 |
| 18 | domain_17 | 0.3400 | 0.4712 | 0.0248 | 0.0003 | False | 0.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 |
| 19 | domain_18 | 0.1841 | 0.2291 | 0.4941 | 0.4609 | False | 0.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 |
| 20 | domain_19 | 0.2113 | 0.2561 | 0.5195 | 0.4629 | False | -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 |
| 21 | domain_20 | 0.1892 | 0.2254 | 0.5352 | 0.4648 | False | -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 |
| 22 | domain_21 | 0.2091 | 0.2412 | 0.5508 | 0.4473 | False | -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 |
| 23 | domain_22 | 0.1998 | 0.2390 | 0.4180 | 0.4844 | False | -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 |
| 24 | domain_23 | 0.1605 | 0.2181 | 0.4668 | 0.5352 | False | -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 |
| 25 | domain_24 | 0.1866 | 0.2203 | 0.4609 | 0.5195 | False | -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 |
| 26 | domain_25 | 0.2238 | 0.2721 | 0.5508 | 0.5117 | False | -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 |
| 27 | domain_26 | 0.2188 | 0.2611 | 0.4395 | 0.5703 | False | 0.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 |
| 28 | domain_27 | 0.1925 | 0.2450 | 0.4746 | 0.5664 | False | -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 |
| 29 | domain_28 | 0.2082 | 0.2530 | 0.5156 | 0.5312 | False | -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 |
| 30 | domain_29 | 0.1963 | 0.2293 | 0.5234 | 0.4258 | False | 0.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 |
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).
| Case | Language Instruction | mean_abs | std | grip1 | grip2 | NaN | first_step (first 8 dims) |
|---|---|---|---|---|---|---|---|
| 31 | Pick up the red block and place it in the green bin. | 0.1794 | 0.2319 | 0.4062 | 0.5703 | False | -0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118... |
| 32 | Move the blue cube to the right side. | 0.1798 | 0.2322 | 0.4062 | 0.5703 | False | -0.0471,-0.1172,0.2617,0.1406,-0.2012,0.1387,0.0327,-0.0101... |
| 33 | Place the mug on the saucer. | 0.1794 | 0.2318 | 0.4062 | 0.5703 | False | -0.0449,-0.1143,0.2637,0.1387,-0.2021,0.1416,0.0302,-0.0104... |
| 34 | Push the yellow button. | 0.1789 | 0.2316 | 0.4062 | 0.5703 | False | -0.0437,-0.1157,0.2598,0.1396,-0.1963,0.1426,0.0308,-0.0101... |
| 35 | Open the drawer and take out the spoon. | 0.1795 | 0.2322 | 0.4082 | 0.5703 | False | -0.0447,-0.1172,0.2598,0.1387,-0.1992,0.1426,0.0294,-0.0091... |
| 36 | Tuck in the chair. | 0.1796 | 0.2319 | 0.4082 | 0.5703 | False | -0.0474,-0.1138,0.2656,0.1416,-0.2021,0.1406,0.0260,-0.0106... |
| 37 | Knock over the cup. | 0.1792 | 0.2320 | 0.4062 | 0.5703 | False | -0.0449,-0.1143,0.2656,0.1396,-0.2002,0.1416,0.0287,-0.0101... |
| 38 | Wipe the whiteboard. | 0.1790 | 0.2316 | 0.4062 | 0.5703 | False | -0.0439,-0.1123,0.2656,0.1396,-0.2002,0.1416,0.0291,-0.0120... |
With fixed domain=0 / instruction / 3 views / seed=42 / steps=10, only the 20-dimensional state is switched.
| Case | state (first 6 dims) | mean_abs | std | grip1 | grip2 | NaN | first_step (first 8 dims) |
|---|---|---|---|---|---|---|---|
| 39 | 0,0,0,0,0,0,... | 0.1794 | 0.2319 | 0.4062 | 0.5703 | False | -0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118... |
| 40 | 0.1,-0.2,0.05,0.5,-0.3,0.2,... | 0.1792 | 0.2317 | 0.4062 | 0.5703 | False | -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.1796 | 0.2320 | 0.4062 | 0.5703 | False | -0.0488,-0.1167,0.2637,0.1357,-0.2041,0.1445,0.0311,-0.0137... |
| 42 | 0.05,0.05,0.1,-0.4,0.2,0.6,... | 0.1794 | 0.2320 | 0.4062 | 0.5703 | False | -0.0466,-0.1143,0.2637,0.1348,-0.2061,0.1484,0.0310,-0.0143... |
固定 domain=0 / 指令 / state 全零 / seed=42 / steps=10,切换视角数与基准色偏 hue。
| 用例 | 视角配置 | mean_abs | std | grip1 | grip2 | NaN | first_step(前 8 维) |
|---|---|---|---|---|---|---|---|
| 43 | 1 视角(hue=0.5) | 0.1790 | 0.2313 | 0.4082 | 0.5703 | False | -0.0415,-0.1138,0.2578,0.1475,-0.1895,0.1377,0.0349,0.0006... |
| 44 | 2 视角(hue=0.2) | 0.1797 | 0.2327 | 0.4062 | 0.5703 | False | -0.0410,-0.1138,0.2578,0.1396,-0.2041,0.1416,0.0330,-0.0100... |
| 45 | 3 视角(hue=0.8) | 0.1793 | 0.2317 | 0.4062 | 0.5703 | False | -0.0439,-0.1167,0.2598,0.1396,-0.2031,0.1426,0.0315,-0.0127... |
固定 domain=0 / 指令 / 3 视角 / seed=42,切换 flow-matching 去噪步数。步数越多耗时越高(约线性),输出收敛稳定(mean_abs ≈ 0.1794~0.1795,无 NaN)。
| 用例 | steps | mean_abs | std | grip1 | grip2 | NaN | first_step(前 8 维) |
|---|---|---|---|---|---|---|---|
| 46 | 5 | 0.1795 | 0.2321 | 0.4062 | 0.5703 | False | -0.0447,-0.1147,0.2637,0.1387,-0.2061,0.1445,0.0298,-0.0123... |
| 47 | 10 | 0.1794 | 0.2319 | 0.4062 | 0.5703 | False | -0.0461,-0.1147,0.2617,0.1377,-0.2041,0.1436,0.0303,-0.0118... |
| 48 | 20 | 0.1795 | 0.2320 | 0.4062 | 0.5703 | False | -0.0464,-0.1152,0.2637,0.1367,-0.2051,0.1445,0.0310,-0.0129... |
固定其余输入,仅切换种子以体现初始噪声的随机性;输出受 seed 影响(逐元素可区分),幅度较小(flow-matching 去噪在合成输入下收敛良好)。
| 用例 | seed | mean_abs | std | grip1 | grip2 | NaN | first_step(前 8 维) |
|---|---|---|---|---|---|---|---|
| 49 | 0 | 0.1794 | 0.2319 | 0.4062 | 0.5703 | False | -0.0461,-0.1157,0.2637,0.1367,-0.2051,0.1445,0.0305,-0.0123... |
| 50 | 123 | 0.1794 | 0.2319 | 0.4062 | 0.5703 | False | -0.0466,-0.1147,0.2637,0.1377,-0.2041,0.1426,0.0298,-0.0114... |
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。
测试条件: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 |
_check_and_adjust_attn_implementation,对本地 Florence2 远端代码(未定义
_supports_sdpa)会误判并报 AttributeError。inference.py 通过显式设
_attn_implementation="eager" 绕过。2tie_weights 置空,加载后
encoder.embed_tokens 与 shared 解绑(保持随机初始化)。推理路径经
get_input_embeddings()(=shared)计算文本嵌入并直接传入 encoder,该随机模块本不
参与计算;inference.py 仍显式重绑以保证完全正确。3Input type (float) and bias type (c10::BFloat16) should be the same。--image cam0.jpg,cam1.jpg,cam2.jpg 传入即可(≤3 视角,PIL 自动转 RGB)。EDQUOT 限流,
inference.py 输出写盘已带自动重试。贡献者: z_studio | 赛道: 模型适配赛道
vllm-ascend / sglang 面向自回归大语言模型,X-VLA-Pt 为 Vision-Language-Action 策略(输出连续动作),使用 torch_npu 原生推理。 ↩ ↩2 ↩3
transformers 4.57.x 在 PreTrainedModel.__init__ 中对远端代码执行注意力实现
校验,需类上存在 _supports_sdpa 等属性;本地 Florence2 未定义,显式
_attn_implementation="eager" 可绕过该校验路径。 ↩ ↩2
Florence2 权重中文本嵌入以 vlm.language_model.model.shared.weight 保存,
get_input_embeddings() 返回该参数(已正确加载);encoder.embed_tokens 为
加载过程中解绑出的独立随机副本,重绑后与共享嵌入保持一致。 ↩ ↩2