Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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) #8560

Open
jeffhataws opened this issue Jan 13, 2025 · 1 comment

Comments

@jeffhataws
Copy link
Collaborator

🐛 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

Additional context

@jeffhataws
Copy link
Collaborator Author

Problem occurs on Python 3.10 but not Python 3.9. I have not tried Python 3.11.

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

No branches or pull requests

1 participant