- Use
SingleXPUStrategy(device_index=0)to run Lightning and NeuralForecast on nativetorch.xpu.
That's it. Tested here on Intel Arc Pro B50 / Ubuntu 25.10 and Windows 11 with torch==2.11.0+xpu, pytorch-lightning==2.6.1, and neuralforecast==3.1.6.
→ I just want the fix — skip to Copy one file → I want to run a working example first — skip to Run the examples
Copy xpu_lightning.py.
NativeXPUAcceleratorsubclassesAcceleratorand maps Lightning's device hooks to nativetorch.xpu.SingleXPUStrategysubclassesSingleDeviceStrategyand buildstorch.device("xpu", device_index)aroundNativeXPUAccelerator().
import pytorch_lightning as L
from xpu_lightning import SingleXPUStrategy
trainer = L.Trainer(
strategy=SingleXPUStrategy(device_index=0),
devices=1,
)from neuralforecast import NeuralForecast
from neuralforecast.models import NHITS
from xpu_lightning import SingleXPUStrategy
model = NHITS(
h=12,
input_size=24,
max_steps=20,
strategy=SingleXPUStrategy(device_index=0),
devices=1,
)
nf = NeuralForecast(models=[model], freq="1d")
nf.fit(df)See minimal_lightning_xpu.py and minimal_neuralforecast_xpu.py.
WARNING: DO NOT INSTALL
intel_extension_for_pytorchHERE. This repo uses native torch.xpu only.
pip install --index-url https://download.pytorch.org/whl/xpu "torch==2.11.0"
pip install "pytorch-lightning==2.6.1" "neuralforecast==3.1.6" "polars==1.38.1" "pytest==8.4.2" "scipy==1.17.1"Or with uv (a fast package installer):
uv pip install torch --index https://download.pytorch.org/whl/xpu
uv pip install -r requirements.txtpython minimal_lightning_xpu.py
# or: uv run minimal_lightning_xpu.pypython minimal_neuralforecast_xpu.py
# or: uv run minimal_neuralforecast_xpu.pypython -m pytest -s examples/
# or: uv run pytest -s examples/Expected output:
GPU available: False, used: Falseis normal for nativetorch.xpu.
Quick check during training: model.layer.weight.device.type should be xpu, or use torch.xpu.get_device_name(0).
Lightning checks accelerator by name, so this is the error you hit first:
ValueError: invalid accelerator name: xpu
Passing SingleXPUStrategy(device_index=0) sidesteps that string check. Lightning gets a ready-made strategy instance and follows its native torch.device("xpu", 0) path instead.
That whole bridge lives in xpu_lightning.py. The two classes in that file are 87 lines total.
| Package | Tested | Tested |
|---|---|---|
| OS | Ubuntu 25.10 | Windows 11 |
| Python | 3.13.12 | 3.12.13 |
| torch (xpu wheel) | 2.11.0+xpu | 2.11.0+xpu |
| pytorch_lightning | 2.6.1 | 2.6.1 |
| neuralforecast | 3.1.6 | 3.1.6 |
| polars | 1.38.1 | 1.38.1 |
| intel_extension_for_pytorch | not installed | not installed |
These are the versions tested in this repo. Other versions may work, but they are not verified here. NeuralForecast currently publishes Python 3.10-3.13 classifiers, and Python 3.14 is not yet supported there.
xpu_lightning.py ← copy this; accelerator + strategy
minimal_lightning_xpu.py Lightning demo on xpu:0
minimal_neuralforecast_xpu.py NeuralForecast demo on xpu:0
examples/
test_vram_proof.py VRAM allocation proof on xpu:0
test_performance.py CPU vs XPU MLP comparison
test_lightning_xpu.py Lightning fit on xpu:0
test_smoke_xpu.py XPU and class smoke test
test_neuralforecast_xpu.py NHITS fit and predict on xpu:0
requirements.txt pinned versions + XPU wheel note
Lightning has no built-in XPU accelerator yet; see issue #20938. PyTorch has supported Intel GPUs natively since 2.5 (October 2024). Intel EOL'd IPEX (their legacy PyTorch extension) in March 2026. This repo is the shortest working bridge.
MIT