[v2.5] Import torch_xla crashed with "TypeError: must be called with a dataclass type or instance" with torch-xla 2.5 and torch 2.5.1+cpu (CPU flavor) 路 Issue #8560 路 pytorch/xla (original) (raw)
馃悰 Bug
When using torch 2.5.1+cpu (CPU flavor), importing torch_xla crashed with "TypeError: must be called with a dataclass type or instance" :
(aws_neuron_venv) ubuntu@ip-10-3-245-151:~$ python -c "import torch_xla"
WARNING:root:MASTER_ADDR environment variable is not set, defaulting to localhost
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch_xla/__init__.py", line 262, in <module>
from .stablehlo import save_as_stablehlo, save_torch_model_as_stablehlo
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch_xla/stablehlo.py", line 18, in <module>
from torch_xla._dynamo import dynamo_bridge
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch_xla/_dynamo/dynamo_bridge.py", line 20, in <module>
from torch._inductor.fx_passes.post_grad import ConstructorMoverPass
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch/_inductor/fx_passes/post_grad.py", line 16, in <module>
from torch._inductor import comms
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch/_inductor/comms.py", line 13, in <module>
from . import config, ir
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch/_inductor/ir.py", line 77, in <module>
from .runtime.hints import ReductionHint
File "/home/ubuntu/aws_neuron_venv/lib/python3.10/site-packages/torch/_inductor/runtime/hints.py", line 36, in <module>
attr_desc_fields = {f.name for f in fields(AttrsDescriptor)}
File "/usr/lib/python3.10/dataclasses.py", line 1198, in fields
raise TypeError('must be called with a dataclass type or instance') from None
TypeError: must be called with a dataclass type or instance
This issue doesn't affect torch-xla 2.6 (rc3).
To Reproduce
Steps to reproduce the behavior:
pip install --force-reinstall torch-xla==2.5.1 torch==2.5.1 torchvision --extra-index-url https://download.pytorch.org/whl/cpu/
python -c "import torch_xla"
Expected behavior
No crash
Environment
- Reproducible on XLA backend [CPU/TPU/CUDA]:
- torch_xla version: 2.5.1