CUDA-only device detection caused tensor device mismatch errors on Apple
Silicon Macs where MPS is available but CUDA is not. Fix by detecting MPS
via torch.backends.mps.is_available() and using the flow tensor's own
device for grid creation to avoid cross-device errors.
Co-authored-by: Erdem Akdag <erdemakdag@Erdem-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>