sbi
sbi copied to clipboard
VIPosterior with device="mps" fails for "nsf"
Describe the bug
When using VIPosterior with "mps" as the GPU device, and setting q="nsf" with num_dim=1, sampling from q leads to NaNs.
To Reproduce
To reproduce the issue, follow these steps:
- Use Python 3.11 with SBI 0.22.0.
- On MacOS with MPS enabled, execute
pytest tests/inference_on_device_test.py::test_vi_on_gpu.
Expected behavior
Sampling from q should not result in NaNs.
Additional context
This issue is specific to the MPS device and does not occur on the CPU. It may be related to or blocked by this PyTorch issue: https://github.com/pytorch/pytorch/issues/89127.
Note
Testing on a Mac is required due to MPS device dependency.
This might be fixed on more recent versions and needs to be tested
see also #912
To solve this issue:
- check out https://github.com/pytorch/pytorch/issues/89127#issuecomment-2579000927
- reproduce locally dependent on the torch version
- change the test to be dependent on the pytorch version, using
pytest.mark.xfail(condition=..., reason=...)