This repository adapts 2toINF/X-VLA-Pt — a
Florence2-based Vision-Language-Action (VLA) model (~0.9B params, single model.safetensors,
action mode ee6d, 30 action steps) — to run on Ascend NPU via torch-npu.
All CUDA-related calls are removed; the model and input tensors are placed on npu:0.
| Item | Value |
|---|---|
| Base model | Florence-2 large encoder + SoftPromptedTransformer |
| Model class | XVLA (model_type: xvla) |
| Action space | ee6d (end-effector xyz + 6D rotation + gripper, dim 20) |
| Weights | model.safetensors (~3.3 GB) cached under model_weights/ |
| Device | npu:0 (Ascend), bfloat16 |
| License | Apache-2.0 |
X-VLA is a soft-prompted Transformer Vision-Language-Action model for cross-embodiment robot learning. It uses:
For a single input image and a language instruction the model predicts an action sequence
(num_actions x dim_action). This repo focuses on the NPU inference path.
.
├── inference.py # CLI + FastAPI dual-mode inference on npu:0 (no CUDA)
├── README.md
├── xvla/ # snapshot of the repo's custom modeling code (Apache-2.0)
│ ├── modeling_xvla.py # XVLA model class
│ ├── configuration_xvla.py # XVLAConfig
│ ├── modeling_florence2.py # Florence2 backbone
│ ├── configuration_florence2.py
│ ├── processing_xvla.py # XVLAProcessor
│ ├── transformer.py # SoftPromptedTransformer
│ └── action_hub.py # action-space registry (ee6d / joint / agibot)
├── config.json / preprocessor_config.json / tokenizer.json / vocab.json
├── assets/ # screenshots (published to repo root)
└── model_weights/ # <-- local cache, git-ignored, NOT pushed
└── X-VLA-Pt/
├── model.safetensors
├── config.json
├── ... modeling files ...grep -rni cuda on the codebase returns nothing. All tensors use
.to(device) / .to(npu:0) and the modeling code derives the device from the inputs, so it
is device-agnostic by design.try-except inside inference.init_device() with a clear error
message if the Ascend NPU is unavailable.input_ids, image_input, image_mask, proprio, domain_id)
are placed on npu:0; the model runs in bfloat16.torch_npu prints many harmless ownership/collect-env warnings on stdout — these can be
ignored.xvla package
(xvla.modeling_xvla.XVLA, xvla.processing_xvla.XVLAProcessor) — a device-agnostic snapshot
of the repo's modeling files with a timm-free DropPath fallback and the newer-transformers
attention-capability flags (_supports_sdpa etc.) so the model instantiates cleanly.pip install torch torch_npu transformers huggingface_hub fastapi uvicorn pillow numpy opencv-python json_numpySet the HF endpoint to the GitCode mirror used for downloads:
export HF_ENDPOINT=https://hf-mirror.compython3 inference.py --img test.png --instruction "pick up the object"The weights are auto-downloaded into ./model_weights/X-VLA-Pt on the first run and reused
afterwards (local cache is checked first; no re-download).
Example output (truncated):
{
"model": "2toINF/X-VLA-Pt",
"device": "npu:0",
"instruction": "pick up the object",
"action_mode": "ee6d",
"num_actions": 30,
"dim_action": 20,
"domain_id": 0,
"steps": 6,
"action": [...],
"status": "ok"
}Options: --img <path>, --instruction "...", --domain <id>, --steps <n>, --seed <n>,
--dtype bfloat16|float32.
python3 inference.py --server --host 0.0.0.0 --port 8000# health check
curl http://127.0.0.1:8000/health
# inference: POST an image file (multipart)
curl -X POST http://127.0.0.1:8000/predict \
-F "file=@test.png" \
-F "instruction=pick up the object" \
-F "domain_id=0" \
-F "steps=6"Response is the same JSON result as the CLI mode.
Ran on Ascend 910 (CANN 8.5.1, torch-npu):
$ python3 inference.py --img test.png
[INFO] Using local weights from ./model_weights/X-VLA-Pt
[INFO] Device: npu:0
[INFO] Running single-image inference on npu:0: test.png
{ "model": "2toINF/X-VLA-Pt", "device": "npu:0", ... "action": [...] , "status": "ok" }--seed 0) so
results are reproducible across runs.num_actions=30 future end-effector poses (dim 20 per step, ee6d) are returned. The
action_mean row in the JSON gives a compact summary; the last two channels are the
post-processed (sigmoid) gripper values.model.safetensors does not ship the shared
embed_tokens weight matrix (it is tied to the Florence2 decoder, which the XVLA code deletes).
On load, transformers therefore reports that vlm.language_model.model.encoder.embed_tokens.weight
is newly initialized. This is a property of the upstream checkpoint (the same warning appears
with the official AutoModel.from_pretrained(..., trust_remote_code=True) usage) and does not
affect the flow-matching action head; the model still runs and produces a deterministic output
on npu:0.xvla package keeps the modeling code self-contained
(no mandatory timm dependency — a local DropPath fallback is used when timm is absent).torch_npu prints many ownership / collect-env warnings on stdout — they are harmless and can
be ignored.