Describe the bug
After upgrading to PyTorch 2.8.0, compilation involving LabelTensor fails due to incorrect inference of runtime_type in the torch compilation pipeline. This results in a RuntimeError during the backward pass.
To Reproduce
Upgrade to PyTorch 2.8.0 and run:
pytest tests/test_solver/test_pinn.py
You might also want to upgrade torchvision.
Expected behavior
All tests should pass successfully, and compilation should handle LabelTensor without metadata mismatches.
Output
RuntimeError:
E During the backward, we encountered a tensor subclass where we guessed its
E metadata incorrectly.
E
E Expected metadata: None, expected type: <class 'torch.Tensor'>
E
E Runtime metadata: None, runtime type: <class 'pina.label_tensor.LabelTensor'>
E
E shape: torch.Size([1, 1])
E To fix this, your tensor subclass must implement the dunder method __force_to_same_metadata__.
Additional context
- Implementing
__force_to_same_metadata__ in LabelTensor did not resolve the issue.
- This might be related to changes introduced in the compilation pipeline in PyTorch 2.8.
- The issue was not observed in PyTorch 2.7.x.
Describe the bug
After upgrading to PyTorch 2.8.0, compilation involving
LabelTensorfails due to incorrect inference ofruntime_typein the torch compilation pipeline. This results in aRuntimeErrorduring the backward pass.To Reproduce
Upgrade to PyTorch 2.8.0 and run:
You might also want to upgrade torchvision.
Expected behavior
All tests should pass successfully, and compilation should handle
LabelTensorwithout metadata mismatches.Output
Additional context
__force_to_same_metadata__inLabelTensordid not resolve the issue.