Skip to content

Add Intel GPU (XPU) support for inference - #3

Open
rv355 wants to merge 2 commits into
pairlab:mainfrom
rv355:rv355/tapestry-xpu-support
Open

rv355 wants to merge 2 commits into
pairlab:mainfrom
rv355:rv355/tapestry-xpu-support

Conversation

@rv355

@rv355 rv355 commented Nov 24, 2026

Copy link
Copy Markdown

Summary

Inference now runs on Intel GPUs through PyTorch's XPU backend. CUDA behavior is unchanged.

  • tapestry/utils/device.py: default_device() (CUDA, else XPU, else CPU) and gpu_device() (CUDA, else XPU, raises when neither is usable).
  • The LIBERO evaluator, scripts/policy_example.py and prepare_release_checkpoint.py --verify use gpu_device(), so a process without a usable GPU stops at start, as with the previous hard-coded "cuda". eval_teacher_forced.py and eval_determinism_at_t.py keep their CPU fallback.
  • visible_gpus() falls back to Intel GPUs when CUDA has none, and each worker is pinned with ZE_AFFINITY_MASK next to CUDA_VISIBLE_DEVICES.
  • The latency benchmarks call torch.cuda or torch.xpu to match the device.
  • README: a short "Run on Intel GPU (XPU)" section under Setup. torch==2.13.* from the XPU index stays inside the existing torch<2.14 pin.
  • Tests for the XPU branch of visible_gpus() and for a worker without a usable GPU.

How it was checked

On an Intel Core Ultra 9 285H with Arc integrated graphics:

  • Released tapestry.pt, TapestryPolicy.act in fp32, XPU against CPU, 4 inputs with 3 noise seeds each, the action noise drawn on the CPU and shared: max abs diff 8.5e-05, cosine 1.0000000 (torch 2.15.0+xpu); max abs diff 8.3e-05 with torch 2.13.0+xpu installed by the new README lines.
  • T5 encoder, XPU against CPU: max abs diff 9.6e-05, cosine 1.0000000.
  • eval_libero_parallel.py and policy_example.py in LIBERO with a checkpoint built from cfg/train_libero.yaml and an untrained action head: workers start on XPU, render and step. Pinned to a device id with no GPU, the worker stops at start with a clear error.
  • prepare_release_checkpoint.py --verify, eval_determinism_at_t.py, eval_teacher_forced.py and both latency benchmarks run on XPU.
  • pytest tests/: 166 passed.

Notes

  • Training (train.py) is unchanged and has only been run on CUDA. AGENTS.md still describes NVIDIA GPUs.

Pick CUDA, then Intel XPU, then the CPU as the default device in the
scripts that run the model and in the LIBERO evaluator, which also
finds Intel GPUs and pins its workers to them with ZE_AFFINITY_MASK.
The latency benchmarks use the matching torch.cuda or torch.xpu calls.
CUDA behavior is unchanged. The README gets a short XPU install section.
A worker pinned to a missing or unusable GPU used to fail when it moved
the model to CUDA. With the CUDA, XPU, CPU fallback it loaded on the CPU
and ran the whole evaluation there. The code that needed CUDA before
(the LIBERO evaluator worker, policy_example.py and the --verify step of
prepare_release_checkpoint.py) now uses CUDA or XPU and raises when
neither is usable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant