Commit dfc5a98
fix: lift nufftax to 0.6.x + rank-guard its vmap batching (batched nufft2d2 grad)
Two stacked fixes for differentiating through TransformerNUFFT's batched
transform_mapping_matrix (PyAutoArray#424, the nightly release blocker):
1. nufftax 0.4.0's _nufft2d2_bwd assumed 2-D f, so any gradient of an
interferometer inversion crashed. 0.6.x supports batched input natively
with primitive-based autodiff; its forward transform is bit-identical to
0.4.0 at eps=1e-12 (2-D and batched, x64), so pinned baselines are safe.
The old <0.5.0 cap only existed for the Python 3.11 floor, now gone.
2. nufftax 0.6.x's own batching fast path re-binds a primitive unchanged
whenever only the source arg is vmapped, with no rank guard — nested
batching (jax.vmap(jax.value_and_grad(...)) over an already-batched
mapping matrix, i.e. MultiStartProdigy) accumulates dims until tracing
crashes. _patch_nufftax_batchers() re-registers every primitive's batcher
with the guard: within native rank bind as before, beyond it collapse the
stacked batch axes into the one native axis and unflatten the output.
Applied only for nufftax 0.6.x; drop when fixed upstream.
Verified: vmap(value_and_grad) matches a per-item loop exactly (jit(vmap) to
~1e-12); autogalaxy_workspace scripts/interferometer/start_here.py completes
end-to-end where it previously crashed; full suite 929 passed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 71cb762 commit dfc5a98
2 files changed
Lines changed: 69 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
32 | 97 | | |
33 | 98 | | |
34 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | | - | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
0 commit comments