Run fn with on-device NaN / Inf detection (JIT-compatible).
- Parameters:
fn (Callable) – The function to debug.
*args – Arguments to pass to the function.
phase (str) – Label prepended to the error message.
Notes
This function is fully JIT-compatible. All NaN checks run on the device;
no data is moved to the CPU unless NaN is actually detected.