jax
60de4356 - Fix custom_linear_solve JVP and transpose rules for partial tangents

Commit
3 days ago
Fix custom_linear_solve JVP and transpose rules for partial tangents Fixes https://github.com/jax-ml/jax/issues/10929. When differentiating `jax.lax.custom_linear_solve` with tangents on only some leaves of a pytree `b` (or only on values closed over by `solve`), `_custom_linear_solve_jvp` passed `ad_util.Zero` leaves directly into `linear_solve_p.bind` when `matvec` had no tangents, raising `TypeError`. In reverse mode, mixing tangent tracers with concrete zero arrays in `rhs` also hit `assert all(ad.is_undefined_primal(x) for x in b)` in `_linear_solve_transpose_rule`. In `_custom_linear_solve_jvp`, return symbolic zeros (`ad_util.p2tz`) when all `rhs` leaves are `Zero`, and call `ad.instantiate_zeros` on `rhs` otherwise. In `_linear_solve_transpose_rule`, remove the assert and return `None` for non-linear leaves of `b`. PiperOrigin-RevId: 1032831632
Author
Paul McMullin
Parents
Loading