Ok,
I mean out.is_sparse but I guess it’s not really important here.
If you have you code crashing then you should:

Run it on cpu. Make sure it runs without error and see if it has the same behaviour.
If the cpu version does not crash and return proper values. Then run the cuda version with CUDA_LAUNCH_BLOCKING=1 python your_script.py. This will make cuda do a bit more error checking, notably stop the execution before returning garbage values. With this enabled, you should not see any garbage value anymore and you should see a proper error message.