[JAX] Fix jax.scipy.linalg.toeplitz (and hankel) NaN propagation #41860

Merged
copybara-service[bot] opened 1:35pm on October 21, 2026 wanted to merge 1 commit into google/jax main from
test_1004027934
copybara-service[bot] authored commits starting at October 22
Diff Delta:
0
Classified as:  Bug Fix

copybara-service[bot]'s Description of Work

[JAX] Fix jax.scipy.linalg.toeplitz (and hankel) NaN propagation

Problem:
In https://github.com/jax-ml/jax/issues/38636 (and https://github.com/jax-ml/jax/issues/38635), jax.scipy.linalg.toeplitz and jax.scipy.linalg.hankel propagated NaNs incorrectly because their underlying implementations used lax.conv_general_dilated_patches. This convolution implementation expands NaN pollution across the entire output matrix due to structural zero padding interacting with NaN.

Solution:
Replace lax.conv_general_dilated_patches with lax.broadcasted_iota indexing in _toeplitz and _hankel. This propagates NaNs only to their respective indexed locations. Added unit tests with nonfinite values to ensure correctness.

Fixes https://github.com/jax-ml/jax/issues/38635
Fixes https://github.com/jax-ml/jax/issues/38636

2 total changed files
Loading changes...
You’ve reached the end
LGTM-land is officially in view