Avoid creating NaNs in binary_cross_entropy_with_logits - #2241
Conversation
Refactor binary_cross_entropy_with_logits to handle NaN cases more robustly.
Add tests for binary_cross_entropy_with_logits at boundary cases.
Benchmark reportthis PR - run time: 1 slower, 0 faster
+ compile time: 1 fasterSignificant changes (2) ──────── run time ─────── ────── compile time ──────
benchmark baseline this PR Δ baseline this PR Δ
────────────────────────────────────────────────────────────────────────────────────────
+ predictive_forward_sampling 729.7 ms 733.8 ms +0.6% 196.2 ms 146.8 ms -25.2%
- nuts_logistic_regression 1.06 s 1.12 s +5.4% 3.34 s 3.48 s +4.2%Red is slower, green is faster; a row is coloured by the worse of its two columns. A delta in parentheses cleared the threshold on a measurement below the resolution floor, so it is shown without being called a change. † marks a benchmark that could not be compared — see below. Full results
|
| baseline | this PR | |
|---|---|---|
| ref | master |
bin-x-ent-fix-nans |
| commit | f107e24d |
3f6041f1 |
| numpyro | 0.21.0 | 0.21.0 |
| jax | 0.11.0 | 0.11.0 |
| backend | cpu | cpu |
| python | 3.14.7 | 3.14.7 |
Runner: Linux-6.17.0-1020-azure-x86_64-with-glibc2.39, 4 CPUs.
Produced by this benchmark run.
|
My pleasure @Qazalbash -- big fan of NumPyro, so I need to give back whenever I can. |
|
Pretty freaky error, don't know what could cause this. Maybe just retry?
|
It is related to GitHub Actions! I am re-triggering the workflow. |
Use the "double where trick" with a short one liner solution for handling the cases where NaNs are created.
Tackles #2240.