sbi icon indicating copy to clipboard operation
sbi copied to clipboard

VIPosterior with device="mps" fails for "nsf"

Open janfb opened this issue 1 year ago • 1 comments

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:

  1. Use Python 3.11 with SBI 0.22.0.
  2. 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

janfb avatar Feb 16 '24 15:02 janfb

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=...)

janfb avatar Mar 13 '25 07:03 janfb